Skip to content
GitLab
Explore
Sign in
Register
Commits on Source (4)
New upstream version 2.15.1
· 49efdd8c
Bas Couwenberg
authored
Jan 25, 2019
49efdd8c
Merge tag 'upstream/2.15.1'
· ff18570f
Bas Couwenberg
authored
Jan 25, 2019
Upstream version 2.15.1
ff18570f
New upstream release.
· 25d35333
Bas Couwenberg
authored
Jan 25, 2019
25d35333
Set distribution to unstable.
· 1425d4da
Bas Couwenberg
authored
Jan 25, 2019
1425d4da
Show whitespace changes
Inline
Side-by-side
.travis.yml
View file @
1425d4da
...
...
@@ -23,13 +23,9 @@ matrix:
compiler
:
gcc
env
:
USE_PYTHON_VERSION=3
-
os
:
osx
osx_image
:
xcode
8.3
osx_image
:
xcode
7
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
View file @
1425d4da
...
...
@@ -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
View file @
1425d4da
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@debian.org>
Tue
, 25
Dec
201
8 23:03:57
+0100
-- Bas Couwenberg <sebastic@debian.org>
Fri
, 25
Jan
201
9 06:59:10
+0100
pyosmium (2.15.0-1) unstable; urgency=medium
...
...
src/osmium/replication/utils.py
View file @
1425d4da
...
...
@@ -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
View file @
1425d4da
...
...
@@ -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
View file @
1425d4da
...
...
@@ -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 → 100644
View file @
1425d4da
"""
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
View file @
1425d4da
...
...
@@ -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
View file @
1425d4da
...
...
@@ -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
.
s
tart
_file
,
'
r
'
)
as
f
:
with
open
(
options
.
s
eq
_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
:]))