NeoBase 0.34.28__tar.gz → 0.35.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. {neobase-0.34.28/src/NeoBase.egg-info → neobase-0.35.1}/PKG-INFO +3 -3
  2. {neobase-0.34.28 → neobase-0.35.1}/README.rst +1 -1
  3. {neobase-0.34.28 → neobase-0.35.1}/pyproject.toml +8 -8
  4. {neobase-0.34.28 → neobase-0.35.1/src/NeoBase.egg-info}/PKG-INFO +3 -3
  5. {neobase-0.34.28 → neobase-0.35.1}/src/NeoBase.egg-info/scm_file_list.json +14 -14
  6. neobase-0.35.1/src/NeoBase.egg-info/scm_version.json +8 -0
  7. neobase-0.35.1/src/neobase/__init__.py +4 -0
  8. {neobase-0.34.28 → neobase-0.35.1}/src/neobase/neobase.py +41 -31
  9. {neobase-0.34.28 → neobase-0.35.1}/src/neobase/optd_por_public.csv +211 -211
  10. {neobase-0.34.28 → neobase-0.35.1}/tox.ini +2 -2
  11. neobase-0.34.28/src/NeoBase.egg-info/scm_version.json +0 -8
  12. neobase-0.34.28/src/neobase/__init__.py +0 -4
  13. {neobase-0.34.28 → neobase-0.35.1}/LICENSE +0 -0
  14. {neobase-0.34.28 → neobase-0.35.1}/MANIFEST.in +0 -0
  15. {neobase-0.34.28 → neobase-0.35.1}/_config.yml +0 -0
  16. {neobase-0.34.28 → neobase-0.35.1}/doc/Makefile +0 -0
  17. {neobase-0.34.28 → neobase-0.35.1}/doc/conf.py +0 -0
  18. {neobase-0.34.28 → neobase-0.35.1}/doc/index.rst +0 -0
  19. {neobase-0.34.28 → neobase-0.35.1}/doc/make.bat +0 -0
  20. {neobase-0.34.28 → neobase-0.35.1}/setup.cfg +0 -0
  21. {neobase-0.34.28 → neobase-0.35.1}/src/NeoBase.egg-info/SOURCES.txt +0 -0
  22. {neobase-0.34.28 → neobase-0.35.1}/src/NeoBase.egg-info/dependency_links.txt +0 -0
  23. {neobase-0.34.28 → neobase-0.35.1}/src/NeoBase.egg-info/entry_points.txt +0 -0
  24. {neobase-0.34.28 → neobase-0.35.1}/src/NeoBase.egg-info/top_level.txt +0 -0
  25. {neobase-0.34.28 → neobase-0.35.1}/src/neobase/__main__.py +0 -0
  26. {neobase-0.34.28 → neobase-0.35.1}/src/neobase/version.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NeoBase
3
- Version: 0.34.28
3
+ Version: 0.35.1
4
4
  Summary: Python library to manipulate OpenTravelData
5
5
  Author-email: Alex Prengère <alex.prengere@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/alexprengere/neobase
@@ -9,7 +9,7 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3 :: Only
10
10
  Classifier: Programming Language :: Python :: Implementation :: CPython
11
11
  Classifier: Programming Language :: Python :: Implementation :: PyPy
12
- Requires-Python: >=3.9
12
+ Requires-Python: >=3.11
13
13
  Description-Content-Type: text/x-rst
14
14
  License-File: LICENSE
15
15
  Dynamic: license-file
@@ -30,7 +30,7 @@ Minimalist `GeoBases <https://github.com/opentraveldata/geobases/>`__
30
30
  implementation:
31
31
 
32
32
  - no dependencies
33
- - compatible with Python 3.9+, CPython and PyPy
33
+ - compatible with Python 3.11+, CPython and PyPy
34
34
  - one data source:
35
35
  `opentraveldata <https://github.com/opentraveldata/opentraveldata>`__
36
36
  - one Python module for easier distribution on clusters (like Hadoop)
@@ -14,7 +14,7 @@ Minimalist `GeoBases <https://github.com/opentraveldata/geobases/>`__
14
14
  implementation:
15
15
 
16
16
  - no dependencies
17
- - compatible with Python 3.9+, CPython and PyPy
17
+ - compatible with Python 3.11+, CPython and PyPy
18
18
  - one data source:
19
19
  `opentraveldata <https://github.com/opentraveldata/opentraveldata>`__
20
20
  - one Python module for easier distribution on clusters (like Hadoop)
@@ -10,7 +10,7 @@ readme = "README.rst"
10
10
  authors = [
11
11
  {name = "Alex Prengère", email = "alex.prengere@gmail.com"},
12
12
  ]
13
- requires-python = ">=3.9"
13
+ requires-python = ">=3.11"
14
14
  license-files = ["LICENSE"]
