jageocoder 2.1.9.dev2__tar.gz → 2.1.9.dev3__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.
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/PKG-INFO +1 -1
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/__init__.py +1 -1
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/remote.py +37 -3
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/tree.py +19 -15
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/pyproject.toml +1 -1
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/LICENSE +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/README.md +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/__main__.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/address.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/aza_master.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/dataset.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/exceptions.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/itaiji.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/itaiji_dic.json +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/module.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/node.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/result.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/rtree.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/strlib.py +0 -0
- {jageocoder-2.1.9.dev2 → jageocoder-2.1.9.dev3}/jageocoder/trie.py +0 -0
|
@@ -19,7 +19,7 @@ running the following steps.
|
|
|
19
19
|
>>> jageocoder.searchNode('<Japanese-address>')
|
|
20
20
|
"""
|
|
21
21
|
|
|
22
|
-
__version__ = '2.1.9.
|
|
22
|
+
__version__ = '2.1.9.dev3' # The package version
|
|
23
23
|
__dictionary_version__ = '20230927' # Compatible dictionary version
|
|
24
24
|
__author__ = 'Takeshi Sagara <sagara@info-proto.com>'
|
|
25
25
|
|
|
@@ -2,10 +2,12 @@ from __future__ import annotations
|
|
|
2
2
|
import json
|
|
3
3
|
from logging import getLogger
|
|
4
4
|
import os
|
|
5
|
-
import
|
|
5
|
+
import re
|
|
6
6
|
from typing import Any, List, NoReturn, Optional
|
|
7
7
|
import uuid
|
|
8
8
|
|
|
9
|
+
import requests
|
|
10
|
+
|
|
9
11
|
from jageocoder.address import AddressLevel
|
|
10
12
|
from jageocoder.exceptions import RemoteTreeException
|
|
11
13
|
from jageocoder.node import AddressNode
|
|
@@ -249,8 +251,8 @@ class RemoteTree(AddressTree):
|
|
|
249
251
|
|
|
250
252
|
- target_area: List[str] (Default = [])
|
|
251
253
|
Specify the areas to be searched.
|
|
252
|
-
The area can be specified by the list of
|
|
253
|
-
|
|
254
|
+
The area can be specified by the list of JIS code of the node.
|
|
255
|
+
Note: Can't specify by node names when using remote server, currently.
|
|
254
256
|
|
|
255
257
|
- auto_redirect: bool (default = True)
|
|
256
258
|
When this option is set and the retrieved node has a
|
|
@@ -261,6 +263,38 @@ class RemoteTree(AddressTree):
|
|
|
261
263
|
self.validate_config(key=k, value=v)
|
|
262
264
|
self.config[k] = v
|
|
263
265
|
|
|
266
|
+
def validate_config(self, key: str, value: Any) -> None:
|
|
267
|
+
"""
|
|
268
|
+
Validate configuration key and parameters.
|
|
269
|
+
|
|
270
|
+
Parameters
|
|
271
|
+
----------
|
|
272
|
+
key: str
|
|
273
|
+
The name of the parameter.
|
|
274
|
+
value: str, int, bool, None
|
|
275
|
+
The value to be set to the parameter.
|
|
276
|
+
|
|
277
|
+
Notes
|
|
278
|
+
-----
|
|
279
|
+
If the key-value pair is not valid, raise RuntimeError.
|
|
280
|
+
"""
|
|
281
|
+
if key == 'target_area':
|
|
282
|
+
if value in (None, []):
|
|
283
|
+
return
|
|
284
|
+
|
|
285
|
+
if isinstance(value, str):
|
|
286
|
+
value = [value]
|
|
287
|
+
|
|
288
|
+
for v in value:
|
|
289
|
+
if re.match(r'\d{2}', v) or re.match(r'\d{5}', v):
|
|
290
|
+
return
|
|
291
|
+
|
|
292
|
+
msg = "'{}' is not a valid value for {}.".format(v, key)
|
|
293
|
+
raise RuntimeError(msg)
|
|
294
|
+
|
|
295
|
+
else:
|
|
296
|
+
return
|
|
297
|
+
|
|
264
298
|
def json_request(
|
|
265
299
|
self,
|
|
266
300
|
method: str,
|
|
@@ -402,22 +402,26 @@ class AddressTree(object):
|
|
|
402
402
|
if value in (None, []):
|
|
403
403
|
return
|
|
404
404
|
|
|
405
|
-
if
|
|
406
|
-
|
|
405
|
+
if isinstance(value, str):
|
|
406
|
+
value = [value]
|
|
407
407
|
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
408
|
+
for v in value:
|
|
409
|
+
if re.match(r'\d{2}', v) or re.match(r'\d{5}', v):
|
|
410
|
+
return
|
|
411
|
+
|
|
412
|
+
# Check if the value is a name of node in the database.
|
|
413
|
+
std = self.converter.standardize(v)
|
|
414
|
+
candidates = self.trie.common_prefixes(std)
|
|
415
|
+
if std in candidates:
|
|
416
|
+
trie_node_id = candidates[std]
|
|
417
|
+
for node_id in self.trie_nodes.get_record(
|
|
418
|
+
pos=trie_node_id).nodes:
|
|
419
|
+
node = self.address_nodes.get_record(pos=node_id)
|
|
420
|
+
if node.name == v:
|
|
421
|
+
return
|
|
422
|
+
|
|
423
|
+
msg = "'{}' is not a valid value for {}.".format(v, key)
|
|
424
|
+
raise RuntimeError(msg)
|
|
421
425
|
|
|
422
426
|
else:
|
|
423
427
|
return
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|