smith-utils 0.2.1__tar.gz → 0.3.1__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.
Files changed (31) hide show
  1. smith_utils-0.3.1/.gitignore +59 -0
  2. {smith_utils-0.2.1/src/smith_utils.egg-info → smith_utils-0.3.1}/PKG-INFO +37 -19
  3. {smith_utils-0.2.1 → smith_utils-0.3.1}/README.md +22 -4
  4. {smith_utils-0.2.1 → smith_utils-0.3.1}/pyproject.toml +17 -5
  5. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/__init__.py +13 -0
  6. smith_utils-0.3.1/src/smith_utils/crypto/__init__.py +6 -0
  7. smith_utils-0.3.1/src/smith_utils/crypto/hashes.py +26 -0
  8. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/text/__init__.py +4 -0
  9. smith_utils-0.3.1/tests/test_hashes.py +34 -0
  10. smith_utils-0.3.1/tests/test_package_exports.py +22 -0
  11. smith_utils-0.2.1/PKG-INFO +0 -114
  12. smith_utils-0.2.1/setup.cfg +0 -4
  13. smith_utils-0.2.1/src/smith_utils.egg-info/SOURCES.txt +0 -24
  14. smith_utils-0.2.1/src/smith_utils.egg-info/dependency_links.txt +0 -1
  15. smith_utils-0.2.1/src/smith_utils.egg-info/requires.txt +0 -7
  16. smith_utils-0.2.1/src/smith_utils.egg-info/top_level.txt +0 -1
  17. {smith_utils-0.2.1 → smith_utils-0.3.1}/LICENSE +0 -0
  18. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/datetime/__init__.py +0 -0
  19. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/datetime/date_utils.py +0 -0
  20. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/numeric/__init__.py +0 -0
  21. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/numeric/refinement.py +0 -0
  22. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/text/metrics.py +0 -0
  23. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/text/newlines.py +0 -0
  24. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/text/normalization.py +0 -0
  25. {smith_utils-0.2.1 → smith_utils-0.3.1}/src/smith_utils/text/unicode_char_names.py +0 -0
  26. {smith_utils-0.2.1 → smith_utils-0.3.1}/tests/test_date_utils.py +0 -0
  27. {smith_utils-0.2.1 → smith_utils-0.3.1}/tests/test_metrics.py +0 -0
  28. {smith_utils-0.2.1 → smith_utils-0.3.1}/tests/test_newlines.py +0 -0
  29. {smith_utils-0.2.1 → smith_utils-0.3.1}/tests/test_normalization.py +0 -0
  30. {smith_utils-0.2.1 → smith_utils-0.3.1}/tests/test_refinement.py +0 -0
  31. {smith_utils-0.2.1 → smith_utils-0.3.1}/tests/test_unicode_char_names.py +0 -0
@@ -0,0 +1,59 @@
1
+ # Python artifacts
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ build/
8
+ develop-eggs/
9
+ dist/
10
+ downloads/
11
+ eggs/
12
+ .eggs/
13
+ parts/
14
+ sdist/
15
+ var/
16
+ wheels/
17
+ *.egg-info/
18
+ .installed.cfg
19
+ *.egg
20
+
21
+ # Unit test / coverage reports
22
+ htmlcov/
23
+ .tox/
24
+ .nox/
25
+ .coverage
26
+ .coverage.*
27
+ .cache
28
+ nosetests.xml
29
+ coverage.xml
30
+ *.cover
31
+ *.sved
32
+ .pytest_cache/
33
+ .ruff_cache/
34
+
35
+ # Environments
36
+ .env
37
+ .venv
38
+ env/
39
+ venv/
40
+ ENV/
41
+ env.bak/
42
+ venv.bak/
43
+
44
+ # IDEs and Editors
45
+ .idea/
46
+ .vscode/
47
+ *.swp
48
+ *.swo
49
+
50
+ # Project specific
51
+ legacy/
52
+ *.log
53
+
54
+ # Documentation
55
+ docs/_build/
56
+ docs/source/generated/
57
+
58
+ # Misc
59
+ scripts/
@@ -1,7 +1,11 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: smith-utils
3
- Version: 0.2.1
3
+ Version: 0.3.1
4
4
  Summary: A utility library for data cleaning and parsing.
