pyconvertu 1.0.5__tar.gz → 1.0.6__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.
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/PKG-INFO +4 -4
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/README.md +3 -3
- pyconvertu-1.0.6/convertu/__init__.py +8 -0
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/convertu/__main__.py +5 -5
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/convertu/convertu.py +5 -5
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/pyconvertu.egg-info/PKG-INFO +4 -4
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/pyproject.toml +1 -1
- pyconvertu-1.0.5/convertu/__init__.py +0 -8
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/MANIFEST.in +0 -0
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/convertu/classification.json +0 -0
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/pyconvertu.egg-info/SOURCES.txt +0 -0
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/pyconvertu.egg-info/dependency_links.txt +0 -0
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/pyconvertu.egg-info/entry_points.txt +0 -0
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/pyconvertu.egg-info/top_level.txt +0 -0
- {pyconvertu-1.0.5 → pyconvertu-1.0.6}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyconvertu
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Summary: From/to Classification Converter
|
|
5
5
|
Author-email: The Economist <29724411+econcz@users.noreply.github.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -29,9 +29,9 @@ pip install pyconvertu
|
|
|
29
29
|
## Quick example
|
|
30
30
|
python:
|
|
31
31
|
```python
|
|
32
|
-
from convertu import
|
|
32
|
+
from convertu import cconv
|
|
33
33
|
|
|
34
|
-
print(
|
|
34
|
+
print(cconv(to="iso3", text=["Czech Republic", "Slovakia"]))
|
|
35
35
|
```
|
|
36
36
|
bash:
|
|
37
37
|
```bash
|
|
@@ -42,7 +42,7 @@ echo -e "Czech Republic\nSlovakia" | cconv -t iso3
|
|
|
42
42
|
## User Reference
|
|
43
43
|
|
|
44
44
|
```python
|
|
45
|
-
|
|
45
|
+
cconv(
|
|
46
46
|
data=[...], json_file='...', info=False, dump=False,
|
|
47
47
|
to="...", text="..." | ["...", "..."], *args, **kwargs
|
|
48
48
|
)
|
|
@@ -11,9 +11,9 @@ pip install pyconvertu
|
|
|
11
11
|
## Quick example
|
|
12
12
|
python:
|
|
13
13
|
```python
|
|
14
|
-
from convertu import
|
|
14
|
+
from convertu import cconv
|
|
15
15
|
|
|
16
|
-
print(
|
|
16
|
+
print(cconv(to="iso3", text=["Czech Republic", "Slovakia"]))
|
|
17
17
|
```
|
|
18
18
|
bash:
|
|
19
19
|
```bash
|
|
@@ -24,7 +24,7 @@ echo -e "Czech Republic\nSlovakia" | cconv -t iso3
|
|
|
24
24
|
## User Reference
|
|
25
25
|
|
|
26
26
|
```python
|
|
27
|
-
|
|
27
|
+
cconv(
|
|
28
28
|
data=[...], json_file='...', info=False, dump=False,
|
|
29
29
|
to="...", text="..." | ["...", "..."], *args, **kwargs
|
|
30
30
|
)
|
|
@@ -2,7 +2,7 @@ from __future__ import annotations
|
|
|
2
2
|
import signal
|
|
3
3
|
import sys
|
|
4
4
|
import argparse
|
|
5
|
-
from convertu import
|
|
5
|
+
from convertu import cconv, __version__
|
|
6
6
|
from typing import Any
|
|
7
7
|
from json import dumps
|
|
8
8
|
|
|
@@ -49,16 +49,16 @@ def main() -> int:
|
|
|
49
49
|
)
|
|
50
50
|
parser.add_argument(
|
|
51
51
|
"text", nargs="*",
|
|
52
|
-
help="Input text(s) to convert (e.g.,
|
|
52
|
+
help="Input text(s) to convert (e.g., cconv -t iso3 'Czech Republic')."
|
|
53
53
|
)
|
|
54
54
|
try:
|
|
55
55
|
args = parser.parse_args()
|
|
56
56
|
if args.info:
|
|
57
|
-
result =
|
|
57
|
+
result = cconv(json_file=args.source, info=True)
|
|
58
58
|
_print_human_readable(result)
|
|
59
59
|
return 0
|
|
60
60
|
if args.dump:
|
|
61
|
-
result =
|
|
61
|
+
result = cconv(json_file=args.source, dump=True)
|
|
62
62
|
_print_human_readable(result)
|
|
63
63
|
return 0
|
|
64
64
|
if not args.to:
|
|
@@ -77,7 +77,7 @@ def main() -> int:
|
|
|
77
77
|
|
|
78
78
|
# preserve shape: single token -> str, multiple -> list[str]
|
|
79
79
|
text_in: str | list[str] = inputs[0] if len(inputs) == 1 else inputs
|
|
80
|
-
result =
|
|
80
|
+
result = cconv(json_file=args.source, to=args.to, text=text_in)
|
|
81
81
|
if isinstance(result, list):
|
|
82
82
|
for item in result:
|
|
83
83
|
print(item)
|
|
@@ -53,23 +53,23 @@ def _validate_data(obj: list[dict[str, Any]]) -> None:
|
|
|
53
53
|
- exactly one dict has key 'sources' (value is a list).
|
|
54
54
|
"""
|
|
55
55
|
if not isinstance(obj, list) or not all(isinstance(d, dict) for d in obj):
|
|
56
|
-
raise ConvertUError("
|
|
56
|
+
raise ConvertUError("`data` must be a list[dict]")
|
|
57
57
|
if not any(isinstance(d.get("regex"), str) and d.get("regex", "").strip()
|
|
58
58
|
for d in obj):
|
|
59
|
-
raise ConvertUError("
|
|
59
|
+
raise ConvertUError("`data` must include at least one entry with "
|
|
60
60
|
"a non-empty 'regex' string")
|
|
61
61
|
if sum(1 for d in obj if "metadata" in d and
|
|
62
62
|
isinstance(d["metadata"], dict) and
|
|
63
63
|
d["metadata"]) != 1:
|
|
64
|
-
raise ConvertUError("
|
|
64
|
+
raise ConvertUError("`data` must include exactly one non-empty "
|
|
65
65
|
"'metadata' dict")
|
|
66
66
|
if sum(1 for d in obj if "sources" in d and
|
|
67
67
|
isinstance(d["sources"], list) and
|
|
68
68
|
d["sources"]) != 1:
|
|
69
|
-
raise ConvertUError("
|
|
69
|
+
raise ConvertUError("`data` must include exactly one non-empty "
|
|
70
70
|
"'sources' list")
|
|
71
71
|
|
|
72
|
-
def
|
|
72
|
+
def cconv(
|
|
73
73
|
data: list[dict] | None = None, json_file: str | None = None,
|
|
74
74
|
info: bool = False, dump: bool = False,
|
|
75
75
|
to: str = '', text: str | list[str] | None = None,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyconvertu
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.6
|
|
4
4
|
Summary: From/to Classification Converter
|
|
5
5
|
Author-email: The Economist <29724411+econcz@users.noreply.github.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -29,9 +29,9 @@ pip install pyconvertu
|
|
|
29
29
|
## Quick example
|
|
30
30
|
python:
|
|
31
31
|
```python
|
|
32
|
-
from convertu import
|
|
32
|
+
from convertu import cconv
|
|
33
33
|
|
|
34
|
-
print(
|
|
34
|
+
print(cconv(to="iso3", text=["Czech Republic", "Slovakia"]))
|
|
35
35
|
```
|
|
36
36
|
bash:
|
|
37
37
|
```bash
|
|
@@ -42,7 +42,7 @@ echo -e "Czech Republic\nSlovakia" | cconv -t iso3
|
|
|
42
42
|
## User Reference
|
|
43
43
|
|
|
44
44
|
```python
|
|
45
|
-
|
|
45
|
+
cconv(
|
|
46
46
|
data=[...], json_file='...', info=False, dump=False,
|
|
47
47
|
to="...", text="..." | ["...", "..."], *args, **kwargs
|
|
48
48
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|