Skip to content
Commits on Source (2)
...@@ -2,18 +2,22 @@ language: python ...@@ -2,18 +2,22 @@ language: python
python: python:
- '2.7' - '2.7'
- '3.3'
- '3.4' - '3.4'
- '3.5' - '3.5'
- '3.6' - '3.6'
matrix:
include:
- python: '3.7'
dist: xenial # required for Python 3.7 (travis-ci/travis-ci#9069)
sudo: required # required for Python 3.7 (travis-ci/travis-ci#9069)
before_install: before_install:
- sudo apt-get update -qq - sudo apt-get update -qq
- sudo apt-get install -qq pandoc - sudo apt-get install -qq pandoc
install: install:
- pip install -r requirements.txt - pip install -r requirements.txt -r test-requirements.txt
- pip install -r test-requirements.txt
- pip install . - pip install .
script: ./build.sh script: ./build.sh
...@@ -22,11 +26,12 @@ after_success: coveralls ...@@ -22,11 +26,12 @@ after_success: coveralls
deploy: deploy:
- provider: pypi - provider: pypi
twine_version: 1.12.1
user: odi user: odi
password: password:
secure: MU3ZQ4rcpsXo0xIYSWXBfaKTAPn1IrL7AEcH231sseFV1RVmdC96Sfmtc2llvD9Eoc0KJpdW0Vy50azNqAMJwXCt/q3gagfao1PTnAEbklU+g1s2PTqW401E95Qm6w192WzWk/q0dy3SJwxEQt023QR78K+nEcYaCdLWDHjR2hY= secure: MU3ZQ4rcpsXo0xIYSWXBfaKTAPn1IrL7AEcH231sseFV1RVmdC96Sfmtc2llvD9Eoc0KJpdW0Vy50azNqAMJwXCt/q3gagfao1PTnAEbklU+g1s2PTqW401E95Qm6w192WzWk/q0dy3SJwxEQt023QR78K+nEcYaCdLWDHjR2hY=
on: on:
tags: true tags: true
all_branches: true all_branches: true
python: 2.7 python: 3.7
repo: metaodi/osmapi repo: metaodi/osmapi
...@@ -4,6 +4,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p ...@@ -4,6 +4,21 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased][unreleased] ## [Unreleased][unreleased]
## 1.2.1 - 2018-11-05
### Fixed
- Deployment to PyPI with Travis
## 1.2.0 - 2018-11-05
### Added
- Support Python 3.7 (thanks a lot [cclauss](https://github.com/cclauss))
### Removed
- Python 3.3 is no longer supported (EOL)
### Changed
- Updated dependencies for Python 3.7
- Adapt README to use Python 3 syntax (thanks [cclauss](https://github.com/cclauss))
## 1.1.0 - 2017-10-11 ## 1.1.0 - 2017-10-11
### Added ### Added
- Raise new `XmlResponseInvalidError` if XML response from the OpenStreetMap API is invalid - Raise new `XmlResponseInvalidError` if XML response from the OpenStreetMap API is invalid
......
...@@ -4,7 +4,6 @@ osmapi ...@@ -4,7 +4,6 @@ osmapi
[![Build](https://img.shields.io/travis/metaodi/osmapi/develop.svg)](https://travis-ci.org/metaodi/osmapi) [![Build](https://img.shields.io/travis/metaodi/osmapi/develop.svg)](https://travis-ci.org/metaodi/osmapi)
[![Coverage](https://img.shields.io/coveralls/metaodi/osmapi/develop.svg)](https://coveralls.io/r/metaodi/osmapi?branch=develop) [![Coverage](https://img.shields.io/coveralls/metaodi/osmapi/develop.svg)](https://coveralls.io/r/metaodi/osmapi?branch=develop)
[![Version](https://img.shields.io/pypi/v/osmapi.svg)](https://pypi.python.org/pypi/osmapi/) [![Version](https://img.shields.io/pypi/v/osmapi.svg)](https://pypi.python.org/pypi/osmapi/)
[![Downloads](https://img.shields.io/pypi/dm/osmapi.svg)](https://pypi.python.org/pypi/osmapi/)
[![License](https://img.shields.io/pypi/l/osmapi.svg)](https://github.com/metaodi/osmapi/blob/master/LICENSE.txt) [![License](https://img.shields.io/pypi/l/osmapi.svg)](https://github.com/metaodi/osmapi/blob/master/LICENSE.txt)
Python wrapper for the OSM API Python wrapper for the OSM API
...@@ -35,7 +34,7 @@ To test this library, please create an account on the [development server of Ope ...@@ -35,7 +34,7 @@ To test this library, please create an account on the [development server of Ope
```python ```python
import osmapi import osmapi
api = osmapi.OsmApi() api = osmapi.OsmApi()
print api.NodeGet(123) print(api.NodeGet(123))
# {u'changeset': 532907, u'uid': 14298, # {u'changeset': 532907, u'uid': 14298,
# u'timestamp': u'2007-09-29T09:19:17Z', # u'timestamp': u'2007-09-29T09:19:17Z',
# u'lon': 10.790009299999999, u'visible': True, # u'lon': 10.790009299999999, u'visible': True,
...@@ -60,7 +59,7 @@ Note: Each line in the password file should have the format _user:password_ ...@@ -60,7 +59,7 @@ Note: Each line in the password file should have the format _user:password_
import osmapi import osmapi
api = osmapi.OsmApi(api="https://api06.dev.openstreetmap.org", username = u"metaodi", password = u"*******") api = osmapi.OsmApi(api="https://api06.dev.openstreetmap.org", username = u"metaodi", password = u"*******")
api.ChangesetCreate({u"comment": u"My first test"}) api.ChangesetCreate({u"comment": u"My first test"})
print api.NodeCreate({u"lon":1, u"lat":1, u"tag": {}}) print(api.NodeCreate({u"lon":1, u"lat":1, u"tag": {}}))
# {u'changeset': 532907, u'lon': 1, u'version': 1, u'lat': 1, u'tag': {}, u'id': 164684} # {u'changeset': 532907, u'lon': 1, u'version': 1, u'lat': 1, u'tag': {}, u'id': 164684}
api.ChangesetClose() api.ChangesetClose()
``` ```
...@@ -88,7 +87,7 @@ To run the tests use the following command: ...@@ -88,7 +87,7 @@ To run the tests use the following command:
nosetests --verbose nosetests --verbose
By using tox you can even run the tests against different versions of python (2.7, 3.3, 3.4, 3.5 and 3.6): By using tox you can even run the tests against different versions of python (2.7, 3.4, 3.5, 3.6 and 3.7):
tox tox
......
...@@ -213,10 +213,10 @@ class OsmApi: ...@@ -213,10 +213,10 @@ class OsmApi:
if password: if password:
self._password = password self._password = password
elif passwordfile: elif passwordfile:
for l in open(passwordfile).readlines(): for line in open(passwordfile).readlines():
l = l.strip().split(":") line = line.strip().split(":")
if l[0] == self._username: if line[0] == self._username:
self._password = l[1] self._password = line[1]
# Changest informations # Changest informations
# auto create and close changesets # auto create and close changesets
...@@ -308,7 +308,7 @@ class OsmApi: ...@@ -308,7 +308,7 @@ class OsmApi:
for k, v in elem.attributes.items(): for k, v in elem.attributes.items():
try: try:
result[elem.nodeName][k] = float(v) result[elem.nodeName][k] = float(v)
except: except Exception:
result[elem.nodeName][k] = v result[elem.nodeName][k] = v
return result return result
...@@ -2223,10 +2223,10 @@ class OsmApi: ...@@ -2223,10 +2223,10 @@ class OsmApi:
result = DateString result = DateString
try: try:
result = datetime.strptime(DateString, "%Y-%m-%d %H:%M:%S UTC") result = datetime.strptime(DateString, "%Y-%m-%d %H:%M:%S UTC")
except: except Exception:
try: try:
result = datetime.strptime(DateString, "%Y-%m-%dT%H:%M:%SZ") result = datetime.strptime(DateString, "%Y-%m-%dT%H:%M:%SZ")
except: except Exception:
pass pass
return result return result
...@@ -2296,5 +2296,5 @@ class OsmApi: ...@@ -2296,5 +2296,5 @@ class OsmApi:
try: try:
elem = DomElement.getElementsByTagName(tag)[0] elem = DomElement.getElementsByTagName(tag)[0]
return elem.firstChild.nodeValue return elem.firstChild.nodeValue
except: except Exception:
return None return None
from __future__ import (absolute_import, print_function, unicode_literals) from __future__ import (absolute_import, print_function, unicode_literals)
__version__ = '1.1.0' __version__ = '1.2.1'
from .OsmApi import * # noqa from .OsmApi import * # noqa
# This file lists the dependencies of this extension. # This file lists the dependencies of this extension.
# Install with a command like: pip install -r pip-requirements.txt # Install with a command like: pip install -r pip-requirements.txt
pypandoc==0.7.0 pdoc==0.3.2
Unidecode==0.04.14 Pygments==2.2.0
pdoc==0.3.1 pypandoc==1.4
Pygments==1.6 requests==2.20.0
requests==2.8.0 Unidecode==1.0.22
...@@ -48,5 +48,6 @@ setup( ...@@ -48,5 +48,6 @@ setup(
'Programming Language :: Python :: 3.4', 'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: 3.5',
'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
], ],
) )
# This file lists the dependencies of this extension. # This file lists the dependencies of this extension.
# Install with a command like: pip install -r pip-requirements.txt # Install with a command like: pip install -r pip-requirements.txt
flake8==3.0.4; python_version >= '2.7' coverage==4.5.1
flake8==2.1.0; python_version == '2.6' coveralls==1.5.1
nose==1.3.0 flake8==3.6.0
tox==2.8.1 mock==2.0.0
coverage==3.7.1 nose==1.3.7
coveralls==0.4.1 tox==3.5.3
mock==1.0.1 virtualenv==16.1.0
xmltodict==0.9.0 xmltodict==0.11.0
virtualenv==15.1.0
...@@ -6,7 +6,7 @@ import xmltodict ...@@ -6,7 +6,7 @@ import xmltodict
import datetime import datetime
try: try:
import urlparse import urlparse
except: except Exception:
import urllib import urllib
urlparse = urllib.parse urlparse = urllib.parse
...@@ -23,7 +23,7 @@ def recursive_sort(col): # noqa ...@@ -23,7 +23,7 @@ def recursive_sort(col): # noqa
col = sorted(col) col = sorted(col)
except TypeError: # in Python 3.x: lists of dicts are not sortable except TypeError: # in Python 3.x: lists of dicts are not sortable
col = sorted(col, key=lambda k: hash(frozenset(k.items()))) col = sorted(col, key=lambda k: hash(frozenset(k.items())))
except: except Exception:
pass pass
for idx, elem in enumerate(col): for idx, elem in enumerate(col):
...@@ -92,10 +92,10 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi): ...@@ -92,10 +92,10 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']), xmltosorteddict(kwargs['data']),
xmltosorteddict( xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n' b'<?xml version="1.0" encoding="UTF-8"?>\n'
b'<osm version="0.6" generator="osmapi/1.1.0">\n' b'<osm version="0.6" generator="osmapi/1.2.1">\n'
b' <changeset visible="true">\n' b' <changeset visible="true">\n'
b' <tag k="test" v="foobar"/>\n' b' <tag k="test" v="foobar"/>\n'
b' <tag k="created_by" v="osmapi/1.1.0"/>\n' b' <tag k="created_by" v="osmapi/1.2.1"/>\n'
b' </changeset>\n' b' </changeset>\n'
b'</osm>\n' b'</osm>\n'
) )
...@@ -125,7 +125,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi): ...@@ -125,7 +125,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']), xmltosorteddict(kwargs['data']),
xmltosorteddict( xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n' b'<?xml version="1.0" encoding="UTF-8"?>\n'
b'<osm version="0.6" generator="osmapi/1.1.0">\n' b'<osm version="0.6" generator="osmapi/1.2.1">\n'
b' <changeset visible="true">\n' b' <changeset visible="true">\n'
b' <tag k="test" v="foobar"/>\n' b' <tag k="test" v="foobar"/>\n'
b' <tag k="created_by" v="MyTestOSMApp"/>\n' b' <tag k="created_by" v="MyTestOSMApp"/>\n'
...@@ -163,10 +163,10 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi): ...@@ -163,10 +163,10 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']), xmltosorteddict(kwargs['data']),
xmltosorteddict( xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n' b'<?xml version="1.0" encoding="UTF-8"?>\n'
b'<osm version="0.6" generator="osmapi/1.1.0">\n' b'<osm version="0.6" generator="osmapi/1.2.1">\n'
b' <changeset visible="true">\n' b' <changeset visible="true">\n'
b' <tag k="foobar" v="A new test changeset"/>\n' b' <tag k="foobar" v="A new test changeset"/>\n'
b' <tag k="created_by" v="osmapi/1.1.0"/>\n' b' <tag k="created_by" v="osmapi/1.2.1"/>\n'
b' </changeset>\n' b' </changeset>\n'
b'</osm>\n' b'</osm>\n'
) )
...@@ -190,7 +190,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi): ...@@ -190,7 +190,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']), xmltosorteddict(kwargs['data']),
xmltosorteddict( xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n' b'<?xml version="1.0" encoding="UTF-8"?>\n'
b'<osm version="0.6" generator="osmapi/1.1.0">\n' b'<osm version="0.6" generator="osmapi/1.2.1">\n'
b' <changeset visible="true">\n' b' <changeset visible="true">\n'
b' <tag k="foobar" v="A new test changeset"/>\n' b' <tag k="foobar" v="A new test changeset"/>\n'
b' <tag k="created_by" v="CoolTestApp"/>\n' b' <tag k="created_by" v="CoolTestApp"/>\n'
...@@ -276,7 +276,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi): ...@@ -276,7 +276,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']), xmltosorteddict(kwargs['data']),
xmltosorteddict( xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n' b'<?xml version="1.0" encoding="UTF-8"?>\n'
b'<osmChange version="0.6" generator="osmapi/1.1.0">\n' b'<osmChange version="0.6" generator="osmapi/1.2.1">\n'
b'<create>\n' b'<create>\n'
b' <node lat="47.123" lon="8.555" visible="true" ' b' <node lat="47.123" lon="8.555" visible="true" '
b'changeset="4444">\n' b'changeset="4444">\n'
...@@ -350,7 +350,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi): ...@@ -350,7 +350,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']), xmltosorteddict(kwargs['data']),
xmltosorteddict( xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n' b'<?xml version="1.0" encoding="UTF-8"?>\n'
b'<osmChange version="0.6" generator="osmapi/1.1.0">\n' b'<osmChange version="0.6" generator="osmapi/1.2.1">\n'
b'<modify>\n' b'<modify>\n'
b' <way id="4294967296" version="2" visible="true" ' b' <way id="4294967296" version="2" visible="true" '
b'changeset="4444">\n' b'changeset="4444">\n'
...@@ -434,7 +434,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi): ...@@ -434,7 +434,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']), xmltosorteddict(kwargs['data']),
xmltosorteddict( xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n' b'<?xml version="1.0" encoding="UTF-8"?>\n'
b'<osmChange version="0.6" generator="osmapi/1.1.0">\n' b'<osmChange version="0.6" generator="osmapi/1.2.1">\n'
b'<delete>\n' b'<delete>\n'
b' <relation id="676" version="2" visible="true" ' b' <relation id="676" version="2" visible="true" '
b'changeset="4444">\n' b'changeset="4444">\n'
......
...@@ -64,7 +64,7 @@ class TestOsmApi(unittest.TestCase): ...@@ -64,7 +64,7 @@ class TestOsmApi(unittest.TestCase):
try: try:
with open(path) as file: with open(path) as file:
return_values.append(file.read()) return_values.append(file.read())
except: except Exception:
pass pass
return return_values return return_values
......
[tox] [tox]
envlist = py27,py33,py34,py35,py36 envlist = py27,py34,py35,py36,py37
[testenv] [testenv]
commands=nosetests --verbose commands=nosetests --verbose
deps = deps =
......