5
+ Project-URL: Homepage, https://github.com/yeiichi/smith-utils
6
+ Project-URL: Repository, https://github.com/yeiichi/smith-utils
7
+ Project-URL: Documentation, https://smith-utils.readthedocs.io/
8
+ Project-URL: Changelog, https://smith-utils.readthedocs.io/en/latest/changelog.html
5
9
  Author-email: Eiichi YAMAMOTO <info@yeiichi.com>
6
10
  License: MIT License
7
11
 
@@ -24,27 +28,23 @@ License: MIT License
24
28
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
29
  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26
30
  IN THE SOFTWARE.
27
-
28
- Project-URL: Homepage, https://github.com/yeiichi/smith-utils
29
- Project-URL: Repository, https://github.com/yeiichi/smith-utils
30
- Project-URL: Documentation, https://smith-utils.readthedocs.io/
31
- Project-URL: Changelog, https://smith-utils.readthedocs.io/en/latest/changelog.html
32
- Keywords: csv,deduplication,data-filtering,file-organization,filtering
31
+ License-File: LICENSE
32
+ Keywords: csv,data-filtering,deduplication,file-organization,filtering
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: License :: OSI Approved :: MIT License
33
35
  Classifier: Programming Language :: Python :: 3
34
36
  Classifier: Programming Language :: Python :: 3 :: Only
35
- Classifier: License :: OSI Approved :: MIT License
36
- Classifier: Intended Audience :: Developers
37
37
  Classifier: Topic :: Software Development :: Libraries
38
38
  Classifier: Topic :: Utilities
39
39
  Requires-Python: >=3.10
40
- Description-Content-Type: text/markdown
41
- License-File: LICENSE
40
+ Provides-Extra: dev
41
+ Requires-Dist: pytest<9,>=8; extra == 'dev'
42
42
  Provides-Extra: docs
43
- Requires-Dist: sphinx<9,>=8; extra == "docs"
44
- Requires-Dist: furo>=2024.8.6; extra == "docs"
43
+ Requires-Dist: furo>=2024.8.6; extra == 'docs'
44
+ Requires-Dist: sphinx<9,>=8; extra == 'docs'
45
45
  Provides-Extra: release
46
- Requires-Dist: python-semantic-release<10,>=9; extra == "release"
47
- Dynamic: license-file
46
+ Requires-Dist: python-semantic-release<10,>=9; extra == 'release'
47
+ Description-Content-Type: text/markdown
48
48
 
49
49
  # smith-utils
