NeoBase 0.34.27__tar.gz → 0.35__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.27/src/NeoBase.egg-info → neobase-0.35}/PKG-INFO +1 -1
  2. {neobase-0.34.27 → neobase-0.35}/pyproject.toml +4 -4
  3. {neobase-0.34.27 → neobase-0.35/src/NeoBase.egg-info}/PKG-INFO +1 -1
  4. {neobase-0.34.27 → neobase-0.35}/src/NeoBase.egg-info/scm_file_list.json +14 -14
  5. neobase-0.35/src/NeoBase.egg-info/scm_version.json +8 -0
  6. neobase-0.35/src/neobase/__init__.py +4 -0
  7. {neobase-0.34.27 → neobase-0.35}/src/neobase/neobase.py +32 -15
  8. {neobase-0.34.27 → neobase-0.35}/src/neobase/optd_por_public.csv +320 -319
  9. neobase-0.34.27/src/NeoBase.egg-info/scm_version.json +0 -8
  10. neobase-0.34.27/src/neobase/__init__.py +0 -4
  11. {neobase-0.34.27 → neobase-0.35}/LICENSE +0 -0
  12. {neobase-0.34.27 → neobase-0.35}/MANIFEST.in +0 -0
  13. {neobase-0.34.27 → neobase-0.35}/README.rst +0 -0
  14. {neobase-0.34.27 → neobase-0.35}/_config.yml +0 -0
  15. {neobase-0.34.27 → neobase-0.35}/doc/Makefile +0 -0
  16. {neobase-0.34.27 → neobase-0.35}/doc/conf.py +0 -0
  17. {neobase-0.34.27 → neobase-0.35}/doc/index.rst +0 -0
  18. {neobase-0.34.27 → neobase-0.35}/doc/make.bat +0 -0
  19. {neobase-0.34.27 → neobase-0.35}/setup.cfg +0 -0
  20. {neobase-0.34.27 → neobase-0.35}/src/NeoBase.egg-info/SOURCES.txt +0 -0
  21. {neobase-0.34.27 → neobase-0.35}/src/NeoBase.egg-info/dependency_links.txt +0 -0
  22. {neobase-0.34.27 → neobase-0.35}/src/NeoBase.egg-info/entry_points.txt +0 -0
  23. {neobase-0.34.27 → neobase-0.35}/src/NeoBase.egg-info/top_level.txt +0 -0
  24. {neobase-0.34.27 → neobase-0.35}/src/neobase/__main__.py +0 -0
  25. {neobase-0.34.27 → neobase-0.35}/src/neobase/version.py +0 -0
  26. {neobase-0.34.27 → neobase-0.35}/tox.ini +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NeoBase
3
- Version: 0.34.27
3
+ Version: 0.35
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
@@ -119,10 +119,10 @@ 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
+ "collections-named-tuple",
126
126
  ]
127
127
  preview = true
128
128
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: NeoBase
3
- Version: 0.34.27
3
+ Version: 0.35
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
@@ -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",
3
+ "distance": 0,
4
+ "node": "ga2c01f4a375b69ab3c2195d56cf5afdce68c1ad8",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-08-01"
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]
@@ -130,7 +130,7 @@ class NeoBase:
130
130
  """
131
131
  f = iter(f) # convert lists to iterators
132
132
 
133
- fields, key_c = cls.FIELDS, cls.KEY
133
+ fields, key_c, skip = cls.FIELDS, cls.KEY, cls.skip
134
134
  empty_value = cls._empty_value
135
135
 
136
136
  data = {}
@@ -139,12 +139,17 @@ class NeoBase:
139
139
  except StopIteration:
140
140
  pass
141
141
 
142
- for row in csv.reader(f, delimiter="^", quotechar='"'):
142
+ for line in f:
143
143
  # Comments and empty lines
144
- if not row or row[0].startswith("#"):
144
+ if not line or line.startswith("#"):
145
145
  continue
146
146
 
147
- if cls.skip(row, date):
147
+ if '"' in line:
148
+ row = next(csv.reader([line], delimiter="^", quotechar='"'))
149
+ else:
150
+ row = line.rstrip("\r\n").split("^")
151
+
152
+ if skip(row, date):
148
153
  continue
149
154
 
150
155
  key = row[key_c]
@@ -269,12 +274,12 @@ class NeoBase:
269
274
  """
270
275
  if key is not None:
271
276
  key = key.upper()
272
- try:
273
- d = self._data[key]
274
- except KeyError as e:
277
+
278
+ d = self._data.get(key)
279
+ if d is None:
275
280
  # Unless default is set, we raise an Exception
276
281
  if default is _sentinel:
277
- raise UnknownKeyError(f"Key not found: {key}") from e
282
+ raise UnknownKeyError(f"Key not found: {key}")
278
283
  return default
279
284
 
280
285
  if field is None:
@@ -294,7 +299,11 @@ class NeoBase:
294
299
  >>> b.get_location('ORY')
295
300
  LatLng(lat=48.72..., lng=2.35...)
296
301
  """
297
- if key not in self:
302
+ if key is not None:
303
+ key = key.upper()
304
+
305
+ d = self._data.get(key)
306
+ if d is None:
298
307
  # Unless default is set, we raise an Exception
299
308
  if default is _sentinel:
300
309
  raise UnknownKeyError(f"Key not found: {key}")
@@ -302,8 +311,8 @@ class NeoBase:
302
311
 
303
312
  try:
304
313
  loc = LatLng(
305
- float(self.get(key, lat_field)),
306
- float(self.get(key, lng_field)),
314
+ float(d[lat_field]),
315
+ float(d[lng_field]),
307
316
  )
308
317
 
309
318
  except (ValueError, TypeError, KeyError):
@@ -387,11 +396,19 @@ class NeoBase:
387
396
  if lat_lng_ref is None:
388
397
  return
389
398
 
399
+ data_get = self._data.get
400
+ distance_between_locations = self.distance_between_locations
390
401
  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
402
+ d = data_get(key.upper() if key is not None else key)
403
+
404
+ if d is None:
405
+ continue
406
+ try:
407
+ lat_lng = float(d["lat"]), float(d["lng"])
408
+ except (ValueError, TypeError, KeyError):
409
+ continue
410
+
411
+ yield distance_between_locations(lat_lng_ref, lat_lng), key
395
412
 
396
413
  def find_near_location(self, lat_lng, radius=_DEFAULT_RADIUS, from_keys=None):
397
414
  """