cihai-cli 0.26.0__tar.gz → 0.27.0__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.
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/PKG-INFO +2 -2
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/pyproject.toml +2 -2
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/src/cihai_cli/__about__.py +2 -1
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/src/cihai_cli/cli.py +12 -8
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/conftest.py +8 -7
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/test_cli.py +9 -7
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/LICENSE +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/README.md +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/src/cihai_cli/__init__.py +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/__init__.py +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/Unihan_DictionaryIndices.txt +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/Unihan_DictionaryLikeData.txt +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/Unihan_IRGSources.txt +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/Unihan_NumericValues.txt +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/Unihan_OtherMappings.txt +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/Unihan_RadicalStrokeCounts.txt +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/Unihan_Readings.txt +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/Unihan_Variants.txt +0 -0
- {cihai_cli-0.26.0 → cihai_cli-0.27.0}/tests/fixtures/test_config.yml +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cihai-cli
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.27.0
|
|
4
4
|
Summary: Command line frontend for the cihai CJK language library
|
|
5
5
|
Home-page: https://cihai-cli.git-pull.com
|
|
6
6
|
License: MIT
|
|
@@ -25,7 +25,7 @@ Classifier: Topic :: Software Development :: Localization
|
|
|
25
25
|
Classifier: Topic :: System :: Shells
|
|
26
26
|
Classifier: Topic :: Utilities
|
|
27
27
|
Requires-Dist: PyYAML
|
|
28
|
-
Requires-Dist: cihai (>=0.
|
|
28
|
+
Requires-Dist: cihai (>=0.32.0,<0.33.0)
|
|
29
29
|
Project-URL: Bug Tracker, https://github.com/cihai/cihai-cli/issues
|
|
30
30
|
Project-URL: Documentation, https://cihai-cli.git-pull.com
|
|
31
31
|
Project-URL: Q & A, https://github.com/cihai/cihai-cli/discussions
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "cihai-cli"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.27.0"
|
|
4
4
|
description = "Command line frontend for the cihai CJK language library"
|
|
5
5
|
license = "MIT"
|
|
6
6
|
authors = ["Tony Narlock <tony@git-pull.com>"]
|
|
@@ -58,7 +58,7 @@ Repository = "https://github.com/cihai/cihai-cli"
|
|
|
58
58
|
|
|
59
59
|
[tool.poetry.dependencies]
|
|
60
60
|
python = "^3.8"
|
|
61
|
-
cihai = "~0.
|
|
61
|
+
cihai = "~0.32.0"
|
|
62
62
|
PyYAML = "*"
|
|
63
63
|
|
|
64
64
|
[tool.poetry.group.docs.dependencies]
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"""Metadata for cihai_cli package."""
|
|
2
|
+
|
|
2
3
|
__title__ = "cihai-cli"
|
|
3
4
|
__package_name__ = "cihai_cli"
|
|
4
|
-
__version__ = "0.
|
|
5
|
+
__version__ = "0.27.0"
|
|
5
6
|
__description__ = "Command line frontend for the cihai CJK language library"
|
|
6
7
|
__author__ = "Tony Narlock"
|
|
7
8
|
__email__ = "tony@git-pull.com"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""CLI functionality for cihai-cli."""
|
|
2
|
+
|
|
2
3
|
import argparse
|
|
3
4
|
import logging
|
|
4
5
|
import sys
|
|
@@ -12,6 +13,9 @@ from unihan_etl.__about__ import __version__ as unihan_etl_version
|
|
|
12
13
|
|
|
13
14
|
from .__about__ import __version__
|
|
14
15
|
|
|
16
|
+
log = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
15
19
|
#: fields which are human friendly
|
|
16
20
|
HUMAN_UNIHAN_FIELDS = [
|
|
17
21
|
"char",
|
|
@@ -90,18 +94,18 @@ def cli(_args: t.Optional[t.List[str]] = None) -> None:
|
|
|
90
94
|
c = Cihai.from_file(args.config_file) if args.config_file else Cihai()
|
|
91
95
|
|
|
92
96
|
if not c.unihan.is_bootstrapped:
|
|
93
|
-
|
|
97
|
+
log.info("Bootstrapping Unihan database")
|
|
94
98
|
c.unihan.bootstrap(options=c.config.get("unihan_options", {}))
|
|
95
99
|
|
|
96
100
|
if args.subparser_name is None:
|
|
97
101
|
parser.print_help()
|
|
98
102
|
return
|
|
99
|
-
|
|
103
|
+
if args.subparser_name == "info":
|
|
100
104
|
command_info(c=c, char=args.char, show_all=args.show_all)
|
|
101
105
|
elif args.subparser_name == "reverse":
|
|
102
106
|
command_reverse(c=c, char=args.char, show_all=args.show_all)
|
|
103
107
|
else:
|
|
104
|
-
|
|
108
|
+
log.info(f"No subparser for {args.subparser_name}")
|
|
105
109
|
|
|
106
110
|
|
|
107
111
|
def create_info_subparser(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
|
|
@@ -122,7 +126,7 @@ def command_info(c: Cihai, char: str, show_all: bool) -> None:
|
|
|
122
126
|
query = c.unihan.lookup_char(char).first()
|
|
123
127
|
attrs = {}
|
|
124
128
|
if not query:
|
|
125
|
-
|
|
129
|
+
log.info(f"No records found for {char}")
|
|
126
130
|
sys.exit()
|
|
127
131
|
for col, _, _ in query.__table__.columns._collection:
|
|
128
132
|
value = getattr(query, col)
|
|
@@ -130,7 +134,7 @@ def command_info(c: Cihai, char: str, show_all: bool) -> None:
|
|
|
130
134
|
if not show_all and str(col) not in HUMAN_UNIHAN_FIELDS:
|
|
131
135
|
continue
|
|
132
136
|
attrs[str(col)] = value
|
|
133
|
-
|
|
137
|
+
log.info(
|
|
134
138
|
yaml.safe_dump(attrs, allow_unicode=True, default_flow_style=False).strip("\n"),
|
|
135
139
|
)
|
|
136
140
|
|
|
@@ -154,7 +158,7 @@ def command_reverse(c: Cihai, char: str, show_all: bool) -> None:
|
|
|
154
158
|
"""Lookup a word or phrase by searching definitions."""
|
|
155
159
|
query = c.unihan.reverse_char([char])
|
|
156
160
|
if not query.count():
|
|
157
|
-
|
|
161
|
+
log.info("No records found for %s" % char)
|
|
158
162
|
sys.exit()
|
|
159
163
|
for k in query:
|
|
160
164
|
attrs = {}
|
|
@@ -164,12 +168,12 @@ def command_reverse(c: Cihai, char: str, show_all: bool) -> None:
|
|
|
164
168
|
if not show_all and str(c) not in HUMAN_UNIHAN_FIELDS:
|
|
165
169
|
continue
|
|
166
170
|
attrs[str(c)] = value
|
|
167
|
-
|
|
171
|
+
log.info(
|
|
168
172
|
yaml.safe_dump(attrs, allow_unicode=True, default_flow_style=False).strip(
|
|
169
173
|
"\n",
|
|
170
174
|
),
|
|
171
175
|
)
|
|
172
|
-
|
|
176
|
+
log.info("--------")
|
|
173
177
|
|
|
174
178
|
|
|
175
179
|
def setup_logger(
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""Pytest configuration."""
|
|
2
|
+
|
|
2
3
|
import pathlib
|
|
3
4
|
import typing as t
|
|
4
5
|
import zipfile
|
|
@@ -11,31 +12,31 @@ if t.TYPE_CHECKING:
|
|
|
11
12
|
from cihai.types import UntypedDict as UnihanOptions
|
|
12
13
|
|
|
13
14
|
|
|
14
|
-
@pytest.fixture
|
|
15
|
+
@pytest.fixture()
|
|
15
16
|
def tests_path() -> pathlib.Path:
|
|
16
17
|
"""Return tests/ directory."""
|
|
17
18
|
return pathlib.Path(__file__).parent
|
|
18
19
|
|
|
19
20
|
|
|
20
|
-
@pytest.fixture
|
|
21
|
+
@pytest.fixture()
|
|
21
22
|
def fixture_path(tests_path: pathlib.Path) -> pathlib.Path:
|
|
22
23
|
"""Return tests/fixtures/ directory."""
|
|
23
24
|
return tests_path / "fixtures"
|
|
24
25
|
|
|
25
26
|
|
|
26
|
-
@pytest.fixture
|
|
27
|
+
@pytest.fixture()
|
|
27
28
|
def test_config_file(fixture_path: pathlib.Path) -> pathlib.Path:
|
|
28
29
|
"""Return test_config.yml file."""
|
|
29
30
|
return fixture_path / "test_config.yml"
|
|
30
31
|
|
|
31
32
|
|
|
32
|
-
@pytest.fixture
|
|
33
|
+
@pytest.fixture()
|
|
33
34
|
def zip_path(tmp_path: pathlib.Path) -> pathlib.Path:
|
|
34
35
|
"""Return Unihan.zip in temporary path."""
|
|
35
36
|
return tmp_path / "Unihan.zip"
|
|
36
37
|
|
|
37
38
|
|
|
38
|
-
@pytest.fixture
|
|
39
|
+
@pytest.fixture()
|
|
39
40
|
def zip_file(zip_path: pathlib.Path, fixture_path: pathlib.Path) -> zipfile.ZipFile:
|
|
40
41
|
"""Create and return ZipFile."""
|
|
41
42
|
_files = []
|
|
@@ -48,7 +49,7 @@ def zip_file(zip_path: pathlib.Path, fixture_path: pathlib.Path) -> zipfile.ZipF
|
|
|
48
49
|
return zf
|
|
49
50
|
|
|
50
51
|
|
|
51
|
-
@pytest.fixture
|
|
52
|
+
@pytest.fixture()
|
|
52
53
|
def unihan_options(
|
|
53
54
|
zip_file: zipfile.ZipFile,
|
|
54
55
|
zip_path: pathlib.Path,
|
|
@@ -62,7 +63,7 @@ def unihan_options(
|
|
|
62
63
|
}
|
|
63
64
|
|
|
64
65
|
|
|
65
|
-
@pytest.fixture(
|
|
66
|
+
@pytest.fixture()
|
|
66
67
|
def tmpdb_file(tmpdir: pathlib.Path) -> pathlib.Path:
|
|
67
68
|
"""Return test SQLite database."""
|
|
68
69
|
return tmpdir / "test.db"
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
"""CLI tests for cihai-cli."""
|
|
2
|
+
|
|
2
3
|
import contextlib
|
|
3
4
|
import pathlib
|
|
4
5
|
import typing as t
|
|
@@ -36,6 +37,7 @@ def test_cli(
|
|
|
36
37
|
def test_cli_reflects_after_bootstrap(
|
|
37
38
|
tmp_path: pathlib.Path,
|
|
38
39
|
capsys: pytest.CaptureFixture[str],
|
|
40
|
+
caplog: pytest.LogCaptureFixture,
|
|
39
41
|
monkeypatch: pytest.MonkeyPatch,
|
|
40
42
|
tmpdb_file: pathlib.Path,
|
|
41
43
|
unihan_options: "UnihanOptions",
|
|
@@ -58,22 +60,23 @@ def test_cli_reflects_after_bootstrap(
|
|
|
58
60
|
try:
|
|
59
61
|
cli(["-c", str(config_file), "info", "㐀"])
|
|
60
62
|
except SystemExit:
|
|
61
|
-
|
|
62
|
-
output = "".join(list(result.out))
|
|
63
|
+
output = "".join(list(caplog.messages) + list(capsys.readouterr().out))
|
|
63
64
|
assert "Bootstrapping Unihan database" in output
|
|
64
65
|
|
|
66
|
+
caplog.clear()
|
|
67
|
+
|
|
65
68
|
try:
|
|
66
69
|
cli(["-c", str(config_file), "info"])
|
|
67
70
|
except SystemExit:
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
assert "Bootstrapping" in output
|
|
71
|
+
output = "".join(list(capsys.readouterr().err))
|
|
72
|
+
assert "cihai info" in output
|
|
71
73
|
|
|
72
74
|
|
|
73
75
|
@pytest.mark.parametrize("flag", ["-V", "--version"])
|
|
74
76
|
def test_cli_version(
|
|
75
77
|
tmp_path: pathlib.Path,
|
|
76
78
|
capsys: pytest.CaptureFixture[str],
|
|
79
|
+
caplog: pytest.LogCaptureFixture,
|
|
77
80
|
monkeypatch: pytest.MonkeyPatch,
|
|
78
81
|
flag: str,
|
|
79
82
|
) -> None:
|
|
@@ -81,8 +84,7 @@ def test_cli_version(
|
|
|
81
84
|
try:
|
|
82
85
|
cli([flag])
|
|
83
86
|
except SystemExit:
|
|
84
|
-
|
|
85
|
-
output = "".join(list(result.out))
|
|
87
|
+
output = "".join(list(caplog.messages) + list(capsys.readouterr().out))
|
|
86
88
|
assert "cihai-cli" in output
|
|
87
89
|
assert "cihai" in output
|
|
88
90
|
assert "unihan-etl" in output
|
|
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
|