50
50
  [![PyPI version](https://img.shields.io/pypi/v/smith-utils.svg)](https://pypi.org/project/smith-utils/)
@@ -60,22 +60,31 @@ This package consolidates distributed utility functions to improve code reuse an
60
60
 
61
61
  ## Key Features
62
62
 
63
- ### 📅 Datetime Utilities (`smith_utils.datetime`)
63
+ ### Datetime Utilities (`smith_utils.datetime`)
64
64
  Robust date parsing and formatting.
65
65
  - `ensure_date`: Flexible conversion of strings, `datetime.date` objects, or `None` (returns today) into a `date` object.
66
66
  - `parse_strict_date`: Strict parsing for `YYYYMMDD` or `YYYY-MM-DD` formats, rejecting ambiguous inputs.
67
67
  - `format_ordinal`: Converts integers to ordinal strings (e.g., `1` → `"1st"`, `22` → `"22nd"`).
68
68
 
69
- ### 🔢 Numeric Refinement (`smith_utils.numeric`)
69
+ ### Numeric Refinement (`smith_utils.numeric`)
70
70
  Clean and parse messy numeric data.
71
71
  - `parse_numeric_value`: Handles custom separators, decimals, and negative formats like `(1,234.56)`.
72
72
  - `parse_currency_value`: Alias for numeric parsing, specifically for currency strings.
73
73
 
74
- ### 📝 Text Normalization & Metrics (`smith_utils.text`)
74
+ ### Text Normalization & Metrics (`smith_utils.text`)
75
75
  Standardize text and compare string similarity.
76
76
  - `normalize_text`: Unicode NFKC normalization, case folding, and whitespace handling.
77
77
  - `StringDistance`: Implementation of Damerau-Levenshtein and Jaro-Winkler algorithms for fuzzy matching.
78
+ - `analyze_pair`: Convenience function for string comparison returning a `Result`.
79
+ - `Relation` / `Result`: Relation enum and typed result for text comparisons.
78
80
  - `make_unicode_char_name_records`: Extract Unicode codepoint/name metadata from text.
81
+ - `normalize_newlines_stream`: Stream-based newline normalization to LF with newline type detection.
82
+ - `normalize_file_to_lf`: File-based newline normalization helper.
83
+
84
+ ### Crypto Hash Utilities (`smith_utils.crypto`)
85
+ Calculate SHA-256 digests for text and files.
86
+ - `get_text_digest`: Returns the SHA-256 hexadecimal digest for a text string.
87
+ - `get_file_digest`: Returns the SHA-256 hexadecimal digest for a file using streaming reads.
79
88
 
80
89
  ## Installation
81
90
 
@@ -88,8 +97,9 @@ pip install smith-utils
88
97
  ## Quick Start
89
98
 
90
99
  ```python
91
- from smith_utils import ensure_date, parse_numeric_value, normalize_text
100
+ from smith_utils import ensure_date, get_text_digest, parse_numeric_value, normalize_text
92
101
  from smith_utils import make_unicode_char_name_records
102
+ from smith_utils import get_file_digest, normalize_file_to_lf
93
103
 
94
104
  # Datetime
95
105
  date = ensure_date("20231225") # datetime.date(2023, 12, 25)
@@ -103,6 +113,14 @@ clean_text = normalize_text(" Smith Utils ") # "smith uti
103
113
  # Unicode metadata
104
114
  records = make_unicode_char_name_records("Aあ")
105
115
  # [UnicodeCharNameRecord(index=0, codepoint='U+0041', ...), ...]
116
+
117
+ # Normalize a file's newlines to LF
118
+ summary = normalize_file_to_lf("input.txt", "output.txt")
119
+ # {'newline_type': 'CRLF', 'bytes_in': ..., 'bytes_out': ...}
120
+
121
+ # SHA-256 digests
122
+ text_digest = get_text_digest("smith-utils")
123
+ file_digest = get_file_digest("input.txt")
106
124
  ```
107
125
 
108
126
  ## Directory Structure
@@ -12,22 +12,31 @@ This package consolidates distributed utility functions to improve code reuse an
12
12
 
13
13
  ## Key Features
14
14
 
15
- ### 📅 Datetime Utilities (`smith_utils.datetime`)
15
+ ### Datetime Utilities (`smith_utils.datetime`)
16
16
  Robust date parsing and formatting.
17
17
  - `ensure_date`: Flexible conversion of strings, `datetime.date` objects, or `None` (returns today) into a `date` object.
18
18
  - `parse_strict_date`: Strict parsing for `YYYYMMDD` or `YYYY-MM-DD` formats, rejecting ambiguous inputs.
19
19
  - `format_ordinal`: Converts integers to ordinal strings (e.g., `1` → `"1st"`, `22` → `"22nd"`).
20
20
 
21
- ### 🔢 Numeric Refinement (`smith_utils.numeric`)
21
+ ### Numeric Refinement (`smith_utils.numeric`)
22
22
  Clean and parse messy numeric data.
23
23
  - `parse_numeric_value`: Handles custom separators, decimals, and negative formats like `(1,234.56)`.
24
24
  - `parse_currency_value`: Alias for numeric parsing, specifically for currency strings.
25
25
 
26
- ### 📝 Text Normalization & Metrics (`smith_utils.text`)
26
+ ### Text Normalization & Metrics (`smith_utils.text`)
27
27
  Standardize text and compare string similarity.
28
28
  - `normalize_text`: Unicode NFKC normalization, case folding, and whitespace handling.
29
29
  - `StringDistance`: Implementation of Damerau-Levenshtein and Jaro-Winkler algorithms for fuzzy matching.
30
+ - `analyze_pair`: Convenience function for string comparison returning a `Result`.
31
+ - `Relation` / `Result`: Relation enum and typed result for text comparisons.
30
32
  - `make_unicode_char_name_records`: Extract Unicode codepoint/name metadata from text.
33
+ - `normalize_newlines_stream`: Stream-based newline normalization to LF with newline type detection.
34
+ - `normalize_file_to_lf`: File-based newline normalization helper.
35
+
36
+ ### Crypto Hash Utilities (`smith_utils.crypto`)
37
+ Calculate SHA-256 digests for text and files.
38
+ - `get_text_digest`: Returns the SHA-256 hexadecimal digest for a text string.
39
+ - `get_file_digest`: Returns the SHA-256 hexadecimal digest for a file using streaming reads.
31
40
 
32
41
  ## Installation
33
42
 
@@ -40,8 +49,9 @@ pip install smith-utils
40
49
  ## Quick Start
41
50
 
42
51
  ```python
43
- from smith_utils import ensure_date, parse_numeric_value, normalize_text
52
+ from smith_utils import ensure_date, get_text_digest, parse_numeric_value, normalize_text
44
53
  from smith_utils import make_unicode_char_name_records
54
+ from smith_utils import get_file_digest, normalize_file_to_lf
45
55
 
46
56
  # Datetime
47
57
  date = ensure_date("20231225") # datetime.date(2023, 12, 25)
@@ -55,6 +65,14 @@ clean_text = normalize_text(" Smith Utils ") # "smith uti
55
65
  # Unicode metadata
56
66
  records = make_unicode_char_name_records("Aあ")
57
67
  # [UnicodeCharNameRecord(index=0, codepoint='U+0041', ...), ...]
68
+
69
+ # Normalize a file's newlines to LF
70
+ summary = normalize_file_to_lf("input.txt", "output.txt")
71
+ # {'newline_type': 'CRLF', 'bytes_in': ..., 'bytes_out': ...}
72
+
73
+ # SHA-256 digests
74
+ text_digest = get_text_digest("smith-utils")
75
+ file_digest = get_file_digest("input.txt")
58
76
  ```
59
77
 
60
78
  ## Directory Structure
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["setuptools>=68.0", "wheel"]
3
- build-backend = "setuptools.build_meta"
2
+ requires = ["hatchling>=1.27"]
3
+ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "smith-utils"
7
- version = "0.2.1"
7
+ version = "0.3.1"
8
8
  description = "A utility library for data cleaning and parsing."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -34,6 +34,9 @@ classifiers = [
34
34
  dependencies = []
35
35
 
36
36
  [project.optional-dependencies]
37
+ dev = [
38
+ "pytest>=8,<9",
39
+ ]
37
40
  docs = [
38
41
  "sphinx>=8,<9",
39
42
  "furo>=2024.8.6",
@@ -48,8 +51,17 @@ Repository = "https://github.com/yeiichi/smith-utils"
48
51
  Documentation = "https://smith-utils.readthedocs.io/"
49
52
  Changelog = "https://smith-utils.readthedocs.io/en/latest/changelog.html"
50
53
 
51
- [tool.setuptools.packages.find]
52
- where = ["src"]
54
+ [tool.hatch.build.targets.wheel]
55
+ packages = ["src/smith_utils"]
56
+
57
+ [tool.hatch.build.targets.sdist]
58
+ include = [
59
+ "src/smith_utils",
60
+ "tests",
61
+ "README.md",
62
+ "LICENSE",
63
+ "pyproject.toml",
64
+ ]
53
65
 
54
66
  [tool.semantic_release]
55
67
  allow_zero_version = true
@@ -1,20 +1,33 @@
1
+ from .crypto import get_file_digest, get_text_digest
1
2
  from .datetime import ensure_date, format_ordinal, parse_strict_date
2
3
  from .numeric import parse_currency_value, parse_numeric_value
3
4
  from .text import (
5
+ NewlineType,
6
+ Relation,
7
+ Result,
4
8
  StringDistance,
5
9
  UnicodeCharNameRecord,
6
10
  analyze_pair,
7
11
  make_unicode_char_name_records,
12
+ normalize_file_to_lf,
13
+ normalize_newlines_stream,
8
14
  normalize_text,
9
15
  )
10
16
 
11
17
  __all__ = [
18
+ "NewlineType",
19
+ "Relation",
20
+ "Result",
12
21
  "StringDistance",
13
22
  "UnicodeCharNameRecord",
14
23
  "analyze_pair",
15
24
  "ensure_date",
16
25
  "format_ordinal",
26
+ "get_file_digest",
27
+ "get_text_digest",
17
28
  "make_unicode_char_name_records",
29
+ "normalize_file_to_lf",
30
+ "normalize_newlines_stream",
18
31
  "normalize_text",
19
32
  "parse_currency_value",
20
33
  "parse_numeric_value",
@@ -0,0 +1,6 @@
1
+ from .hashes import get_file_digest, get_text_digest
2
+
3
+ __all__ = [
4
+ "get_file_digest",
5
+ "get_text_digest",
6
+ ]
@@ -0,0 +1,26 @@
1
+ """Utilities for calculating SHA-256 digests."""
2
+
3
+ import hashlib
4
+ import sys
5
+ from pathlib import Path
6
+
7
+
8
+ def get_text_digest(text, encoding="utf-8"):
9
+ """Return the SHA-256 hexadecimal digest for ``text`` encoded as ``encoding``."""
10
+
11
+ return hashlib.sha256(text.encode(encoding)).hexdigest()
12
+
13
+
14
+ def get_file_digest(file_path):
15
+ """Return the SHA-256 hexadecimal digest for the file at ``file_path``."""
16
+
17
+ file_path = Path(file_path)
18
+ if sys.version_info >= (3, 11):
19
+ with open(file_path, "rb") as file:
20
+ return hashlib.file_digest(file, "sha256").hexdigest()
21
+
22
+ hasher = hashlib.sha256()
23
+ with open(file_path, "rb") as file:
24
+ while chunk := file.read(65536):
25
+ hasher.update(chunk)
26
+ return hasher.hexdigest()
@@ -1,8 +1,12 @@
1
1
  from .metrics import StringDistance, analyze_pair, Result, Relation
2
+ from .newlines import NewlineType, normalize_file_to_lf, normalize_newlines_stream
2
3
  from .normalization import normalize_text
3
4
  from .unicode_char_names import UnicodeCharNameRecord, make_unicode_char_name_records
4
5
 
5
6
  __all__ = [
7
+ "NewlineType",
8
+ "normalize_file_to_lf",
9
+ "normalize_newlines_stream",
6
10
  "StringDistance",
7
11
  "analyze_pair",
8
12
  "Result",
@@ -0,0 +1,34 @@
1
+ import hashlib
2
+
3
+ from src.smith_utils import crypto
4
+ from src.smith_utils.crypto import hashes
5
+ from src.smith_utils.crypto import get_file_digest, get_text_digest
6
+
7
+
8
+ def test_get_file_digest_returns_sha256_hexdigest(tmp_path):
9
+ sample_file = tmp_path / "sample.txt"
10
+ content = b"smith-utils\n"
11
+ sample_file.write_bytes(content)
12
+
13
+ assert get_file_digest(sample_file) == hashlib.sha256(content).hexdigest()
14
+
15
+
16
+ def test_get_text_digest_returns_sha256_hexdigest():
17
+ text = "smith-utils\n"
18
+
19
+ assert get_text_digest(text) == hashlib.sha256(text.encode("utf-8")).hexdigest()
20
+
21
+
22
+ def test_get_text_digest_handles_unicode_text():
23
+ text = "こんにちは smith-utils"
24
+
25
+ assert get_text_digest(text) == hashlib.sha256(text.encode("utf-8")).hexdigest()
26
+
27
+
28
+ def test_crypto_package_exports_hash_functions():
29
+ assert "get_file_digest" in crypto.__all__
30
+ assert "get_text_digest" in crypto.__all__
31
+ assert crypto.get_file_digest is get_file_digest
32
+ assert crypto.get_text_digest is get_text_digest
33
+ assert hashes.get_file_digest is get_file_digest
34
+ assert hashes.get_text_digest is get_text_digest
@@ -0,0 +1,22 @@
1
+ from src import smith_utils
2
+
3
+
4
+ def test_exports_are_available_globally():
5
+ expected = {
6
+ "get_file_digest",
7
+ "get_text_digest",
8
+ "NewlineType",
9
+ "normalize_file_to_lf",
10
+ "normalize_newlines_stream",
11
+ "StringDistance",
12
+ "analyze_pair",
13
+ "Result",
14
+ "Relation",
15
+ "normalize_text",
16
+ "UnicodeCharNameRecord",
17
+ "make_unicode_char_name_records",
18
+ }
19
+
20
+ for name in expected:
21
+ assert hasattr(smith_utils, name), f"missing export: {name}"
22
+ assert name in smith_utils.__all__
@@ -1,114 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: smith-utils
3
- Version: 0.2.1
4
- Summary: A utility library for data cleaning and parsing.
5
- Author-email: Eiichi YAMAMOTO <info@yeiichi.com>
6
- License: MIT License
7
-
8
- Copyright (c) 2026 Eiichi YAMAMOTO
9
-
10
- Permission is hereby granted, free of charge, to any person obtaining a copy
11
- of this software and associated documentation files (the "Software"), to deal
12
- in the Software without restriction, including without limitation the rights
13
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
- copies of the Software, and to permit persons to whom the Software is
15
- furnished to do so, subject to the following conditions:
16
-
17
- The above copyright notice and this permission notice shall be included in
18
- all copies or substantial portions of the Software.
19
-
20
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25
- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26
- IN THE SOFTWARE.
27
-
28
- Project-URL: Homepage, https://github.com/yeiichi/smith-utils
29
- Project-URL: Repository, https://github.com/yeiichi/smith-utils
30
- Project-URL: Documentation, https://smith-utils.readthedocs.io/
31
- Project-URL: Changelog, https://smith-utils.readthedocs.io/en/latest/changelog.html
32
- Keywords: csv,deduplication,data-filtering,file-organization,filtering
33
- Classifier: Programming Language :: Python :: 3
34
- Classifier: Programming Language :: Python :: 3 :: Only
35
- Classifier: License :: OSI Approved :: MIT License
36
- Classifier: Intended Audience :: Developers
37
- Classifier: Topic :: Software Development :: Libraries
38
- Classifier: Topic :: Utilities
39
- Requires-Python: >=3.10
40
- Description-Content-Type: text/markdown
41
- License-File: LICENSE
42
- Provides-Extra: docs
43
- Requires-Dist: sphinx<9,>=8; extra == "docs"
44
- Requires-Dist: furo>=2024.8.6; extra == "docs"
45
- Provides-Extra: release
46
- Requires-Dist: python-semantic-release<10,>=9; extra == "release"
47
- Dynamic: license-file
48
-
49
- # smith-utils
50
- [![PyPI version](https://img.shields.io/pypi/v/smith-utils.svg)](https://pypi.org/project/smith-utils/)
51
- ![Python versions](https://img.shields.io/pypi/pyversions/smith-utils.svg)
52
- ![Status](https://img.shields.io/badge/status-Alpha-orange.svg)
53
- ![License](https://img.shields.io/badge/license-MIT-blue.svg)
54
- ![Tests](https://img.shields.io/badge/tests-passing-brightgreen.svg)
55
- [![Documentation Status](https://readthedocs.org/projects/smith-utils/badge/?version=latest)](https://smith-utils.readthedocs.io/en/latest/?badge=latest)
56
-
57
-
58
- **Smith Utils** is a central hub for data cleaning and parsing scripts.
59
- This package consolidates distributed utility functions to improve code reuse and maintenance efficiency across all yeiichi projects.
60
-
61
- ## Key Features
62
-
63
- ### 📅 Datetime Utilities (`smith_utils.datetime`)
64
- Robust date parsing and formatting.
65
- - `ensure_date`: Flexible conversion of strings, `datetime.date` objects, or `None` (returns today) into a `date` object.
66
- - `parse_strict_date`: Strict parsing for `YYYYMMDD` or `YYYY-MM-DD` formats, rejecting ambiguous inputs.
67
- - `format_ordinal`: Converts integers to ordinal strings (e.g., `1` → `"1st"`, `22` → `"22nd"`).
68
-
69
- ### 🔢 Numeric Refinement (`smith_utils.numeric`)
70
- Clean and parse messy numeric data.
71
- - `parse_numeric_value`: Handles custom separators, decimals, and negative formats like `(1,234.56)`.
72
- - `parse_currency_value`: Alias for numeric parsing, specifically for currency strings.
73
-
74
- ### 📝 Text Normalization & Metrics (`smith_utils.text`)
75
- Standardize text and compare string similarity.
76
- - `normalize_text`: Unicode NFKC normalization, case folding, and whitespace handling.
77
- - `StringDistance`: Implementation of Damerau-Levenshtein and Jaro-Winkler algorithms for fuzzy matching.
78
- - `make_unicode_char_name_records`: Extract Unicode codepoint/name metadata from text.
79
-
80
- ## Installation
81
-
82
- Install via pip:
83
-
84
- ```bash
85
- pip install smith-utils
86
- ```
87
-
88
- ## Quick Start
89
-
90
- ```python
91
- from smith_utils import ensure_date, parse_numeric_value, normalize_text
92
- from smith_utils import make_unicode_char_name_records
93
-
94
- # Datetime
95
- date = ensure_date("20231225") # datetime.date(2023, 12, 25)
96
-
97
- # Numeric
98
- value = parse_numeric_value("(1,250.50)") # -1250.5
99
-
100
- # Text
101
- clean_text = normalize_text(" Smith Utils ") # "smith utils"
102
-
103
- # Unicode metadata
104
- records = make_unicode_char_name_records("Aあ")
105
- # [UnicodeCharNameRecord(index=0, codepoint='U+0041', ...), ...]
106
- ```
107
-
108
- ## Directory Structure
109
- - `src/smith_utils/`: Main package source.
110
- - `legacy/`: Legacy scripts and templates (not included in distribution).
111
- - `tests/`: Comprehensive test suite.
112
-
113
- ## License
114
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,24 +0,0 @@
1
- LICENSE
2
- README.md
3
- pyproject.toml
4
- src/smith_utils/__init__.py
5
- src/smith_utils.egg-info/PKG-INFO
6
- src/smith_utils.egg-info/SOURCES.txt
7
- src/smith_utils.egg-info/dependency_links.txt
8
- src/smith_utils.egg-info/requires.txt
9
- src/smith_utils.egg-info/top_level.txt
10
- src/smith_utils/datetime/__init__.py
11
- src/smith_utils/datetime/date_utils.py
12
- src/smith_utils/numeric/__init__.py
13
- src/smith_utils/numeric/refinement.py
14
- src/smith_utils/text/__init__.py
15
- src/smith_utils/text/metrics.py
16
- src/smith_utils/text/newlines.py
17
- src/smith_utils/text/normalization.py
18
- src/smith_utils/text/unicode_char_names.py
19
- tests/test_date_utils.py
20
- tests/test_metrics.py
21
- tests/test_newlines.py
22
- tests/test_normalization.py
23
- tests/test_refinement.py
24
- tests/test_unicode_char_names.py
@@ -1,7 +0,0 @@
1
-
2
- [docs]
3
- sphinx<9,>=8
4
- furo>=2024.8.6
5
-
6
- [release]
7
- python-semantic-release<10,>=9
@@ -1 +0,0 @@
1
- smith_utils
File without changes