15
15
  classifiers = [
16
16
  "Development Status :: 5 - Production/Stable",
@@ -36,7 +36,7 @@ include = ["neobase*",]
36
36
  [dependency-groups]
37
37
  test = [
38
38
  "pytz>=2024",
39
- "pytest>=8.0",
39
+ "pytest>=9.0",
40
40
  "pytest-cov>=5.0",
41
41
  "pytest-benchmark>=5.1",
42
42
  ]
@@ -89,7 +89,7 @@ show_contexts = true
89
89
 
90
90
  [tool.ruff]
91
91
  line-length = 100
92
- target-version = "py39"
92
+ target-version = "py311"
93
93
  extend-exclude = ["doc"]
94
94
 
95
95
  [tool.ruff.lint]
@@ -119,14 +119,14 @@ select = [
119
119
  "RUF", # Ruff-specific rules
120
120
  ]
121
121
  ignore = [
122
- "E402", # module-import-not-at-top-of-file
123
- "RUF001", # ambiguous-unicode-character-string
124
- "RUF005", # splat-instead-of-concatenation
125
- "PYI024", # collections-named-tuple
122
+ "module-import-not-at-top-of-file",
123
+ "ambiguous-unicode-character-string",
124
+ "collection-literal-concatenation",
125
+ "mutable-class-default",
126
126
  ]
127
127
  preview = true
128
128
 
129
129
  [tool.black]
130
130
  line-length = 88
131
- target-version = ["py39"]
131
+ target-version = ["py311"]
132
132
  force_exclude = "doc/*"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NeoBase
3
- Version: 0.34.28
3
+ Version: 0.35.1
4
4
  Summary: Python library to manipulate OpenTravelData
5
5
  Author-email: Alex Prengère <alex.prengere@gmail.com>
6
6
  Project-URL: Homepage, https://github.com/alexprengere/neobase
@@ -9,7 +9,7 @@ Classifier: Programming Language :: Python :: 3
9
9
  Classifier: Programming Language :: Python :: 3 :: Only
10
10
  Classifier: Programming Language :: Python :: Implementation :: CPython
11
11
  Classifier: Programming Language :: Python :: Implementation :: PyPy
12
- Requires-Python: >=3.9
12
+ Requires-Python: >=3.11
13
13
  Description-Content-Type: text/x-rst
14
14
  License-File: LICENSE
15
15
  Dynamic: license-file
@@ -30,7 +30,7 @@ Minimalist `GeoBases <https://github.com/opentraveldata/geobases/>`__
30
30
  implementation:
31
31
 
32
32
  - no dependencies
33
- - compatible with Python 3.9+, CPython and PyPy
33
+ - compatible with Python 3.11+, CPython and PyPy
34
34
  - one data source:
35
35
  `opentraveldata <https://github.com/opentraveldata/opentraveldata>`__
36
36
  - one Python module for easier distribution on clusters (like Hadoop)
@@ -1,25 +1,25 @@
1
1
  {
2
2
  "files": [
3
- ".pre-commit-config.yaml",
4
3
  "tox.ini",
5
- "LICENSE",
6
- "pyproject.toml",
7
- "README.rst",
4
+ ".pre-commit-config.yaml",
8
5
  "MANIFEST.in",
6
+ "README.rst",
7
+ "update_data.sh",
9
8
  "_config.yml",
9
+ "pyproject.toml",
10
+ "LICENSE",
10
11
  ".gitignore",
11
- "update_data.sh",
12
+ ".github/workflows/python-package.yml",
13
+ "tests/test_neobase.py",
14
+ "tests/conftest.py",
15
+ "doc/index.rst",
16
+ "doc/conf.py",
17
+ "doc/Makefile",
18
+ "doc/make.bat",
19
+ "src/neobase/optd_por_public.csv",
12
20
  "src/neobase/neobase.py",
13
21
  "src/neobase/__init__.py",
14
22
  "src/neobase/version.py",
15
- "src/neobase/optd_por_public.csv",
16
- "src/neobase/__main__.py",
17
- "doc/Makefile",
18
- "doc/index.rst",
19
- "doc/make.bat",
20
- "doc/conf.py",
21
- "tests/test_neobase.py",
22
- "tests/conftest.py",
23
- ".github/workflows/python-package.yml"
23
+ "src/neobase/__main__.py"
24
24
  ]
25
25
  }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "0.35.1",
3
+ "distance": 0,
4
+ "node": "gc721aa006ff5e634993c5fccb8839e3f172277cc",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-08-03"
8
+ }
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env python
2
+
3
+ from .neobase import * # ruff: ignore[undefined-local-with-import-star]
4
+ from .version import __version__ # ruff: ignore[unused-import]
@@ -20,28 +20,17 @@ from importlib.resources import files
20
20
  from os import getenv
21
21
  import operator
22
22
  from datetime import datetime
23
- from collections import namedtuple
24
23
  from math import pi, cos, sin, asin, sqrt, fsum
25
- from itertools import starmap
24
+ from itertools import starmap, pairwise
25
+ from typing import NamedTuple
26
26
  import csv
27
27
  import heapq
28
+ from collections.abc import Callable, Sequence
28
29
 
29
30
  from functools import partial
30
31
 
31
32
  open_ = partial(open, encoding="utf-8")
