Skip to content

Commit 820b71f

Browse files
authored
Merge pull request #26 from docentYT/development
v3.0.0
2 parents b617b30 + 6598662 commit 820b71f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+16596
-1251
lines changed

.coveragerc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@
22
source = src/osm_easy_api/*
33

44
[run]
5-
omit = tests/*
5+
omit =
6+
tests/*
7+
*/__init__.py
8+
9+
[report]
10+
exclude_lines =
11+
pragma: no cover
12+
# This covers both typing.TYPE_CHECKING and plain TYPE_CHECKING, with any amount of whitespace
13+
if\s+(typing\.)?TYPE_CHECKING:

API.txt

Lines changed: 0 additions & 74 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,60 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [2.2.0]
8+
## [3.0.0] - 2024-03-19
9+
### Added
10+
- Support for `oAuth2`: `access_token` parameter in `Api` class constructor.
11+
- `Unauthorized` exception. (No access token.)
12+
- `Forbidden` exception. (The access token does not support the needed scope or you must be a moderator.)
13+
- `gpx.create()` endpoint.
14+
- `GpxFile` data class.
15+
- `Visibility` enum.
16+
- `gpx.update()` endpoint.
17+
- `gpx.delete()` endpoint.
18+
- `gpx.get_details()` endpoint.
19+
- `gpx.get_file()` endpoint.
20+
- `gpx.list_details()` endpoint.
21+
- `order` parameter in `changeset.get_query()`.
22+
23+
### Fixed
24+
- Types in `elements` endpoint.
25+
- Missing documentation.
26+
- `misc.get_map_in_bbox()` endpoint should not yield `string`.
27+
28+
### Changed
29+
- The way http errors are handled.
30+
- In `elements.get()` endpoint the `element` parameter has been renamed to `element_type`.
31+
- In `elements.history()` endpoint the `element` parameter has been renamed to `element_type`.
32+
- In `elements.version()` endpoint the `element` parameter has been renamed to `element_type`.
33+
- In `elements.getQuery()` endpoint the `element` parameter has been renamed to `element_type`.
34+
- In `elements.relations()` endpoint the `element` parameter has been renamed to `element_type`.
35+
- In `elements.full()` endpoint the `element` parameter has been renamed to `element_type`.
36+
- Type of `user_id` parameter in `changeset.get_query()` was changed from `str` to `int`.
37+
- `OsmChange_parser_generator()` and `OsmChange_parser()` from `diff` module are now 'private' functions. Use `Diff.get()` instead.
38+
- `notes.search()` endpoint throws `LimitsExceeded` exception instead of `ValueError`.
39+
- `page_number` paremeter in `gpx.get()` has now default value 0.
40+
- Now classes are imported from individual modules - not from the main library. See examples in the `README.md`.
41+
- `gpx.get()` renamed to `gpx.get_gps_points()`
42+
43+
### Removed
44+
- Support for `HTTP Basic authentication`: `username` and `password` parameters in `Api` class constructor.
45+
- Most `# type: ignore`.
46+
- `NotAModerator` exception. It is now replaced by `Forbidden` exception.
47+
48+
## [2.2.0] - 2024-02-23
949
### Added
1050
- Exception for `410` status code in notes endpoint.
1151

