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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyconvertu
3
- Version: 1.0.5
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 convert
32
+ from convertu import cconv
33
33
 
34
- print(convert(to="iso3", text=["Czech Republic", "Slovakia"]))
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
- convert(
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 convert
14
+ from convertu import cconv
15
15
 
16
- print(convert(to="iso3", text=["Czech Republic", "Slovakia"]))
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
- convert(
27
+ cconv(
28
28
  data=[...], json_file='...', info=False, dump=False,
29
29
  to="...", text="..." | ["...", "..."], *args, **kwargs
30
30
  )
@@ -0,0 +1,8 @@
1
+ __version__ = "1.0.6"
2
+
3
+ from .convertu import cconv
4
+
5
+ __all__ = [
6
+ "cconv",
7
+ "__version__"
8
+ ]
@@ -2,7 +2,7 @@ from __future__ import annotations
2
2
  import signal
3
3
  import sys
4
4
  import argparse
5
- from convertu import convert, __version__
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., uconv -t iso3 'Czech Republic')."
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 = convert(json_file=args.source, info=True)
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 = convert(json_file=args.source, dump=True)
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 = convert(json_file=args.source, to=args.to, text=text_in)
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("obj must be a list[dict]")
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("obj must include at least one entry with "
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("obj must include exactly one non-empty "
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("obj must include exactly one non-empty "
69
+ raise ConvertUError("`data` must include exactly one non-empty "
70
70
  "'sources' list")
71
71
 
72
- def convert(
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.5
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 convert
32
+ from convertu import cconv
33
33
 
34
- print(convert(to="iso3", text=["Czech Republic", "Slovakia"]))
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
- convert(
45
+ cconv(
46
46
  data=[...], json_file='...', info=False, dump=False,
47
47
  to="...", text="..." | ["...", "..."], *args, **kwargs
48
48
  )
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "pyconvertu"
3
- version = "1.0.5"
3
+ version = "1.0.6"
4
4
  description = "From/to Classification Converter"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.10"
@@ -1,8 +0,0 @@
1
- __version__ = "1.0.5"
2
-
3
- from .convertu import convert
4
-
5
- __all__ = [
6
- "convert",
7
- "__version__"
8
- ]
File without changes
File without changes