hdx-python-utilities 3.6.7__tar.gz → 3.8.2__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.
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/.config/pre-commit-config.yaml +7 -6
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/.config/ruff.toml +0 -1
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/.github/workflows/publish.yaml +2 -1
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/.github/workflows/run-python-tests.yaml +4 -3
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/.gitignore +2 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/PKG-INFO +6 -4
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/documentation/.readthedocs.yaml +1 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/documentation/main.md +50 -17
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/documentation/pydoc-markdown.yaml +1 -1
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/pyproject.toml +17 -16
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/requirements.txt +69 -65
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/_version.py +2 -2
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/dateparse.py +18 -5
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/downloader.py +19 -0
- hdx_python_utilities-3.8.2/src/hdx/utilities/error_handler.py +185 -0
- hdx_python_utilities-3.8.2/src/hdx/utilities/errors_onexit.py +14 -0
- hdx_python_utilities-3.6.7/src/hdx/utilities/text.py → hdx_python_utilities-3.8.2/src/hdx/utilities/matching.py +137 -259
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/retriever.py +1 -1
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/saver.py +1 -1
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/session.py +1 -1
- hdx_python_utilities-3.8.2/src/hdx/utilities/text.py +269 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_dateparse.py +4 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_downloader.py +78 -2
- hdx_python_utilities-3.8.2/tests/hdx/utilities/test_error_handler.py +56 -0
- hdx_python_utilities-3.6.7/tests/hdx/utilities/test_text.py → hdx_python_utilities-3.8.2/tests/hdx/utilities/test_matching.py +179 -111
- hdx_python_utilities-3.8.2/tests/hdx/utilities/test_text.py +123 -0
- hdx_python_utilities-3.6.7/src/hdx/utilities/errors_onexit.py +0 -53
- hdx_python_utilities-3.6.7/tests/hdx/utilities/test_errors_onexit.py +0 -24
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/.config/coveragerc +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/.config/pytest.ini +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/CONTRIBUTING.md +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/LICENSE +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/README.md +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/__init__.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/base_downloader.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/compare.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/dictandlist.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/easy_logging.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/email.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/encoding.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/frictionless_wrapper.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/html.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/loader.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/path.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/state.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/typehint.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/useragent.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/src/hdx/utilities/uuid.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/compare/test_csv_processing.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/compare/test_csv_processing2.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/empty.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/hdx_config.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/hdx_config.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/hdx_email_configuration.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/hdx_email_configuration.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/json_csv.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/logging_config.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/logging_config.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/project_configuration.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/project_configuration.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/smtp_config.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/smtp_config.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/user_agent_config.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/user_agent_config2.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/user_agent_config3.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/config/user_agent_config_wrong.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/basicauth.txt +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/bearertoken.txt +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/extra_params.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/extra_params.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/extra_params_tree.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_csv_processing.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_csv_processing_blanks.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_data.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_data.xlsx +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_data1.csv/empty.txt +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_data2.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_json_processing.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_xls_processing.xls +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/downloader/test_xlsx_processing.xlsx +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/html/response.html +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/loader/empty.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/loader/empty.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/fallbacks/test.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/fallbacks/test.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/fallbacks/test.txt +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/fallbacks/test.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/retriever-test.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/test.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/test.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/test.txt +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/test.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/retriever/test_hxl.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out2.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out2.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out5.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out6.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out7.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out8.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/out8.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/pretty-false_sortkeys-false.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/pretty-false_sortkeys-false.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/pretty-false_sortkeys-true.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/pretty-false_sortkeys-true.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/pretty-true_sortkeys-false.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/pretty-true_sortkeys-false.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/pretty-true_sortkeys-true.json +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/saver/pretty-true_sortkeys-true.yaml +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/state/analysis_dates.txt +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/state/last_build_date.txt +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/fixtures/test_data.csv +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/conftest.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_compare.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_dictandlist.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_easy_logging.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_email.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_encoding.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_html.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_loader.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_path.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_retriever.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_saver.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_state.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_useragent.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/test_uuid.py +0 -0
- {hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/tests/hdx/utilities/utils.py +0 -0
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
default_language_version:
|
|
2
|
-
python: python3.
|
|
2
|
+
python: python3.12
|
|
3
3
|
repos:
|
|
4
4
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
5
|
-
rev:
|
|
5
|
+
rev: v5.0.0
|
|
6
6
|
hooks:
|
|
7
7
|
- id: trailing-whitespace
|
|
8
8
|
exclude: test_loader.py
|
|
@@ -10,7 +10,7 @@ repos:
|
|
|
10
10
|
exclude: (test_csv_processing_blanks.csv|test.txt)
|
|
11
11
|
- id: check-ast
|
|
12
12
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
13
|
-
rev: v0.
|
|
13
|
+
rev: v0.8.6
|
|
14
14
|
hooks:
|
|
15
15
|
# Run the linter.
|
|
16
16
|
- id: ruff
|
|
@@ -18,10 +18,11 @@ repos:
|
|
|
18
18
|
# Run the formatter.
|
|
19
19
|
- id: ruff-format
|
|
20
20
|
args: [--config, .config/ruff.toml]
|
|
21
|
-
- repo: https://github.com/
|
|
22
|
-
rev:
|
|
21
|
+
- repo: https://github.com/astral-sh/uv-pre-commit
|
|
22
|
+
rev: 0.5.15
|
|
23
23
|
hooks:
|
|
24
|
+
# Run the pip compile
|
|
24
25
|
- id: pip-compile
|
|
25
26
|
name: pip-compile requirements.txt
|
|
26
27
|
files: pyproject.toml
|
|
27
|
-
args: [pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt]
|
|
28
|
+
args: [ pyproject.toml, --resolver=backtracking, --all-extras, --upgrade, -q, -o, requirements.txt ]
|
{hdx_python_utilities-3.6.7 → hdx_python_utilities-3.8.2}/.github/workflows/run-python-tests.yaml
RENAMED
|
@@ -26,14 +26,15 @@ jobs:
|
|
|
26
26
|
- name: Install dependencies
|
|
27
27
|
run: |
|
|
28
28
|
python -m pip install --upgrade pip
|
|
29
|
-
|
|
29
|
+
- name: Install Hatch
|
|
30
|
+
uses: pypa/hatch@install
|
|
30
31
|
- name: Test with hatch/pytest
|
|
31
32
|
run: |
|
|
32
|
-
hatch
|
|
33
|
+
hatch test
|
|
33
34
|
- name: Check styling
|
|
34
35
|
if: always()
|
|
35
36
|
run: |
|
|
36
|
-
hatch
|
|
37
|
+
hatch fmt --check
|
|
37
38
|
- name: Publish Unit Test Results
|
|
38
39
|
uses: EnricoMi/publish-unit-test-result-action@v2
|
|
39
40
|
if: always()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: hdx-python-utilities
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.8.2
|
|
4
4
|
Summary: HDX Python Utilities for streaming tabular data, date and time handling and other helpful functions
|
|
5
5
|
Project-URL: Homepage, https://github.com/OCHA-DAP/hdx-python-utilities
|
|
6
6
|
Author-email: Michael Rans <rans@email.com>
|
|
@@ -25,17 +25,19 @@ Classifier: Programming Language :: Python :: 3.11
|
|
|
25
25
|
Classifier: Programming Language :: Python :: 3.12
|
|
26
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
27
|
Requires-Python: >=3.8
|
|
28
|
-
Requires-Dist: frictionless>=5.
|
|
28
|
+
Requires-Dist: frictionless>=5.18.0
|
|
29
29
|
Requires-Dist: ijson>=3.2.3
|
|
30
30
|
Requires-Dist: jsonlines>=4.0.0
|
|
31
31
|
Requires-Dist: loguru
|
|
32
32
|
Requires-Dist: openpyxl>=3.1.2
|
|
33
|
-
Requires-Dist:
|
|
33
|
+
Requires-Dist: pyphonetics
|
|
34
|
+
Requires-Dist: python-dateutil<2.9.1,>=2.9.0
|
|
34
35
|
Requires-Dist: ratelimit
|
|
35
36
|
Requires-Dist: requests-file
|
|
36
37
|
Requires-Dist: ruamel-yaml
|
|
37
38
|
Requires-Dist: tableschema-to-template>=0.0.13
|
|
38
39
|
Requires-Dist: xlrd>=2.0.1
|
|
40
|
+
Requires-Dist: xlsx2csv
|
|
39
41
|
Requires-Dist: xlwt>=1.3.0
|
|
40
42
|
Provides-Extra: dev
|
|
41
43
|
Requires-Dist: pre-commit; extra == 'dev'
|
|
@@ -18,6 +18,7 @@ Python developers. Note that these are not specific to HDX.
|
|
|
18
18
|
1. [State utility](#state-utility)
|
|
19
19
|
1. [Path utilities](#path-utilities)
|
|
20
20
|
1. [Text processing](#text-processing)
|
|
21
|
+
1. [Matching utilities](#matching-utilities)
|
|
21
22
|
1. [Encoding utilities](#encoding-utilities)
|
|
22
23
|
1. [Check valid UUID](#valid-uuid)
|
|
23
24
|
1. [Easy building and packaging](#easy-building-and-packaging)
|
|
@@ -31,6 +32,12 @@ The code for the library is [here](https://github.com/OCHA-DAP/hdx-python-utilit
|
|
|
31
32
|
The library has detailed API documentation which can be found in the menu at the top.
|
|
32
33
|
|
|
33
34
|
## Breaking Changes
|
|
35
|
+
From 3.8.0, multiple_replace, match_template_variables, earliest_index,
|
|
36
|
+
get_matching_text_in_strs, get_matching_text,
|
|
37
|
+
get_matching_then_nonmatching_text moved from hdx.utilities.text to
|
|
38
|
+
hdx.utilities.matching. ErrorOnExit renamed ErrorHandler with changed
|
|
39
|
+
functionality.
|
|
40
|
+
|
|
34
41
|
From 3.5.5, Python 3.7 no longer supported
|
|
35
42
|
|
|
36
43
|
From 3.3.7, improved parse_date and parse_date_range by default will attempt to parse
|
|
@@ -648,17 +655,23 @@ Then use the logger like this:
|
|
|
648
655
|
There is a class that allows collecting of errors to be logged later, typically on exit.
|
|
649
656
|
It is called ErrorsOnExit and can be used as follows:
|
|
650
657
|
|
|
651
|
-
with
|
|
658
|
+
with ErrorsHandler() as errors:
|
|
652
659
|
...
|
|
653
|
-
errors.
|
|
660
|
+
errors.add_message("MY ERROR MESSAGE")
|
|
661
|
+
errors.add_message("MY WARNING MESSAGE", "category 1", "warning")
|
|
654
662
|
...
|
|
655
|
-
errors.add("
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
`
|
|
663
|
+
errors.add("ERROR MESSAGE", "category 1", "warning")
|
|
664
|
+
errors.add("ANOTHER ERROR MESSAGE", "category 1", "warning")
|
|
665
|
+
|
|
666
|
+
The above code will collect the errors and warnings, in this case
|
|
667
|
+
"MY ERROR MESSAGE", "category 1 - ERROR MESSAGE",
|
|
668
|
+
"category 1 - ANOTHER ERROR MESSAGE" and "category 1 - MY WARNING MESSAGE".
|
|
669
|
+
On leaving the `with` block, the errors and warnings will be logged by category
|
|
670
|
+
and sorted. The code will exit with the error code 1 (ie.`sys.exit(1)` will be
|
|
671
|
+
called) if there are errors and `should_exit_on_error` is True (the default
|
|
672
|
+
for this parameter in the constructor). If there are no errors, the code will
|
|
673
|
+
not exit and execution will continue after the `with` block (ie.`sys.exit(1)`
|
|
674
|
+
will not be called).
|
|
662
675
|
|
|
663
676
|
## State utility
|
|
664
677
|
|
|
@@ -785,6 +798,9 @@ Examples:
|
|
|
785
798
|
|
|
786
799
|
a = "The quick brown fox jumped over the lazy dog. It was so fast!"
|
|
787
800
|
|
|
801
|
+
# Normalise text eg. to support name matching
|
|
802
|
+
assert normalise("£^*& ()+-[]<>?|\ Al DhaleZ'eÉ / الضالع,,..1234''#~~### ") == "al dhalezee 1234"
|
|
803
|
+
|
|
788
804
|
# Remove whitespace and punctuation from end of string
|
|
789
805
|
assert remove_end_characters('lalala,.,"') == "lalala"
|
|
790
806
|
assert remove_end_characters('lalala, .\t/,"', f"{punctuation}{whitespace}" == "lalala"
|
|
@@ -800,13 +816,35 @@ Examples:
|
|
|
800
816
|
assert remove_string("lala, 01/02/2020 ", "01/02/2020", PUNCTUATION_MINUS_BRACKETS) == "lala "
|
|
801
817
|
assert remove_string("lala,(01/02/2020) ", "01/02/2020", PUNCTUATION_MINUS_BRACKETS) == "lala,() "
|
|
802
818
|
|
|
819
|
+
# Extract words from a string sentence into a list
|
|
820
|
+
result = get_words_in_sentence("Korea (Democratic People's Republic of)")
|
|
821
|
+
assert result == ["Korea", "Democratic", "People's", "Republic", "of"]
|
|
822
|
+
|
|
823
|
+
## Matching utilities
|
|
824
|
+
|
|
825
|
+
Examples:
|
|
826
|
+
|
|
827
|
+
possible_names = ["Al Maharah", "Ad Dali", "Dhamar"]
|
|
828
|
+
phonetics = Phonetics()
|
|
829
|
+
assert phonetics.match(possible_names, "al dali") == 1
|
|
830
|
+
|
|
831
|
+
org_type_lookup = {"Donor": "433", "National NGO": "441", "Other": "443"}
|
|
832
|
+
lookup = {
|
|
833
|
+
normalise(k): v for k, v in org_type_lookup.items()
|
|
834
|
+
}
|
|
835
|
+
assert get_code_from_name("NATIONAL_NGO", lookup, [], fuzzy_match=False) == "441"
|
|
836
|
+
|
|
837
|
+
a = "The quick brown fox jumped over the lazy dog. It was so fast!"
|
|
838
|
+
|
|
803
839
|
# Replace multiple strings in a string simultaneously
|
|
804
840
|
result = multiple_replace(a, {"quick": "slow", "fast": "slow", "lazy": "busy"})
|
|
805
841
|
assert result == "The slow brown fox jumped over the busy dog. It was so slow!"
|
|
806
842
|
|
|
807
|
-
#
|
|
808
|
-
|
|
809
|
-
|
|
843
|
+
# Look for template variables in a string (ie. {{XXX}})
|
|
844
|
+
assert match_template_variables("dasdda{{abc}}gff") == ("{{abc}}", "abc")
|
|
845
|
+
|
|
846
|
+
# Search a string for each of a list of strings and return the earliest index
|
|
847
|
+
assert earliest_index(a, ["dog", "lala", "fox", "haha", "quick"]) == 4
|
|
810
848
|
|
|
811
849
|
# Find matching text in strings
|
|
812
850
|
a = "The quick brown fox jumped over the lazy dog. It was so fast!"
|
|
@@ -815,11 +853,6 @@ Examples:
|
|
|
815
853
|
result = get_matching_text([a, b, c], match_min_size=10)
|
|
816
854
|
assert result == " brown fox over the It was so fast!"
|
|
817
855
|
|
|
818
|
-
# Search a string for each of a list of strings and return the earliest index
|
|
819
|
-
assert earliest_index(a, ["dog", "lala", "fox", "haha", "quick"]) == 4
|
|
820
|
-
|
|
821
|
-
# Look for template variables in a string (ie. {{XXX}})
|
|
822
|
-
assert match_template_variables("dasdda{{abc}}gff") == ("{{abc}}", "abc")
|
|
823
856
|
|
|
824
857
|
## Encoding utilities
|
|
825
858
|
|
|
@@ -36,7 +36,7 @@ requires-python = ">=3.8"
|
|
|
36
36
|
# Extras for frictionless[excel,json] added explicitly
|
|
37
37
|
# for conda-forge compatibility
|
|
38
38
|
dependencies = [
|
|
39
|
-
"frictionless>=5.
|
|
39
|
+
"frictionless>=5.18.0",
|
|
40
40
|
# frictionless[excel]
|
|
41
41
|
"openpyxl>=3.1.2",
|
|
42
42
|
"tableschema-to-template>=0.0.13",
|
|
@@ -47,10 +47,12 @@ dependencies = [
|
|
|
47
47
|
"jsonlines>=4.0.0",
|
|
48
48
|
# /end frictionless extras
|
|
49
49
|
"loguru",
|
|
50
|
-
"
|
|
50
|
+
"pyphonetics",
|
|
51
|
+
"python-dateutil>=2.9.0, <2.9.1",
|
|
51
52
|
"ratelimit",
|
|
52
53
|
"requests-file",
|
|
53
54
|
"ruamel.yaml",
|
|
55
|
+
"xlsx2csv",
|
|
54
56
|
]
|
|
55
57
|
dynamic = ["version"]
|
|
56
58
|
|
|
@@ -91,25 +93,24 @@ version_scheme = "python-simplified-semver"
|
|
|
91
93
|
|
|
92
94
|
# Tests
|
|
93
95
|
|
|
94
|
-
[tool.hatch.envs.test]
|
|
96
|
+
[tool.hatch.envs.hatch-test]
|
|
95
97
|
features = ["html", "email", "test"]
|
|
96
98
|
|
|
97
|
-
[tool.hatch.envs.test.
|
|
98
|
-
|
|
99
|
+
[[tool.hatch.envs.hatch-test.matrix]]
|
|
100
|
+
python = ["3.12"]
|
|
101
|
+
|
|
102
|
+
[tool.hatch.envs.hatch-test.scripts]
|
|
103
|
+
run = """
|
|
99
104
|
pytest -c .config/pytest.ini --rootdir=. --junitxml=test-results.xml \
|
|
100
105
|
--cov --cov-config=.config/coveragerc --no-cov-on-fail \
|
|
101
106
|
--cov-report=lcov --cov-report=term-missing
|
|
102
107
|
"""
|
|
103
108
|
|
|
104
|
-
[
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
[tool.hatch.envs.lint]
|
|
108
|
-
detached = true
|
|
109
|
-
dependencies = ["ruff"]
|
|
109
|
+
[tool.hatch.envs.hatch-static-analysis]
|
|
110
|
+
dependencies = ["ruff==0.8.6"]
|
|
110
111
|
|
|
111
|
-
[tool.hatch.envs.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
]
|
|
112
|
+
[tool.hatch.envs.hatch-static-analysis.scripts]
|
|
113
|
+
format-check = ["ruff format --config .config/ruff.toml --check --diff {args:.}",]
|
|
114
|
+
format-fix = ["ruff format --config .config/ruff.toml {args:.}",]
|
|
115
|
+
lint-check = ["ruff check --config .config/ruff.toml {args:.}",]
|
|
116
|
+
lint-fix = ["ruff check --config .config/ruff.toml --fix {args:.}",]
|
|
@@ -1,148 +1,151 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
|
|
4
|
-
#
|
|
5
|
-
# pip-compile --all-extras --output-file=requirements.txt pyproject.toml
|
|
6
|
-
#
|
|
7
|
-
annotated-types==0.6.0
|
|
1
|
+
# This file was autogenerated by uv via the following command:
|
|
2
|
+
# uv pip compile pyproject.toml --resolver=backtracking --all-extras -o requirements.txt
|
|
3
|
+
annotated-types==0.7.0
|
|
8
4
|
# via pydantic
|
|
9
|
-
attrs==
|
|
5
|
+
attrs==24.3.0
|
|
10
6
|
# via
|
|
11
7
|
# frictionless
|
|
12
8
|
# jsonlines
|
|
13
9
|
# jsonschema
|
|
10
|
+
# referencing
|
|
14
11
|
beautifulsoup4==4.12.3
|
|
15
12
|
# via hdx-python-utilities (pyproject.toml)
|
|
16
|
-
certifi==2024.
|
|
13
|
+
certifi==2024.12.14
|
|
17
14
|
# via requests
|
|
18
15
|
cfgv==3.4.0
|
|
19
16
|
# via pre-commit
|
|
20
17
|
chardet==5.2.0
|
|
21
18
|
# via frictionless
|
|
22
|
-
charset-normalizer==3.
|
|
19
|
+
charset-normalizer==3.4.1
|
|
23
20
|
# via requests
|
|
24
|
-
click==8.1.
|
|
21
|
+
click==8.1.8
|
|
25
22
|
# via typer
|
|
26
|
-
|
|
27
|
-
# via typer
|
|
28
|
-
coverage[toml]==7.4.4
|
|
23
|
+
coverage==7.6.10
|
|
29
24
|
# via pytest-cov
|
|
30
|
-
distlib==0.3.
|
|
25
|
+
distlib==0.3.9
|
|
31
26
|
# via virtualenv
|
|
32
|
-
dnspython==2.
|
|
27
|
+
dnspython==2.7.0
|
|
33
28
|
# via email-validator
|
|
34
|
-
email-validator==2.
|
|
29
|
+
email-validator==2.2.0
|
|
35
30
|
# via hdx-python-utilities (pyproject.toml)
|
|
36
|
-
et-xmlfile==
|
|
31
|
+
et-xmlfile==2.0.0
|
|
37
32
|
# via openpyxl
|
|
38
|
-
filelock==3.
|
|
33
|
+
filelock==3.16.1
|
|
39
34
|
# via virtualenv
|
|
40
|
-
frictionless==5.
|
|
35
|
+
frictionless==5.18.0
|
|
41
36
|
# via hdx-python-utilities (pyproject.toml)
|
|
42
37
|
html5lib==1.1
|
|
43
38
|
# via hdx-python-utilities (pyproject.toml)
|
|
44
|
-
humanize==4.
|
|
39
|
+
humanize==4.11.0
|
|
45
40
|
# via frictionless
|
|
46
|
-
identify==2.5
|
|
41
|
+
identify==2.6.5
|
|
47
42
|
# via pre-commit
|
|
48
|
-
idna==3.
|
|
43
|
+
idna==3.10
|
|
49
44
|
# via
|
|
50
45
|
# email-validator
|
|
51
46
|
# requests
|
|
52
|
-
ijson==3.
|
|
47
|
+
ijson==3.3.0
|
|
53
48
|
# via hdx-python-utilities (pyproject.toml)
|
|
54
49
|
iniconfig==2.0.0
|
|
55
50
|
# via pytest
|
|
56
|
-
isodate==0.
|
|
51
|
+
isodate==0.7.2
|
|
57
52
|
# via frictionless
|
|
58
|
-
jinja2==3.1.
|
|
53
|
+
jinja2==3.1.5
|
|
59
54
|
# via frictionless
|
|
60
55
|
jsonlines==4.0.0
|
|
61
56
|
# via hdx-python-utilities (pyproject.toml)
|
|
62
|
-
jsonschema==4.
|
|
57
|
+
jsonschema==4.23.0
|
|
63
58
|
# via
|
|
64
59
|
# frictionless
|
|
65
60
|
# tableschema-to-template
|
|
66
|
-
|
|
61
|
+
jsonschema-specifications==2024.10.1
|
|
62
|
+
# via jsonschema
|
|
63
|
+
loguru==0.7.3
|
|
67
64
|
# via
|
|
68
65
|
# hdx-python-utilities (pyproject.toml)
|
|
69
66
|
# pytest-loguru
|
|
70
67
|
markdown-it-py==3.0.0
|
|
71
68
|
# via rich
|
|
72
|
-
marko==2.
|
|
69
|
+
marko==2.1.2
|
|
73
70
|
# via frictionless
|
|
74
|
-
markupsafe==
|
|
71
|
+
markupsafe==3.0.2
|
|
75
72
|
# via jinja2
|
|
76
73
|
mdurl==0.1.2
|
|
77
74
|
# via markdown-it-py
|
|
78
|
-
nodeenv==1.
|
|
75
|
+
nodeenv==1.9.1
|
|
79
76
|
# via pre-commit
|
|
80
|
-
openpyxl==3.1.
|
|
77
|
+
openpyxl==3.1.5
|
|
81
78
|
# via hdx-python-utilities (pyproject.toml)
|
|
82
|
-
packaging==24.
|
|
79
|
+
packaging==24.2
|
|
83
80
|
# via pytest
|
|
84
81
|
petl==1.7.15
|
|
85
82
|
# via frictionless
|
|
86
|
-
platformdirs==4.
|
|
83
|
+
platformdirs==4.3.6
|
|
87
84
|
# via virtualenv
|
|
88
|
-
pluggy==1.
|
|
85
|
+
pluggy==1.5.0
|
|
89
86
|
# via pytest
|
|
90
|
-
pre-commit==
|
|
87
|
+
pre-commit==4.0.1
|
|
91
88
|
# via hdx-python-utilities (pyproject.toml)
|
|
92
|
-
pydantic==2.
|
|
89
|
+
pydantic==2.10.5
|
|
93
90
|
# via frictionless
|
|
94
|
-
pydantic-core==2.
|
|
91
|
+
pydantic-core==2.27.2
|
|
95
92
|
# via pydantic
|
|
96
|
-
pygments==2.
|
|
93
|
+
pygments==2.19.1
|
|
97
94
|
# via rich
|
|
98
|
-
|
|
99
|
-
# via
|
|
100
|
-
pytest==8.
|
|
95
|
+
pyphonetics==0.5.3
|
|
96
|
+
# via hdx-python-utilities (pyproject.toml)
|
|
97
|
+
pytest==8.3.4
|
|
101
98
|
# via
|
|
102
99
|
# hdx-python-utilities (pyproject.toml)
|
|
103
100
|
# pytest-cov
|
|
104
|
-
|
|
105
|
-
pytest-cov==4.1.0
|
|
101
|
+
pytest-cov==6.0.0
|
|
106
102
|
# via hdx-python-utilities (pyproject.toml)
|
|
107
|
-
pytest-loguru==0.
|
|
103
|
+
pytest-loguru==0.4.0
|
|
108
104
|
# via hdx-python-utilities (pyproject.toml)
|
|
109
|
-
python-dateutil==2.
|
|
105
|
+
python-dateutil==2.9.0.post0
|
|
110
106
|
# via
|
|
111
|
-
# frictionless
|
|
112
107
|
# hdx-python-utilities (pyproject.toml)
|
|
108
|
+
# frictionless
|
|
113
109
|
python-slugify==8.0.4
|
|
114
110
|
# via frictionless
|
|
115
|
-
pyyaml==6.0.
|
|
111
|
+
pyyaml==6.0.2
|
|
116
112
|
# via
|
|
117
113
|
# frictionless
|
|
118
114
|
# pre-commit
|
|
119
115
|
# tableschema-to-template
|
|
120
116
|
ratelimit==2.2.1
|
|
121
117
|
# via hdx-python-utilities (pyproject.toml)
|
|
122
|
-
|
|
118
|
+
referencing==0.35.1
|
|
119
|
+
# via
|
|
120
|
+
# jsonschema
|
|
121
|
+
# jsonschema-specifications
|
|
122
|
+
requests==2.32.3
|
|
123
123
|
# via
|
|
124
124
|
# frictionless
|
|
125
125
|
# requests-file
|
|
126
|
-
requests-file==2.
|
|
126
|
+
requests-file==2.1.0
|
|
127
127
|
# via hdx-python-utilities (pyproject.toml)
|
|
128
128
|
rfc3986==2.0.0
|
|
129
129
|
# via frictionless
|
|
130
|
-
rich==13.
|
|
130
|
+
rich==13.9.4
|
|
131
131
|
# via typer
|
|
132
|
-
|
|
132
|
+
rpds-py==0.22.3
|
|
133
|
+
# via
|
|
134
|
+
# jsonschema
|
|
135
|
+
# referencing
|
|
136
|
+
ruamel-yaml==0.18.10
|
|
133
137
|
# via hdx-python-utilities (pyproject.toml)
|
|
134
|
-
ruamel-yaml-clib==0.2.
|
|
138
|
+
ruamel-yaml-clib==0.2.12
|
|
135
139
|
# via ruamel-yaml
|
|
136
140
|
shellingham==1.5.4
|
|
137
141
|
# via typer
|
|
138
|
-
simpleeval==0.
|
|
142
|
+
simpleeval==1.0.3
|
|
139
143
|
# via frictionless
|
|
140
|
-
six==1.
|
|
144
|
+
six==1.17.0
|
|
141
145
|
# via
|
|
142
146
|
# html5lib
|
|
143
|
-
# isodate
|
|
144
147
|
# python-dateutil
|
|
145
|
-
soupsieve==2.
|
|
148
|
+
soupsieve==2.6
|
|
146
149
|
# via beautifulsoup4
|
|
147
150
|
stringcase==1.2.0
|
|
148
151
|
# via frictionless
|
|
@@ -152,28 +155,29 @@ tabulate==0.9.0
|
|
|
152
155
|
# via frictionless
|
|
153
156
|
text-unidecode==1.3
|
|
154
157
|
# via python-slugify
|
|
155
|
-
typer
|
|
158
|
+
typer==0.15.1
|
|
156
159
|
# via frictionless
|
|
157
|
-
typing-extensions==4.
|
|
160
|
+
typing-extensions==4.12.2
|
|
158
161
|
# via
|
|
159
162
|
# frictionless
|
|
160
163
|
# pydantic
|
|
161
164
|
# pydantic-core
|
|
162
165
|
# typer
|
|
163
|
-
|
|
166
|
+
unidecode==1.3.8
|
|
167
|
+
# via pyphonetics
|
|
168
|
+
urllib3==2.3.0
|
|
164
169
|
# via requests
|
|
165
|
-
validators==0.
|
|
170
|
+
validators==0.34.0
|
|
166
171
|
# via frictionless
|
|
167
|
-
virtualenv==20.
|
|
172
|
+
virtualenv==20.28.1
|
|
168
173
|
# via pre-commit
|
|
169
174
|
webencodings==0.5.1
|
|
170
175
|
# via html5lib
|
|
171
176
|
xlrd==2.0.1
|
|
172
177
|
# via hdx-python-utilities (pyproject.toml)
|
|
178
|
+
xlsx2csv==0.8.4
|
|
179
|
+
# via hdx-python-utilities (pyproject.toml)
|
|
173
180
|
xlsxwriter==3.2.0
|
|
174
181
|
# via tableschema-to-template
|
|
175
182
|
xlwt==1.3.0
|
|
176
183
|
# via hdx-python-utilities (pyproject.toml)
|
|
177
|
-
|
|
178
|
-
# The following packages are considered to be unsafe in a requirements file:
|
|
179
|
-
# setuptools
|
|
@@ -177,8 +177,10 @@ class _ymd(list): # pragma: no cover
|
|
|
177
177
|
self.ystridx = len(self) - 1
|
|
178
178
|
|
|
179
179
|
def _resolve_from_stridxs(self, strids):
|
|
180
|
-
"""
|
|
181
|
-
|
|
180
|
+
"""
|
|
181
|
+
Try to resolve the identities of year/month/day elements using
|
|
182
|
+
ystridx, mstridx, and dstridx, if enough of these are specified.
|
|
183
|
+
"""
|
|
182
184
|
if len(self) == 3 and len(strids) == 2:
|
|
183
185
|
# we can back out the remaining stridx value
|
|
184
186
|
missing = [x for x in range(3) if x not in strids.values()]
|
|
@@ -301,8 +303,9 @@ class DateParser(dateutil.parser.parser): # pragma: no cover
|
|
|
301
303
|
fuzzy=False,
|
|
302
304
|
fuzzy_with_tokens=False,
|
|
303
305
|
):
|
|
304
|
-
"""
|
|
305
|
-
|
|
306
|
+
"""
|
|
307
|
+
Private method which performs the heavy lifting of parsing, called from
|
|
308
|
+
``parse()``, which passes on its ``kwargs`` to this function.
|
|
306
309
|
|
|
307
310
|
:param timestr:
|
|
308
311
|
The string to parse.
|
|
@@ -553,7 +556,8 @@ DEFAULTPARSER = DateParser(parserinfo(dayfirst=True))
|
|
|
553
556
|
def parse(
|
|
554
557
|
timestr, default=None, ignoretz=False, tzinfos=None, **kwargs
|
|
555
558
|
): # pragma: no cover
|
|
556
|
-
"""
|
|
559
|
+
"""
|
|
560
|
+
Parse the date/time string into a :class:`datetime.datetime` object.
|
|
557
561
|
|
|
558
562
|
:param timestr:
|
|
559
563
|
Any date/time string using the supported formats.
|
|
@@ -650,6 +654,15 @@ def now_utc() -> datetime:
|
|
|
650
654
|
return datetime.now(timezone.utc)
|
|
651
655
|
|
|
652
656
|
|
|
657
|
+
def now_utc_notz() -> datetime:
|
|
658
|
+
"""Return now in UTC but with timezone removed.
|
|
659
|
+
|
|
660
|
+
Returns:
|
|
661
|
+
datetime: Now in UTC but with timezone removed
|
|
662
|
+
"""
|
|
663
|
+
return datetime.now(timezone.utc).replace(tzinfo=None)
|
|
664
|
+
|
|
665
|
+
|
|
653
666
|
def parse_date_range(
|
|
654
667
|
string: str,
|
|
655
668
|
date_format: Optional[str] = None,
|