[Git][debian-gis-team/python-osmapi][master] 5 commits: New upstream version 1.3.0
Bas Couwenberg
gitlab at salsa.debian.org
Mon Oct 5 04:46:49 BST 2020
Bas Couwenberg pushed to branch master at Debian GIS Project / python-osmapi
Commits:
4e87497e by Bas Couwenberg at 2020-10-05T05:38:16+02:00
New upstream version 1.3.0
- - - - -
6b99ed78 by Bas Couwenberg at 2020-10-05T05:38:17+02:00
Update upstream source from tag 'upstream/1.3.0'
Update to upstream version '1.3.0'
with Debian dir e88629182dd45ac66d41865f7a627a30f3192412
- - - - -
b12f6f88 by Bas Couwenberg at 2020-10-05T05:38:31+02:00
New upstream release.
- - - - -
ddbf13fd by Bas Couwenberg at 2020-10-05T05:40:11+02:00
Update lintian overrides.
- - - - -
5f778942 by Bas Couwenberg at 2020-10-05T05:40:24+02:00
Set distribution to unstable.
- - - - -
9 changed files:
- .gitignore
- CHANGELOG.md
- debian/changelog
- − debian/source/lintian-overrides
- osmapi/OsmApi.py
- osmapi/__init__.py
- tests/changeset_tests.py
- + tests/fixtures/passwordfile_colon.txt
- tests/helper_tests.py
Changes:
=====================================
.gitignore
=====================================
@@ -4,3 +4,4 @@ MANIFEST
*.egg-info
.coverage
.tox
+.pycache/*
=====================================
CHANGELOG.md
=====================================
@@ -4,6 +4,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p
## [Unreleased][unreleased]
+## 1.3.0 - 2020-10-05
+### Added
+- Add close() method to close the underlying http session (see issue #107)
+- Add context manager to automatically open and close the http session (see issue #107)
+
+### Fixed
+- Correctly parse password file (thanks [Julien Palard](https://github.com/JulienPalard), see pull request #106)
+
## 1.2.2 - 2018-11-05
### Fixed
- Update PyPI password for deployment
=====================================
debian/changelog
=====================================
@@ -1,10 +1,12 @@
-python-osmapi (1.2.2-4) UNRELEASED; urgency=medium
+python-osmapi (1.3.0-1) unstable; urgency=medium
+ * New upstream release.
* Bump Standards-Version to 4.5.0, no changes.
* Drop Name field from upstream metadata.
* Bump debhelper compat to 10.
+ * Update lintian overrides.
- -- Bas Couwenberg <sebastic at debian.org> Mon, 30 Sep 2019 19:54:08 +0200
+ -- Bas Couwenberg <sebastic at debian.org> Mon, 05 Oct 2020 05:40:14 +0200
python-osmapi (1.2.2-3) unstable; urgency=medium
=====================================
debian/source/lintian-overrides deleted
=====================================
@@ -1,3 +0,0 @@
-# Not worth the effort
-testsuite-autopkgtest-missing
-
=====================================
osmapi/OsmApi.py
=====================================
@@ -206,17 +206,19 @@ class OsmApi:
if username:
self._username = username
elif passwordfile:
- pass_line = open(passwordfile).readline()
+ with open(passwordfile) as f:
+ pass_line = f.readline()
self._username = pass_line.split(":")[0].strip()
# Get password
if password:
self._password = password
elif passwordfile:
- for line in open(passwordfile).readlines():
- line = line.strip().split(":")
- if line[0] == self._username:
- self._password = line[1]
+ with open(passwordfile) as f:
+ for line in f:
+ line = line.strip().split(":", 1)
+ if line[0] == self._username:
+ self._password = line[1]
# Changest informations
# auto create and close changesets
@@ -249,13 +251,26 @@ class OsmApi:
self._session = self._get_http_session()
def __del__(self):
+ self.close()
+
+ return None
+
+ def __enter__(self):
+ self._session = self._get_http_session()
+ return self
+
+ def __exit__(self, *args):
+ self.close()
+
+ def close(self):
try:
if self._changesetauto:
self._changesetautoflush(True)
except ResponseEmptyApiError:
pass
- return None
+ if self._session:
+ self._session.close()
##################################################
# Capabilities #
=====================================
osmapi/__init__.py
=====================================
@@ -1,5 +1,5 @@
from __future__ import (absolute_import, print_function, unicode_literals)
-__version__ = '1.2.2'
+__version__ = '1.3.0'
from .OsmApi import * # noqa
=====================================
tests/changeset_tests.py
=====================================
@@ -92,10 +92,10 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']),
xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n'
- b'<osm version="0.6" generator="osmapi/1.2.2">\n'
+ b'<osm version="0.6" generator="osmapi/1.3.0">\n'
b' <changeset visible="true">\n'
b' <tag k="test" v="foobar"/>\n'
- b' <tag k="created_by" v="osmapi/1.2.2"/>\n'
+ b' <tag k="created_by" v="osmapi/1.3.0"/>\n'
b' </changeset>\n'
b'</osm>\n'
)
@@ -125,7 +125,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']),
xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n'
- b'<osm version="0.6" generator="osmapi/1.2.2">\n'
+ b'<osm version="0.6" generator="osmapi/1.3.0">\n'
b' <changeset visible="true">\n'
b' <tag k="test" v="foobar"/>\n'
b' <tag k="created_by" v="MyTestOSMApp"/>\n'
@@ -163,10 +163,10 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']),
xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n'
- b'<osm version="0.6" generator="osmapi/1.2.2">\n'
+ b'<osm version="0.6" generator="osmapi/1.3.0">\n'
b' <changeset visible="true">\n'
b' <tag k="foobar" v="A new test changeset"/>\n'
- b' <tag k="created_by" v="osmapi/1.2.2"/>\n'
+ b' <tag k="created_by" v="osmapi/1.3.0"/>\n'
b' </changeset>\n'
b'</osm>\n'
)
@@ -190,7 +190,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']),
xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n'
- b'<osm version="0.6" generator="osmapi/1.2.2">\n'
+ b'<osm version="0.6" generator="osmapi/1.3.0">\n'
b' <changeset visible="true">\n'
b' <tag k="foobar" v="A new test changeset"/>\n'
b' <tag k="created_by" v="CoolTestApp"/>\n'
@@ -276,7 +276,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']),
xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n'
- b'<osmChange version="0.6" generator="osmapi/1.2.2">\n'
+ b'<osmChange version="0.6" generator="osmapi/1.3.0">\n'
b'<create>\n'
b' <node lat="47.123" lon="8.555" visible="true" '
b'changeset="4444">\n'
@@ -350,7 +350,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']),
xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n'
- b'<osmChange version="0.6" generator="osmapi/1.2.2">\n'
+ b'<osmChange version="0.6" generator="osmapi/1.3.0">\n'
b'<modify>\n'
b' <way id="4294967296" version="2" visible="true" '
b'changeset="4444">\n'
@@ -434,7 +434,7 @@ class TestOsmApiChangeset(osmapi_tests.TestOsmApi):
xmltosorteddict(kwargs['data']),
xmltosorteddict(
b'<?xml version="1.0" encoding="UTF-8"?>\n'
- b'<osmChange version="0.6" generator="osmapi/1.2.2">\n'
+ b'<osmChange version="0.6" generator="osmapi/1.3.0">\n'
b'<delete>\n'
b' <relation id="676" version="2" visible="true" '
b'changeset="4444">\n'
=====================================
tests/fixtures/passwordfile_colon.txt
=====================================
@@ -0,0 +1,2 @@
+testosm:testpass
+testuser:test:userpass
=====================================
tests/helper_tests.py
=====================================
@@ -23,6 +23,7 @@ class TestOsmApiHelper(osmapi_tests.TestOsmApi):
mock_response.reason = "test reason"
mock_response.content = 'test response'
self.api._session.request = mock.Mock(return_value=mock_response)
+ self.api._session.close = mock.Mock()
self.api._username = 'testuser'
self.api._password = 'testpassword'
@@ -46,6 +47,25 @@ class TestOsmApiHelper(osmapi_tests.TestOsmApi):
self.assertEquals('testuser', my_api._username)
self.assertEquals('testuserpass', my_api._password)
+ def test_passwordfile_with_colon(self):
+ path = os.path.join(
+ __location__,
+ 'fixtures',
+ 'passwordfile_colon.txt'
+ )
+ my_api = osmapi.OsmApi(username='testuser', passwordfile=path)
+ self.assertEquals('testuser', my_api._username)
+ self.assertEquals('test:userpass', my_api._password)
+
+ def test_close_call(self):
+ self.api.close()
+ self.assertEquals(self.api._session.close.call_count, 1)
+
+ def test_close_context_manager(self):
+ with osmapi.OsmApi() as my_api:
+ my_api._session.close = mock.Mock()
+ self.assertEquals(my_api._session.close.call_count, 1)
+
def test_http_request_get(self):
response = self.api._http_request(
'GET',
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-osmapi/-/compare/395bfd9312aeb9df144f2e431bbb597a1c35d9a2...5f778942d780f65e75d619a64d5931f040e80243
--
View it on GitLab: https://salsa.debian.org/debian-gis-team/python-osmapi/-/compare/395bfd9312aeb9df144f2e431bbb597a1c35d9a2...5f778942d780f65e75d619a64d5931f040e80243
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/20201005/9245c046/attachment-0001.html>
More information about the Pkg-grass-devel
mailing list