[Git][debian-gis-team/pyosmium][master] 4 commits: New upstream version 2.15.1

Bas Couwenberg gitlab at salsa.debian.org
Fri Jan 25 06:12:42 GMT 2019


Bas Couwenberg pushed to branch master at Debian GIS Project / pyosmium


Commits:
49efdd8c by Bas Couwenberg at 2019-01-25T05:58:10Z
New upstream version 2.15.1
- - - - -
ff18570f by Bas Couwenberg at 2019-01-25T05:58:12Z
Merge tag 'upstream/2.15.1'

Upstream version 2.15.1

- - - - -
25d35333 by Bas Couwenberg at 2019-01-25T05:58:43Z
New upstream release.

- - - - -
1425d4da by Bas Couwenberg at 2019-01-25T05:59:22Z
Set distribution to unstable.

- - - - -


9 changed files:

- .travis.yml
- CHANGELOG.md
- debian/changelog
- src/osmium/replication/utils.py
- src/osmium/version.py
- test/helpers.py
- + test/test_pyosmium_get_changes.py
- test/test_replication.py
- tools/pyosmium-get-changes


Changes:

=====================================
.travis.yml
=====================================
@@ -23,13 +23,9 @@ matrix:
           compiler: gcc
           env: USE_PYTHON_VERSION=3
         - os: osx
-          osx_image: xcode8.3
+          osx_image: xcode7
           compiler: clang
-          env: USE_PYTHON_VERSION=3
-        - os: osx
-          osx_image: xcode9.4
-          compiler: clang
-          env: USE_PYTHON_VERSION=3
+          env: USE_PYTHON_VERSION=
         - os: osx
           osx_image: xcode10.1
           compiler: clang


