hdx-python-utilities 4.2.3__py3-none-any.whl → 4.2.5__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 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.3'
22
- __version_tuple__ = version_tuple = (4, 2, 3)
21
+ __version__ = version = '4.2.5'
22
+ __version_tuple__ = version_tuple = (4, 2, 5)
23
23
 
24
24
  __commit_id__ = commit_id = None
@@ -1,9 +1,7 @@
1
1
  from abc import ABC, abstractmethod
2
2
  from collections.abc import Iterator, Sequence
3
3
  from pathlib import Path
4
- from typing import Any
5
-
6
- from typing_extensions import Self
4
+ from typing import Any, Self
7
5
 
8
6
 
9
7
  class DownloadError(Exception):
@@ -3,12 +3,11 @@
3
3
  import re
4
4
  import time
5
5
  from calendar import monthrange
6
- from datetime import datetime, timedelta, timezone
6
+ from datetime import UTC, datetime, timedelta
7
7
  from io import StringIO
8
8
 
9
9
  import dateutil
10
10
  from dateutil.parser import ParserError, parserinfo
11
- from six import text_type
12
11
 
13
12
  default_sd_year = 1
14
13
  default_date_notz = datetime(
@@ -28,7 +27,7 @@ default_date = datetime(
28
27
  minute=0,
29
28
  second=0,
30
29
  microsecond=0,
31
- tzinfo=timezone.utc,
30
+ tzinfo=UTC,
32
31
  )
33
32
  default_ed_year = 9990
34
33
  default_enddate_notz = datetime(
@@ -48,7 +47,7 @@ default_enddate = datetime(
48
47
  minute=0,
49
48
  second=0,
50
49
  microsecond=0,
51
- tzinfo=timezone.utc,
50
+ tzinfo=UTC,
52
51
  )
53
52
 
54
53
  # Used https://stackoverflow.com/questions/1703546/parsing-date-time-string-with-timezone-abbreviated-name-in-python/4766400#4766400
@@ -124,7 +123,7 @@ class _timelex:
124
123
  if isinstance(instream, (bytes, bytearray)):
125
124
  instream = instream.decode()
126
125
 
127
- if isinstance(instream, text_type):
126
+ if isinstance(instream, str):
128
127
  instream = StringIO(instream)
129
128
  elif getattr(instream, "read", None) is None:
130
129
  raise TypeError(
@@ -806,7 +805,7 @@ def now_utc() -> datetime:
806
805
  Returns:
807
806
  Now with UTC timezone
808
807
  """
809
- return datetime.now(timezone.utc)
808
+ return datetime.now(UTC)
810
809
 
811
810
 
812
811
  def now_utc_notz() -> datetime:
@@ -815,7 +814,7 @@ def now_utc_notz() -> datetime:
815
814
  Returns:
816
815
  Now in UTC but with timezone removed
817
816
  """
818
- return datetime.now(timezone.utc).replace(tzinfo=None)
817
+ return datetime.now(UTC).replace(tzinfo=None)
819
818
 
820
819
 
821
820
  def parse_date_range(
@@ -960,25 +959,25 @@ def parse_date_range(
960
959
  if max_endtime:
961
960
  enddate = enddate.replace(hour=23, minute=59, second=59, microsecond=999999)
962
961
  if timezone_handling == 0:
963
- startdate = startdate.replace(tzinfo=timezone.utc)
964
- enddate = enddate.replace(tzinfo=timezone.utc)
962
+ startdate = startdate.replace(tzinfo=UTC)
963
+ enddate = enddate.replace(tzinfo=UTC)
965
964
  elif timezone_handling == 3:
966
965
  if startdate.tzinfo is None:
967
- startdate = startdate.replace(tzinfo=timezone.utc)
966
+ startdate = startdate.replace(tzinfo=UTC)
968
967
  if enddate.tzinfo is None:
969
- enddate = enddate.replace(tzinfo=timezone.utc)
968
+ enddate = enddate.replace(tzinfo=UTC)
970
969
  elif timezone_handling == 4:
971
- startdate = startdate.astimezone(timezone.utc)
972
- enddate = enddate.astimezone(timezone.utc)
970
+ startdate = startdate.astimezone(UTC)
971
+ enddate = enddate.astimezone(UTC)
973
972
  elif timezone_handling == 5:
974
973
  if startdate.tzinfo is None:
975
- startdate = startdate.replace(tzinfo=timezone.utc)
974
+ startdate = startdate.replace(tzinfo=UTC)
976
975
  else:
977
- startdate = startdate.astimezone(timezone.utc)
976
+ startdate = startdate.astimezone(UTC)
978
977
  if enddate.tzinfo is None:
979
- enddate = enddate.replace(tzinfo=timezone.utc)
978
+ enddate = enddate.replace(tzinfo=UTC)
980
979
  else:
981
- enddate = enddate.astimezone(timezone.utc)
980
+ enddate = enddate.astimezone(UTC)
982
981
  if not include_microseconds:
983
982
  startdate = startdate.replace(microsecond=0)
984
983
  enddate = enddate.replace(microsecond=0)
@@ -1093,12 +1092,12 @@ def get_timestamp_from_datetime(date: datetime) -> float:
1093
1092
  + date.microsecond / 1e6
1094
1093
  )
1095
1094
  else:
1096
- return (date - datetime(1970, 1, 1, tzinfo=timezone.utc)).total_seconds()
1095
+ return (date - datetime(1970, 1, 1, tzinfo=UTC)).total_seconds()
1097
1096
 
1098
1097
 
1099
1098
  def get_datetime_from_timestamp(
1100
1099
  timestamp: float,
1101
- timezone: datetime.tzinfo = timezone.utc,
1100
+ timezone: datetime.tzinfo = UTC,
1102
1101
  today: datetime = now_utc(),
1103
1102
  ) -> datetime:
1104
1103
  """Convert timestamp to datetime.
@@ -1151,7 +1150,7 @@ def get_quarter_start(year: int, quarter: int) -> datetime:
1151
1150
  First day of quarter
1152
1151
  """
1153
1152
  month = 3 * (quarter - 1) + 1
1154
- return datetime(year, month, 1, tzinfo=timezone.utc)
1153
+ return datetime(year, month, 1, tzinfo=UTC)
1155
1154
 
1156
1155
 
1157
1156
  def get_quarter_end(
@@ -1184,5 +1183,5 @@ def get_quarter_end(
1184
1183
  seconds = 0
1185
1184
  microseconds = 0
1186
1185
  return datetime(
1187
- year, month, 1, hours, minutes, seconds, microseconds, tzinfo=timezone.utc
1186
+ year, month, 1, hours, minutes, seconds, microseconds, tzinfo=UTC
1188
1187
  ) + timedelta(days=-1)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: hdx-python-utilities
3
- Version: 4.2.3
3
+ Version: 4.2.5
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>
@@ -18,25 +18,23 @@ Classifier: Operating System :: Unix
18
18
  Classifier: Programming Language :: Python
19
19
  Classifier: Programming Language :: Python :: 3
20
20
  Classifier: Programming Language :: Python :: 3 :: Only
21
- Classifier: Programming Language :: Python :: 3.10
22
21
  Classifier: Programming Language :: Python :: 3.11
23
22
  Classifier: Programming Language :: Python :: 3.12
24
23
  Classifier: Programming Language :: Python :: 3.13
25
24
  Classifier: Programming Language :: Python :: 3.14
26
25
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
27
- Requires-Python: >=3.10
26
+ Requires-Python: >=3.11
28
27
  Requires-Dist: frictionless>=5.19.0
29
28
  Requires-Dist: ijson>=3.5.0
30
29
  Requires-Dist: jsonlines>=4.0.0
31
30
  Requires-Dist: loguru
32
31
  Requires-Dist: openpyxl>=3.1.2
33
- Requires-Dist: python-dateutil<2.9.1,>=2.9.0
32
+ Requires-Dist: python-dateutil<3.1,>=2.9.0
34
33
  Requires-Dist: rapidfuzz
35
34
  Requires-Dist: ratelimit
36
35
  Requires-Dist: requests-file
37
36
  Requires-Dist: ruamel-yaml
38
37
  Requires-Dist: tableschema-to-template>=0.0.13
39
- Requires-Dist: typing-extensions
40
38
  Requires-Dist: xlrd>=2.0.1
41
39
  Requires-Dist: xlsx2csv==0.8.4
42
40
  Requires-Dist: xlwt>=1.3.0
@@ -1,8 +1,8 @@
1
1
  hdx/utilities/__init__.py,sha256=DQztoBWScN4UoX3pTjA6JN_CHX-Lls3duu41YLJtdcM,72
2
- hdx/utilities/_version.py,sha256=21amJoXCtnqCF82G0b3U092e2mAWEVhjbNYbWBX862A,520
3
- hdx/utilities/base_downloader.py,sha256=SzGSz57CwdmtvL2gaNAldXtfQ4uN4F5mjYkBAyq3U7M,3501
2
+ hdx/utilities/_version.py,sha256=7bhmAD-On_XHKZRDnLBnKaG2dkNHvJ2D5XVBOhtc5UA,520
3
+ hdx/utilities/base_downloader.py,sha256=jFQ0zf9FdAjNBKBieZj47Aejl0cn92jVvajuYASH394,3471
4
4
  hdx/utilities/compare.py,sha256=3w12iMELCBsR9gKXM7zyRZAf8YSeRylJwmGuLlEkAVQ,1145
5
- hdx/utilities/dateparse.py,sha256=Rlg6YM-Rt8jol-6vKy1OfLemnsx3DfRJj4dIfALUe_E,42170
5
+ hdx/utilities/dateparse.py,sha256=rs8uUSy_YnGxCqMNv8LWbaZHYmmtdAbJnzwsOenq0FE,41971
6
6
  hdx/utilities/dictandlist.py,sha256=ho760YhYUGrd4GpkDekgFJiOg2bpqOHwvjTQmQx82h0,15590
7
7
  hdx/utilities/downloader.py,sha256=nyjuzrEHELdU81gAdUQsFkujM42fHOXh4DO1UcPRBpg,59973
8
8
  hdx/utilities/easy_logging.py,sha256=UizwMsYpFcKmY3x7qVPxi4cIpEyqpKQaKhby_kuFH4A,2129
@@ -25,7 +25,7 @@ hdx/utilities/url.py,sha256=iN4tqU7sbpXc3EXMNaQfoot8Wm98AvDKN_oKS2heuAE,4312
25
25
  hdx/utilities/useragent.py,sha256=u1nwquIei93lLMAGqHrLs0w99qIIM1A2yUY7AOMSFy4,6862
26
26
  hdx/utilities/uuid.py,sha256=KUpQoo0P3RFO_n6-qdxTDxdaJMUpkTosdI0ulyk-RYA,557
27
27
  hdx/utilities/zip_crc.py,sha256=qs-81dd1oX6uIfwH7DUoZaS7OngHwOb7lnogBVmtBl8,4275
28
- hdx_python_utilities-4.2.3.dist-info/METADATA,sha256=3LCVLm7yts7CpVk_i7t_6Jg4lZJhn2haGg3Ry74CHIk,5495
29
- hdx_python_utilities-4.2.3.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
30
- hdx_python_utilities-4.2.3.dist-info/licenses/LICENSE,sha256=wc-4GpMn-ODs-U_bTe1YCiPVgvcjzrpYOx2wPuyAeII,1079
31
- hdx_python_utilities-4.2.3.dist-info/RECORD,,
28
+ hdx_python_utilities-4.2.5.dist-info/METADATA,sha256=s9GWRw2vU2DH53tDT8swq5Koo0jPEfmyssb_geF6aYc,5409
29
+ hdx_python_utilities-4.2.5.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
30
+ hdx_python_utilities-4.2.5.dist-info/licenses/LICENSE,sha256=wc-4GpMn-ODs-U_bTe1YCiPVgvcjzrpYOx2wPuyAeII,1079
31
+ hdx_python_utilities-4.2.5.dist-info/RECORD,,