hdx-python-utilities 4.2.6__py3-none-any.whl → 4.2.7__py3-none-any.whl
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/utilities/_version.py +2 -2
- hdx/utilities/downloader.py +8 -0
- hdx/utilities/frictionless_wrapper.py +19 -1
- hdx/utilities/text.py +1 -1
- {hdx_python_utilities-4.2.6.dist-info → hdx_python_utilities-4.2.7.dist-info}/METADATA +1 -1
- {hdx_python_utilities-4.2.6.dist-info → hdx_python_utilities-4.2.7.dist-info}/RECORD +8 -8
- {hdx_python_utilities-4.2.6.dist-info → hdx_python_utilities-4.2.7.dist-info}/WHEEL +0 -0
- {hdx_python_utilities-4.2.6.dist-info → hdx_python_utilities-4.2.7.dist-info}/licenses/LICENSE +0 -0
hdx/utilities/_version.py
CHANGED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '4.2.
|
|
22
|
-
__version_tuple__ = version_tuple = (4, 2,
|
|
21
|
+
__version__ = version = '4.2.7'
|
|
22
|
+
__version_tuple__ = version_tuple = (4, 2, 7)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
hdx/utilities/downloader.py
CHANGED
|
@@ -592,6 +592,7 @@ class Download(BaseDownload):
|
|
|
592
592
|
default_type (str | None): Default field type if infer_types False. Defaults to string.
|
|
593
593
|
float_numbers (bool): Use float not Decimal if infer_types True. Defaults to True.
|
|
594
594
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
595
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
595
596
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
596
597
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
597
598
|
layout (Layout): This can be set to override the above. See Frictionless docs.
|
|
@@ -660,6 +661,7 @@ class Download(BaseDownload):
|
|
|
660
661
|
default_type (str | None): Default field type if infer_types False. Defaults to string.
|
|
661
662
|
float_numbers (bool): Use float not Decimal if infer_types True. Defaults to True.
|
|
662
663
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
664
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
663
665
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
664
666
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
665
667
|
layout (Layout): This can be set to override the above. See Frictionless docs.
|
|
@@ -771,6 +773,7 @@ class Download(BaseDownload):
|
|
|
771
773
|
default_type (str | None): Default field type if infer_types False. Defaults to string.
|
|
772
774
|
float_numbers (bool): Use float not Decimal if infer_types True. Defaults to True.
|
|
773
775
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
776
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
774
777
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
775
778
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
776
779
|
layout (Layout): This can be set to override the above. See Frictionless docs.
|
|
@@ -868,6 +871,7 @@ class Download(BaseDownload):
|
|
|
868
871
|
default_type (str | None): Default field type if infer_types False. Defaults to string.
|
|
869
872
|
float_numbers (bool): Use float not Decimal if infer_types True. Defaults to True.
|
|
870
873
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
874
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
871
875
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
872
876
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
873
877
|
layout (Layout): This can be set to override the above. See Frictionless docs.
|
|
@@ -937,6 +941,7 @@ class Download(BaseDownload):
|
|
|
937
941
|
default_type (str | None): Default field type if infer_types False. Defaults to string.
|
|
938
942
|
float_numbers (bool): Use float not Decimal if infer_types True. Defaults to True.
|
|
939
943
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
944
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
940
945
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
941
946
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
942
947
|
layout (Layout): This can be set to override the above. See Frictionless docs.
|
|
@@ -1008,6 +1013,7 @@ class Download(BaseDownload):
|
|
|
1008
1013
|
default_type (str | None): Default field type if infer_types False. Defaults to string.
|
|
1009
1014
|
float_numbers (bool): Use float not Decimal if infer_types True. Defaults to True.
|
|
1010
1015
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
1016
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
1011
1017
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
1012
1018
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
1013
1019
|
layout (Layout): This can be set to override the above. See Frictionless docs.
|
|
@@ -1083,6 +1089,7 @@ class Download(BaseDownload):
|
|
|
1083
1089
|
default_type (str | None): Default field type if infer_types False. Defaults to string.
|
|
1084
1090
|
float_numbers (bool): Use float not Decimal if infer_types True. Defaults to True.
|
|
1085
1091
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
1092
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
1086
1093
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
1087
1094
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
1088
1095
|
layout (Layout): This can be set to override the above. See Frictionless docs.
|
|
@@ -1162,6 +1169,7 @@ class Download(BaseDownload):
|
|
|
1162
1169
|
default_type (str | None): Default field type if infer_types False. Defaults to string.
|
|
1163
1170
|
float_numbers (bool): Use float not Decimal if infer_types True. Defaults to True.
|
|
1164
1171
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
1172
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
1165
1173
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
1166
1174
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
1167
1175
|
layout (Layout): This can be set to override the above. See Frictionless docs.
|
|
@@ -14,6 +14,17 @@ from frictionless import (
|
|
|
14
14
|
from frictionless.errors import ResourceError
|
|
15
15
|
from frictionless.formats import CsvControl, ExcelControl, JsonControl
|
|
16
16
|
from frictionless.resources import TableResource
|
|
17
|
+
from frictionless.types import ISample
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class NormalisedHeaderDialect(Dialect):
|
|
21
|
+
"""Dialect that converts newlines in headers to spaces and strips them, as
|
|
22
|
+
frictionless did before 5.20."""
|
|
23
|
+
|
|
24
|
+
def read_labels(self, sample: ISample) -> list[str]:
|
|
25
|
+
return [
|
|
26
|
+
label.replace("\n", " ").strip() for label in super().read_labels(sample)
|
|
27
|
+
]
|
|
17
28
|
|
|
18
29
|
|
|
19
30
|
def get_frictionless_control(**kwargs: Any) -> tuple[Control, Any]:
|
|
@@ -106,12 +117,18 @@ def get_frictionless_dialect(
|
|
|
106
117
|
ignore_blank_rows: Whether to ignore blank rows. Defaults to True.
|
|
107
118
|
**kwargs: See below
|
|
108
119
|
columns (Sequence[int] | Sequence[str] | None): Columns to pick. Defaults to all.
|
|
120
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
109
121
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
110
122
|
|
|
111
123
|
Returns:
|
|
112
124
|
(frictionless Dialect object, Any)
|
|
113
125
|
"""
|
|
114
|
-
|
|
126
|
+
normalise_headers = kwargs.pop("normalise_headers", True)
|
|
127
|
+
if normalise_headers:
|
|
128
|
+
default_dialect = NormalisedHeaderDialect()
|
|
129
|
+
else:
|
|
130
|
+
default_dialect = Dialect()
|
|
131
|
+
dialect = kwargs.get("dialect", default_dialect)
|
|
115
132
|
columns = kwargs.pop("columns", None)
|
|
116
133
|
if columns:
|
|
117
134
|
dialect.pick_fields = columns
|
|
@@ -156,6 +173,7 @@ def get_frictionless_tableresource(
|
|
|
156
173
|
null_values (list[Any]): Values that will return None. Defaults to [""].
|
|
157
174
|
control (Control): This can be set to override the above. See Frictionless docs.
|
|
158
175
|
detector (Detector): This can be set to override the above. See Frictionless docs.
|
|
176
|
+
normalise_headers (bool): Convert newlines in headers to spaces and strip them. Ignored if dialect supplied. Defaults to True.
|
|
159
177
|
dialect (Dialect): This can be set to override the above. See Frictionless docs.
|
|
160
178
|
schema (Schema): This can be set to override the above. See Frictionless docs.
|
|
161
179
|
|
hdx/utilities/text.py
CHANGED
|
@@ -60,7 +60,7 @@ def remove_end_characters(string: str, characters_to_remove: str = punctuation)
|
|
|
60
60
|
Returns:
|
|
61
61
|
String with any characters at end of string that are in characters_to_remove removed
|
|
62
62
|
"""
|
|
63
|
-
while string[-1] in characters_to_remove:
|
|
63
|
+
while string and string[-1] in characters_to_remove:
|
|
64
64
|
string = string[:-1]
|
|
65
65
|
return string
|
|
66
66
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: hdx-python-utilities
|
|
3
|
-
Version: 4.2.
|
|
3
|
+
Version: 4.2.7
|
|
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>
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
hdx/utilities/__init__.py,sha256=DQztoBWScN4UoX3pTjA6JN_CHX-Lls3duu41YLJtdcM,72
|
|
2
|
-
hdx/utilities/_version.py,sha256=
|
|
2
|
+
hdx/utilities/_version.py,sha256=h4Ocm059KhrmW9LjVPUzFYdcMdF2OXrkmAKxCgyYAy4,520
|
|
3
3
|
hdx/utilities/base_downloader.py,sha256=FuE3CyGVOaKJaJm4bRDMstwiR65HB5JNiceDYUQBrk0,3599
|
|
4
4
|
hdx/utilities/compare.py,sha256=WOFH4Ic2ljMb2BF-UseGZAogeSC8pitRbyfo6HRt56s,1151
|
|
5
5
|
hdx/utilities/dateparse.py,sha256=RGFBuOHE2pflqAY824XLfrBUt1tyY_ieG5yJtlqZOEY,42006
|
|
6
6
|
hdx/utilities/dictandlist.py,sha256=GCpws3WzVtJg8zxQJxlZXqOeOxNMk3Dn74oq-jxDQ-g,15590
|
|
7
|
-
hdx/utilities/downloader.py,sha256=
|
|
7
|
+
hdx/utilities/downloader.py,sha256=q3-ZLciQ-_L-k58GnFJm4UHQovTn2kTdAJ0N4SyWVh0,61280
|
|
8
8
|
hdx/utilities/easy_logging.py,sha256=UizwMsYpFcKmY3x7qVPxi4cIpEyqpKQaKhby_kuFH4A,2129
|
|
9
9
|
hdx/utilities/email.py,sha256=T-56gxAxrL_HQEjVtgjgC0bSRRAQSNn9qQgaUYGzp3c,8226
|
|
10
10
|
hdx/utilities/encoding.py,sha256=_y7kdLG-AFkwIrbG-pNmsWQNbIv8GGNK8nFEpbnWSzI,2102
|
|
11
11
|
hdx/utilities/error_handler.py,sha256=1c82AJu-mnjuNaGfn9MpmU6xqaHgc-GNyIBiYOiZIpw,5938
|
|
12
12
|
hdx/utilities/errors_onexit.py,sha256=mnllrcWJt3zbfzAact-UWU-ZhymhWCZpPmMfpZCfVEU,383
|
|
13
13
|
hdx/utilities/file_hashing.py,sha256=5LMBbeJXQQMsZZGE8hdVg5n9DCi0G1PkMRqz8OBO8qw,3634
|
|
14
|
-
hdx/utilities/frictionless_wrapper.py,sha256=
|
|
14
|
+
hdx/utilities/frictionless_wrapper.py,sha256=o28-F-0uc5D5ym6kgZZpfzhsXEEITIk6NMBfsuNfFPA,9353
|
|
15
15
|
hdx/utilities/html.py,sha256=KX5m9mXbSsruzqIVg60REJMvvtd0R_pahrKUb4bGPYQ,2880
|
|
16
16
|
hdx/utilities/loader.py,sha256=_0cbraMPneahCiQCetUovwMMaHCBmPhirys9QPMiD7c,6097
|
|
17
17
|
hdx/utilities/matching.py,sha256=nlGoYHUnKulekkqtY1tVfn8mWuGdw4oWCmM2p668rpo,18249
|
|
@@ -20,12 +20,12 @@ hdx/utilities/retriever.py,sha256=8nrNwGO2zJImbdlMtfbFAUrEb0OQKnw2wUXPYvmBQWk,18
|
|
|
20
20
|
hdx/utilities/saver.py,sha256=O9QHGjqH9E4UMnDzmDPmvINCq8qGbljq4U_l9VnLfdM,8038
|
|
21
21
|
hdx/utilities/session.py,sha256=RuxZqr2jX7xZ3qUlGSH5ZInCFsSl6THOXk0bUPgFtzw,9866
|
|
22
22
|
hdx/utilities/state.py,sha256=TSZXwiZSgGCiedXsy_CCDREK-oYZ6S28vKHqzpcq61w,4057
|
|
23
|
-
hdx/utilities/text.py,sha256=
|
|
23
|
+
hdx/utilities/text.py,sha256=Z2eJWO_-dDA7WthkovthM0dgXmN0NYwU7mbn-WoUhGI,9747
|
|
24
24
|
hdx/utilities/url.py,sha256=iN4tqU7sbpXc3EXMNaQfoot8Wm98AvDKN_oKS2heuAE,4312
|
|
25
25
|
hdx/utilities/useragent.py,sha256=u1nwquIei93lLMAGqHrLs0w99qIIM1A2yUY7AOMSFy4,6862
|
|
26
26
|
hdx/utilities/uuid.py,sha256=ysPLCRnwkDYA-ifL-pYJzBigh-jm8_zjqVjcwYSZzno,573
|
|
27
27
|
hdx/utilities/zip_crc.py,sha256=qs-81dd1oX6uIfwH7DUoZaS7OngHwOb7lnogBVmtBl8,4275
|
|
28
|
-
hdx_python_utilities-4.2.
|
|
29
|
-
hdx_python_utilities-4.2.
|
|
30
|
-
hdx_python_utilities-4.2.
|
|
31
|
-
hdx_python_utilities-4.2.
|
|
28
|
+
hdx_python_utilities-4.2.7.dist-info/METADATA,sha256=FGk-B4TJ74RvmvZKtF3ILnrfas2-K5FAUvrrwxEfImI,5409
|
|
29
|
+
hdx_python_utilities-4.2.7.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
30
|
+
hdx_python_utilities-4.2.7.dist-info/licenses/LICENSE,sha256=wc-4GpMn-ODs-U_bTe1YCiPVgvcjzrpYOx2wPuyAeII,1079
|
|
31
|
+
hdx_python_utilities-4.2.7.dist-info/RECORD,,
|
|
File without changes
|
{hdx_python_utilities-4.2.6.dist-info → hdx_python_utilities-4.2.7.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|