12-
## [2.1.1]
52+
## [2.1.1] - 2024-01-04
1353
### Fixed
1454
- Percent-encoding was not applied on texts entered by the user. [#22](https://github.com/docentYT/osm_easy_api/issues/22)
1555

16-
## [2.1.0]
56+
## [2.1.0] - 2023-09-06
1757
### Added
1858
- `TooManyRequests` exception.
1959
- Support for `429` status code in `api.changeset.discussion.comment()`.
2060

21-
## [2.0.0]
61+
## [2.0.0] - 2023-08-29
2262
### Added
2363
- Missing status code handling in `notes.get()`.
2464
- Support for hide note endpoint.
@@ -35,27 +75,27 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3575
- `EmptyResult` api exception, which was used in endpoints `notes`, `user` and `changeset`. From now on when the results are empty an empty list will be returned.
3676
- Unused imports.
3777

38-
## [1.1.1]
78+
## [1.1.1] - 2023-08-03
3979
### Fixed
4080
- Corrected character when adding parameters in endpoint `api.notes.get_bbox()` (from `?` to `&`).
4181
- Fixed the `limit` parameter restrictions in `api.notes.get_bbox()` documentation.
4282

43-
## [1.1.0]
83+
## [1.1.0] - 2023-08-28
4484
### Added
4585
- `limit` parameter for `api.changeset.get_query()` endpoint.
4686

4787
### Fixed
4888
- Corrected character when adding parameters in endpoint `api.changeset.get_query()` (from `;` to `&`).
4989

50-
## [1.0.2]
90+
## [1.0.2] - 2023-07-26
5191
### Fixed
5292
- Auth problems in API when using characters unsupported by latin-1 codec.
5393

54-
## [1.0.1]
94+
## [1.0.1] - 2023-07-24
5595
### Fixed
5696
- `api.notes.create()` created only anonymous notes.
5797

58-
## [1.0.0]
98+
## [1.0.0] - 2023-06-18
5999
### Added
60100
- `to_xml()` method in `OsmChange`.
61101
- `upload()` method in `changeset` `endpoint` has new optional arguments.
@@ -65,7 +105,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
65105
### Changed
66106
- Private `_to_xml()` method in `OsmChange` is now static.
67107

68-
## [0.4.2]
108+
## [0.4.2] - 2023-06-11
69109

70110
### Changed
71111
- Order of elements in xml generated by `Way._to_xml()`. First tags, then nodes.
@@ -75,11 +115,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
75115
- Deleted disused variable in `Node._to_xml()`.
76116
- Fixed incorrect relation parsing of data recived by `full` endpoint.
77117

78-
## [0.4.1]
118+
## [0.4.1] - 2023-05-23
79119
### Changed
80120
- Updated `requests` from `2.28.1` to `2.31.0`.
81121

82-
## [0.4.0]
122+
## [0.4.0] - 2023-05-03
83123
### Added
84124
- `to_dict()` method and `from_dict()` class method to `Note`.
85125
- `to_dict()` method and `from_dict()` class method to `Comment`.

README.md

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,13 @@
1515

1616
<p align="center"><a href="https://www.openstreetmap.org/user/kwiatek_123">Me on OpenStreetMap</a></p>
1717

18-
Python package for parsing osm diffs and communicating with the OpenStreetMap api. See API.txt for list of supported endpoints.
18+
> Python package for parsing osm diffs and communicating with the OpenStreetMap api.
1919
20-
## What's the point of this package?
20+
### What's the point of this package?
2121

2222
This package was created to provide an easy way to create automated scripts and programs that use diff and/or osm api. The main advantage is the classes (data_classes) that provide data of elements (node, way, relation, OsmChange, etc.) in a readable way and the possibility to use them in diff and api without worrying about missing data or dictionaries. You can easily find nodes in diff, add a tag to them and send the corrected version to osm.
2323

24-
## What next?
25-
The plan is to optimise and improve the code, add support for gpx traces, rss support and overpass api.
26-
27-
# Installation
24+
## Installation
2825

2926
Works on python >= 3.10. (Due to new typehints standard)
3027

@@ -33,21 +30,26 @@ Install `osm_easy_api` from [PyPi](https://pypi.org/project/osm-easy-api/):
3330
pip install osm_easy_api
3431
```
3532

36-
# Documentation
33+
## Documentation
3734

3835
You can view documentation on [github-pages](https://docentyt.github.io/osm_easy_api/osm_easy_api.html).
3936

4037
Documentation is build using [pdoc](https://pdoc.dev).
4138
To run docs on your machine use preferred command: `pdoc --docformat google --no-show-source osm_easy_api !osm_easy_api.utils`.
4239

43-
# Examples
40+
## OAuth 2.0
41+
Due to the deprecation of HTTP Basic Auth you need an access token to use most api endpoints. To obtain an access token we recommend using https://tools.interactivemaps.xyz/token/.
42+
43+
44+
## Examples
4445

45-
## DIFF
46+
### DIFF
4647

47-
### Print trees
48+
#### Print trees
4849

4950
```py
50-
from osm_easy_api import Node, Diff, Frequency
51+
from osm_easy_api.diff import Diff, Frequency
52+
from osm_easy_api.data_classes import Node
5153

5254
# Download diff from last hour.
5355
d = Diff(Frequency.HOUR)
@@ -61,10 +63,11 @@ for action, element in gen:
6163
print(action, element.id)
6264
```
6365

64-
### Print incorrectly tagged single tress
66+
#### Print incorrectly tagged single tress
6567

6668
```py
67-
from osm_easy_api import Diff, Frequency, Action, Node
69+
from osm_easy_api.diff import Diff, Frequency
70+
from osm_easy_api.data_classes import Action, Node
6871

6972
d = Diff(Frequency.DAY)
7073

@@ -81,14 +84,15 @@ Example output:
8184
Node(id = 10208486717, visible = None, version = 1, changeset_id = 129216075, timestamp = 2022-11-22T00:16:44Z, user_id = 17471721, tags = {'leaf_type': 'broadleaved', 'natural': 'wood'}, latitude = 48.6522286, longitude = 12.583809, )
8285
```
8386

84-
## API
87+
### API
8588

86-
### Add missing wikidata tag
89+
#### Add missing wikidata tag
8790

8891
```py
89-
from osm_easy_api import Api, Node, Tags
92+
from osm_easy_api.api import Api
93+
from osm_easy_api.data_classes import Node, Tags
9094

91-
api = Api("https://master.apis.dev.openstreetmap.org", LOGIN, PASSWORD)
95+
api = Api("https://master.apis.dev.openstreetmap.org", ACCESS_TOKEN)
9296

9397
node = api.elements.get(Node, 4296460336) # We are getting Node with id 4296460336 where we want to add a new tag to
9498
node.tags.add("wikidata", "Qexample") # Add a new tag to node.
@@ -98,11 +102,11 @@ api.elements.update(node, my_changeset) # Send new version of a node to osm
98102
api.changeset.close(my_changeset) # Close changeset.
99103
```
100104

101-
# Notes
105+
## Notes
102106

103107
Note that the following codes do the same thing
104108
```py
105-
from osm_easy_api import Diff, Frequency
109+
from osm_easy_api.diff import Diff, Frequency
106110

107111
d = Diff(Frequency.DAY)
108112

@@ -113,7 +117,8 @@ for action, element in gen:
113117
print(element)
114118
```
115119
```py
116-
from osm_easy_api import Diff, Frequency, Tags
120+
from osm_easy_api.diff import Diff, Frequency
121+
from osm_easy_api.data_classes import Tags
117122

118123
d = Diff(Frequency.DAY)
119124

@@ -126,7 +131,8 @@ but the second seems to be faster.
126131

127132
Also you can use OsmChange object if you don't want to use generator
128133
```py
129-
from osm_easy_api import Diff, Frequency, Action, Node
134+
from osm_easy_api.diff import Diff, Frequency
135+
from osm_easy_api.data_classes import Action, Node
130136

131137
d = Diff(Frequency.MINUTE)
132138

@@ -138,7 +144,7 @@ for node in deleted_nodes:
138144
```
139145
but it can consume large amounts of ram and use of this method is not recommended for large diff's.
140146

141-
# Tests
147+
## Tests
142148

143149
You will need to install `test-requirements.txt`. You can use tox.
144150
To run tests manually use `python -m unittest discover`.

coverage-badge.svg

Lines changed: 3 additions & 3 deletions
Loading

src/osm_easy_api/__init__.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
VERSION = "2.2.0"
1+
"""Python package for parsing osm diffs and communicating with the OpenStreetMap api."""
2+
VERSION = "3.0.0"
23

3-
from .data_classes import *
4-
from .diff import Diff, Frequency
5-
6-
from .api import Api
4+
from . import data_classes
5+
from . import diff
6+
from . import api

src/osm_easy_api/api/_URLs.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,13 @@ def __init__(self, base_url: str):
4747
}
4848

4949
self.gpx: Dict[str, str] = {
50-
"get": six_url + "/trackpoints?bbox={left},{bottom},{right},{top}&page={page_number}"
50+
"get_gps_points": six_url + "/trackpoints?bbox={left},{bottom},{right},{top}&page={page_number}",
51+
"create": six_url + "/gpx/create",
52+
"update": six_url + "/gpx/{id}",
53+
"delete": six_url + "/gpx/{id}",
54+
"details": six_url + "/gpx/{id}/details",
55+
"get_file": six_url + "/gpx/{id}/data",
56+
"list": six_url + "/user/gpx_files"
5157
}
5258

5359
self.user: Dict[str, str] = {

0 commit comments

Comments
 (0)