diff --git a/.vscode/launch.json b/.vscode/launch.json index ee3e88c..e76688a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,17 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "Install dictionary", + "type": "python", + "request": "launch", + "module": "jageocoder", + "args": [ + "install-dictionary", + "jukyo_all_v20.zip", + "-y" + ] + }, { "name": "Python: Reverse test", "type": "python", diff --git a/flask-demo/templates/aza.html b/flask-demo/templates/aza.html index 0172b1b..e415627 100644 --- a/flask-demo/templates/aza.html +++ b/flask-demo/templates/aza.html @@ -1,80 +1,44 @@ - - - - - - Jageocoder Demonstration - - - -

- Jageocoder - のデモンストレーション

-
- - -
- 小字の省略: - 自動判定  - 省略する  - 省略しない  -
+{% extends 'base.html' %} -

- 住所の例に戻る

+{% block title %}ノード一覧 | Jageocoder{% endblock %} -

アドレス・ベース・レジストリ マスター属性

+{% block content %} +{% include "addressform.html" %} - {% if aza is none %} - (条件に該当するレコードが見つかりません) - {% else %} - - {% endif %} +

アドレス・ベース・レジストリ マスター属性

- - +{% if aza is none %} +(条件に該当するレコードが見つかりません) +{% else %} + +{% endif %} + +{% endblock %} diff --git a/jageocoder/__init__.py b/jageocoder/__init__.py index e0c577c..3868bcd 100644 --- a/jageocoder/__init__.py +++ b/jageocoder/__init__.py @@ -19,7 +19,7 @@ >>> jageocoder.searchNode('') """ -__version__ = '2.0.2rc1' # The package version +__version__ = '2.0.2' # The package version __dictionary_version__ = '20230405' # Compatible dictionary version __author__ = 'Takeshi Sagara ' @@ -34,7 +34,6 @@ 'download_dictionary', 'install_dictionary', 'uninstall_dictionary', - 'migrate_dictionary', 'create_trie_index', 'search', 'searchNode', @@ -48,6 +47,6 @@ from jageocoder.module import init, free, is_initialized,\ get_db_dir, set_search_config, get_search_config,\ get_module_tree, download_dictionary, install_dictionary,\ - uninstall_dictionary, migrate_dictionary, create_trie_index,\ + uninstall_dictionary, create_trie_index,\ search, searchNode, reverse, version, dictionary_version,\ installed_dictionary_version, installed_dictionary_readme # noqa: F401 diff --git a/jageocoder/__main__.py b/jageocoder/__main__.py index 10f14cc..dc91e1f 100644 --- a/jageocoder/__main__.py +++ b/jageocoder/__main__.py @@ -16,7 +16,7 @@ {p} reverse [-d] [--level=] [--db-dir=] {p} get-db-dir [-d] {p} download-dictionary [-d] - {p} install-dictionary [-d] [--db-dir=] + {p} install-dictionary [-d] [-y] [--db-dir=] {p} uninstall-dictionary [-d] [--db-dir=] Options: @@ -138,11 +138,12 @@ def main(): try: jageocoder.install_dictionary( path=path, - db_dir=args['--db-dir'] + db_dir=args['--db-dir'], + skip_confirmation=(args['-y'] is True), ) except JageocoderError: logging.warning(( - "Could not find the dictionary at '{}'.".format(path) + "辞書データファイルが '{}' にありません。".format(path) )) exit(1) diff --git a/jageocoder/module.py b/jageocoder/module.py index ddbb7a3..df61d95 100644 --- a/jageocoder/module.py +++ b/jageocoder/module.py @@ -174,7 +174,8 @@ def download_dictionary(url: str) -> None: def install_dictionary( path: os.PathLike, - db_dir: Optional[os.PathLike] = None) -> None: + db_dir: Optional[os.PathLike] = None, + skip_confirmation: bool = False) -> None: """ Install address-dictionary from the specified path. @@ -193,6 +194,12 @@ def install_dictionary( if db_dir is None: db_dir = get_db_dir(mode='w') + if skip_confirmation is not True and (db_dir / 'address_node').exists(): + # Dictionary had been installed. + r = input("他の辞書がインストール済みです。上書きしますか?(Y/n) ") + if r.lower()[0] != 'y': + return + if os.path.exists(path): path = path else: @@ -235,30 +242,6 @@ def uninstall_dictionary(db_dir: Optional[os.PathLike] = None) -> None: logger.info('Dictionary has been uninstalled.') -def migrate_dictionary(db_dir: Optional[os.PathLike] = None) -> None: - """ - Migrate address-dictionary. - - Parameters - ---------- - db_dir: os.PathLike, optional - The directory where the database files has been installed. - If omitted, it will be determined by `get_db_dir()`. - """ - # Set default value - if db_dir is None: - db_dir = get_db_dir(mode='a') - - # Update the name and trie index - init(db_dir=db_dir, mode='a') - global _tree - # logger.info('Updating name index') - # _tree.update_name_index() - logger.info('Updating TRIE index {}'.format(_tree.trie_path)) - _tree.create_trie_index() - logger.info('The dictionary is successfully migrated.') - - def installed_dictionary_version(db_dir: Optional[os.PathLike] = None) -> str: """ Get the installed dictionary version. diff --git a/poetry.lock b/poetry.lock index a2979dd..34fb0b6 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand. [[package]] name = "alabaster" @@ -842,14 +842,14 @@ testing = ["pytest", "pytest-benchmark"] [[package]] name = "portabletab" -version = "0.3.2" +version = "0.3.3" description = "Python package for serializing tables in portable format with Capnp." category = "main" optional = false python-versions = ">=3.7,<4.0" files = [ - {file = "portabletab-0.3.2-py3-none-any.whl", hash = "sha256:597730aaef6280d4c5482f04666a8c83d7632eadb1d2ae6fb1a1f6caff6eba70"}, - {file = "portabletab-0.3.2.tar.gz", hash = "sha256:e23fb3690f24245c976e71b24252c0d65b595017311c008a8b0673c6af0733ff"}, + {file = "portabletab-0.3.3-py3-none-any.whl", hash = "sha256:30cbd473a38ac95de98f4ceb3b8ef84abcf153d806e7d0b9e5fd8cb95f23234b"}, + {file = "portabletab-0.3.3.tar.gz", hash = "sha256:a550333f231571b9bfd16090c55faad8ab43fd2b21ac4eaee5f38575463319c8"}, ] [package.dependencies] @@ -1579,4 +1579,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "a342746ba7d78ab01a3870e1d379e7f182310d4f3fdd1b1c608cad25c20b722e" +content-hash = "04ee21ac04261898f1e8089c0c9c28aa32974bcf9f976fd9bba72e14e84098d3" diff --git a/pyproject.toml b/pyproject.toml index e6cbea7..5fa2b7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "jageocoder" -version = "2.0.2rc1" +version = "2.0.2" description = "A Japanese-address geocoder for Python." authors = ["Takeshi Sagara "] repository = "https://github.com/t-sagara/jageocoder/" @@ -27,7 +27,7 @@ docopt = "^0.6.2" deprecated = "^1.2.13" Werkzeug = ">=2.2.3" pycapnp = "^1.3.0" -portabletab = ">=0.3.2" +portabletab = ">=0.3.3" tqdm = "^4.00.0" rtree = "^1.0.0" geographiclib = "^2.0"