32
33
 
33
- try:
34
- # This is only available for Python3.10+
35
- from itertools import pairwise
36
- except ImportError:
37
- from itertools import tee
38
-
39
- def pairwise(iterable):
40
- # pairwise('ABCDEFG') --> AB BC CD DE EF FG
41
- a, b = tee(iterable)
42
- next(b, None)
43
- return zip(a, b)
44
-
45
34
 
46
35
  __all__ = ["OPTD_POR_URL", "LatLng", "NeoBase", "UnknownKeyError"]
47
36
 
@@ -52,7 +41,11 @@ OPTD_POR_URL = (
52
41
 
53
42
  _DEF_OPTD_POR_FILE = "optd_por_public.csv"
54
43
  _DEFAULT_RADIUS = 50
55
- LatLng = namedtuple("LatLng", ["lat", "lng"])
44
+
45
+
46
+ class LatLng(NamedTuple):
47
+ lat: float
48
+ lng: float
56
49
 
57
50
 
58
51
  class UnknownKeyError(KeyError):
@@ -67,7 +60,7 @@ class NeoBase:
67
60
  """Main structure, a wrapper around a dict, with dict-like behavior."""
68
61
 
69
62
  KEY = 0 # iata_code
70
- FIELDS = (
63
+ FIELDS: Sequence[tuple[str, int, Callable | None]] = (
71
64
  ("iata_code", 0, None),
72
65
  ("name", 6, None),
73
66
  ("lat", 8, None),
@@ -130,7 +123,7 @@ class NeoBase:
130
123
  """
131
124
  f = iter(f) # convert lists to iterators
132
125
 
133
- fields, key_c = cls.FIELDS, cls.KEY
126
+ fields, key_c, skip = cls.FIELDS, cls.KEY, cls.skip
134
127
  empty_value = cls._empty_value
135
128
 
136
129
  data = {}
@@ -139,12 +132,17 @@ class NeoBase:
139
132
  except StopIteration:
140
133
  pass
141
134
 
142
- for row in csv.reader(f, delimiter="^", quotechar='"'):
135
+ for line in f:
143
136
  # Comments and empty lines
144
- if not row or row[0].startswith("#"):
137
+ if not line or line.startswith("#"):
145
138
  continue
146
139
 
147
- if cls.skip(row, date):
140
+ if '"' in line:
141
+ row = next(csv.reader([line], delimiter="^", quotechar='"'))
142
+ else:
143
+ row = line.rstrip("\r\n").split("^")
144
+
145
+ if skip(row, date):
148
146
  continue
149
147
 
150
148
  key = row[key_c]
@@ -269,12 +267,12 @@ class NeoBase:
269
267
  """
270
268
  if key is not None:
271
269
  key = key.upper()
272
- try:
273
- d = self._data[key]
274
- except KeyError as e:
270
+
271
+ d = self._data.get(key)
272
+ if d is None:
275
273
  # Unless default is set, we raise an Exception
276
274
  if default is _sentinel:
277
- raise UnknownKeyError(f"Key not found: {key}") from e
275
+ raise UnknownKeyError(f"Key not found: {key}")
278
276
  return default
279
277
 
280
278
  if field is None:
@@ -294,7 +292,11 @@ class NeoBase:
294
292
  >>> b.get_location('ORY')
295
293
  LatLng(lat=48.72..., lng=2.35...)
296
294
  """
297
- if key not in self:
295
+ if key is not None:
296
+ key = key.upper()
297
+
298
+ d = self._data.get(key)
299
+ if d is None:
298
300
  # Unless default is set, we raise an Exception
299
301
  if default is _sentinel:
300
302
  raise UnknownKeyError(f"Key not found: {key}")
@@ -302,8 +304,8 @@ class NeoBase:
302
304
 
303
305
  try:
304
306
  loc = LatLng(
305
- float(self.get(key, lat_field)),
306
- float(self.get(key, lng_field)),
307
+ float(d[lat_field]),
308
+ float(d[lng_field]),
307
309
  )
308
310
 
309
311
  except (ValueError, TypeError, KeyError):
@@ -387,11 +389,19 @@ class NeoBase:
387
389
  if lat_lng_ref is None:
388
390
  return
389
391
 
392
+ data_get = self._data.get
393
+ distance_between_locations = self.distance_between_locations
390
394
  for key in keys:
391
- if key in self:
392
- lat_lng = self.get_location(key)
393
- if lat_lng is not None:
394
- yield self.distance_between_locations(lat_lng_ref, lat_lng), key
395
+ d = data_get(key.upper() if key is not None else key)
396
+
397
+ if d is None:
398
+ continue
399
+ try:
400
+ lat_lng = float(d["lat"]), float(d["lng"])
401
+ except (ValueError, TypeError, KeyError):
402
+ continue
403
+
404
+ yield distance_between_locations(lat_lng_ref, lat_lng), key
395
405
 
396
406
  def find_near_location(self, lat_lng, radius=_DEFAULT_RADIUS, from_keys=None):
397
407
  """