=====================================
CHANGELOG.md
=====================================
@@ -4,6 +4,20 @@
 All notable changes to this project will be documented in this file.
 This project adheres to [Semantic Versioning](http://semver.org/).
 
+## [2.15.1] - 2019-01-24
+
+### Added
+
+- tests for pyosmium-get-changes
+
+### Changed
+
+- do not read data when checking for replication headers
+
+### Fixed
+
+- fix typo in sequence file reading of pyosmium-get-changes
+
 ## [2.15.0] - 2018-12-09
 
 ### Added


=====================================
debian/changelog
=====================================
@@ -1,8 +1,9 @@
-pyosmium (2.15.0-2) UNRELEASED; urgency=medium
+pyosmium (2.15.1-1) unstable; urgency=medium
 
+  * New upstream release.
   * Bump Standards-Version to 4.3.0, no changes.
 
- -- Bas Couwenberg <sebastic at debian.org>  Tue, 25 Dec 2018 23:03:57 +0100
+ -- Bas Couwenberg <sebastic at debian.org>  Fri, 25 Jan 2019 06:59:10 +0100
 
 pyosmium (2.15.0-1) unstable; urgency=medium
 


=====================================
src/osmium/replication/utils.py
=====================================
@@ -4,6 +4,7 @@ import logging
 import datetime as dt
 from collections import namedtuple
 from osmium.io import Reader as oreader
+from osmium.osm import NOTHING
 from sys import version_info as python_version
 
 log = logging.getLogger('pyosmium')
@@ -21,7 +22,7 @@ def get_replication_header(fname):
         a `RuntimeError` is raised.
     """
 
-    r = oreader(fname)
+    r = oreader(fname, NOTHING)
     h = r.header()
 
     ts = h.get("osmosis_replication_timestamp")


=====================================
src/osmium/version.py
=====================================
@@ -5,7 +5,7 @@ Version information.
 # the major version
 pyosmium_major = '2.15'
 # current release (Pip version)
-pyosmium_release = '2.15.0'
+pyosmium_release = '2.15.1'
 
 # libosmium version shipped with the Pip release
 libosmium_version = '2.15.0'


=====================================
test/helpers.py
=====================================
@@ -18,6 +18,19 @@ else:
         return datetime(*args)
 
 
+def load_script(filename):
+    """ Load an executable script into its own private environment.
+    """
+    src = os.path.normpath(filename)
+    globvars = dict()
+    if sys.version_info[0] >= 3:
+        exec(compile(open(src, "rb").read(), src, 'exec'), globvars)
+    else:
+        execfile(src, globvars)
+
+    return globvars
+
+
 def _complete_object(o):
     """Takes a hash with an incomplete OSM object description and returns a
        complete one.


=====================================
test/test_pyosmium_get_changes.py
=====================================
@@ -0,0 +1,92 @@
+""" Tests for the pyosmium-get-changes script.
+"""
+
+from helpers import load_script
+from nose.tools import *
+import unittest
+from io import BytesIO
+from os import path as osp
+from textwrap import dedent
+import sys
+import tempfile
+
+try:
+    from cStringIO import StringIO
+except:
+    from io import StringIO
+
+try:
+    from urllib.error import URLError
+except ImportError:
+    from urllib2 import URLError
+
+try:
+    from unittest.mock import MagicMock, DEFAULT
+except ImportError:
+    from mock import MagicMock, DEFAULT
+
+class Capturing(list):
+    def __enter__(self):
+        self._stdout = sys.stdout
+        sys.stdout = self._stringio = StringIO()
+        return self
+    def __exit__(self, *args):
+        self.extend(self._stringio.getvalue().splitlines())
+        del self._stringio    # free up some memory
+        sys.stdout = self._stdout
+
+
+class TestPyosmiumGetChanges(unittest.TestCase):
+
+    def setUp(self):
+        self.script = load_script(osp.join(osp.realpath(__file__),
+                                           "../../tools/pyosmium-get-changes"))
+        self.url_mock = MagicMock()
+        self.urls = dict()
+        self.url_mock.side_effect = lambda url : self.urls[url]
+        self.script['rserv'].urlrequest.urlopen = self.url_mock
+
+    def url(self, url, result):
+        self.urls[url] = BytesIO(dedent(result).encode())
+
+    def main(self, *args):
+        with Capturing() as output:
+            ret = self.script['main'](args)
+            self.stdout = output
+        return ret
+
+    def test_init_id(self):
+        assert_equals(0, self.main('-I', '453'))
+        assert_equals(1, len(self.stdout))
+        assert_equals('454', self.stdout[0])
+
+    def test_init_date(self):
+        self.url('https://planet.osm.org/replication/minute//state.txt',
+                 """\
+                    sequenceNumber=100
+                    timestamp=2017-08-26T11\:04\:02Z
+                 """)
+        self.url('https://planet.osm.org/replication/minute//000/000/000.state.txt',
+                 """\
+                    sequenceNumber=0
+                    timestamp=2016-08-26T11\:04\:02Z
+                 """)
+        assert_equals(0, self.main('-D', '2015-12-24T08:08:08Z'))
+        assert_equals(1, len(self.stdout))
+        assert_equals('1', self.stdout[0])
+
+    def test_init_to_file(self):
+        with tempfile.NamedTemporaryFile(dir=tempfile.gettempdir(), suffix='.seq') as fd:
+            assert_equals(0, self.main('-I', '453', '-f', fd.name))
+            content = fd.read()
+            assert_equals('454', content.decode('utf-8'))
+
+    def test_init_from_seq_file(self):
+        with tempfile.NamedTemporaryFile(dir=tempfile.gettempdir(), suffix='.seq') as fd:
+            fd.write('453'.encode('utf-8'))
+            fd.flush()
+            assert_equals(0, self.main('-f', fd.name))
+            fd.seek(0)
+            content = fd.read()
+            assert_equals('454', content.decode('utf-8'))
+


=====================================
test/test_replication.py
=====================================
@@ -17,6 +17,7 @@ except ImportError:
 
 import osmium as o
 import osmium.replication.server as rserv
+import osmium.replication.utils as rutil
 import osmium.replication
 import tempfile
 import datetime
@@ -243,3 +244,16 @@ def test_get_newest_change_from_file():
         assert_equals(val, mkdate(2018, 10, 29, 3, 56, 7))
     finally:
         os.remove(fn)
+
+def test_get_replication_header_empty():
+    data = [osmobj('N', id=1, version=1, changeset=63965061, uid=8369524,
+                   timestamp='2018-10-29T03:56:07Z', user='x')]
+    fn = create_osm_file(data)
+
+    try:
+        val = rutil.get_replication_header(fn)
+        assert_is_none(val.url)
+        assert_is_none(val.sequence)
+        assert_is_none(val.timestamp)
+    finally:
+        os.remove(fn)


=====================================
tools/pyosmium-get-changes
=====================================
@@ -164,11 +164,11 @@ def get_arg_parser(from_main=False):
     return parser
 
 
-if __name__ == '__main__':
+def main(args):
     logging.basicConfig(stream=sys.stderr,
                         format='%(levelname)s: %(message)s')
 
-    options = get_arg_parser(from_main=True).parse_args()
+    options = get_arg_parser(from_main=True).parse_args(args)
 
     log.setLevel(max(3 - options.loglevel, 0) * 10)
 
@@ -181,11 +181,11 @@ if __name__ == '__main__':
               Don't know with which change to start. One of the parameters
                 -I / -D / -O / -f
               needs to begiven."""))
-            exit(1)
+            return 1
 
-        with open(options.start_file, 'r') as f:
+        with open(options.seq_file, 'r') as f:
             seq = f.readline()
-            options.start = ReplicationStart_from_id(seq)
+            options.start = ReplicationStart.from_id(seq)
 
     if options.server_url is not None and options.start.source is not None:
         if options.server_url != options.start.source:
@@ -196,7 +196,7 @@ if __name__ == '__main__':
                 %s
               If you really mean to overwrite the URL, use --ignore-osmosis-headers."""
               % (options.server_url, options.start.source)))
-            exit(2)
+            return 2
     url = options.server_url \
             or options.start.source \
             or 'https://planet.osm.org/replication/minute/'
@@ -214,11 +214,11 @@ if __name__ == '__main__':
     startseq = options.start.get_sequence(svr)
     if startseq is None:
         log.error("Cannot read state file from server. Is the URL correct?")
-        exit(1)
+        return 1
 
     if options.outfile is None:
         write_end_sequence(options.seq_file, startseq)
-        exit(0)
+        return 0
 
     log.debug("Starting download at ID %d (max %d MB)" % (startseq, options.outsize))
     outhandler = WriteHandler(options.outfile)
@@ -232,6 +232,12 @@ if __name__ == '__main__':
         cookie_jar.save(options.cookie)
 
     if endseq is None:
-        exit(3)
+        return 3
 
     write_end_sequence(options.seq_file, endseq)
+
+    return 0
+
+
+if __name__ == '__main__':
+    exit(main(sys.argv[1:]))



View it on GitLab: https://salsa.debian.org/debian-gis-team/pyosmium/compare/2b4d08064898b45f2fd463fea90b74cef6deb892...1425d4da9c7beace6e684b7554dc450b8e87c72f

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/pyosmium/compare/2b4d08064898b45f2fd463fea90b74cef6deb892...1425d4da9c7beace6e684b7554dc450b8e87c72f
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20190125/39d3e3db/attachment-0001.html>


More information about the Pkg-grass-devel mailing list