durationpy 0.9__tar.gz → 0.11__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,10 +1,17 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: durationpy
3
- Version: 0.9
3
+ Version: 0.11
4
4
  Summary: Module for converting between datetime.timedelta and Go's Duration strings.
5
5
  Home-page: https://github.com/icholy/durationpy
6
- Download-URL: https://github.com/icholy/durationpy/tarball/0.9
6
+ Download-URL: https://github.com/icholy/durationpy/tarball/0.11
7
7
  Author: Ilia Choly
8
8
  Author-email: ilia.choly@gmail.com
9
9
  License: MIT
10
10
  License-File: LICENSE
11
+ Dynamic: author
12
+ Dynamic: author-email
13
+ Dynamic: download-url
14
+ Dynamic: home-page
15
+ Dynamic: license
16
+ Dynamic: license-file
17
+ Dynamic: summary
@@ -17,6 +17,10 @@ $ pip install durationpy
17
17
  * `s` - second
18
18
  * `m` - minute
19
19
  * `h` - hour
20
+ * `d` - day
21
+ * `w` - week
22
+ * `mm` - month
23
+ * `y` - year
20
24
 
21
25
  ``` py
22
26
  # parse
@@ -0,0 +1,6 @@
1
+ import datetime
2
+
3
+ def from_str(duration: str) -> datetime.timedelta: ...
4
+ def to_str(delta: datetime.timedelta, extended: bool = ...) -> str: ...
5
+
6
+ class DurationError(ValueError): ...
@@ -70,7 +70,15 @@ def from_str(duration):
70
70
  "Invalid value {} in duration {}".format(value, original))
71
71
 
72
72
  microseconds = total / _microsecond_size
73
- return datetime.timedelta(microseconds=sign * microseconds)
73
+ try:
74
+ return datetime.timedelta(microseconds=sign * microseconds)
75
+ except (OverflowError, ValueError) as e:
76
+ # A huge value overflows timedelta's day count, and a value large enough
77
+ # to become float inf makes timedelta reject it too. Report either as a
78
+ # DurationError instead of leaking the raw exception.
79
+ raise DurationError(
80
+ "Duration out of range: {}".format(original)
81
+ ) from e
74
82
 
75
83
  def to_str(delta, extended=False):
76
84
  """Format a datetime.timedelta to a duration string"""
File without changes
@@ -1,10 +1,17 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: durationpy
3
- Version: 0.9
3
+ Version: 0.11
4
4
  Summary: Module for converting between datetime.timedelta and Go's Duration strings.
5
5
  Home-page: https://github.com/icholy/durationpy
6
- Download-URL: https://github.com/icholy/durationpy/tarball/0.9
6
+ Download-URL: https://github.com/icholy/durationpy/tarball/0.11
7
7
  Author: Ilia Choly
8
8
  Author-email: ilia.choly@gmail.com
9
9
  License: MIT
10
10
  License-File: LICENSE
11
+ Dynamic: author
12
+ Dynamic: author-email
13
+ Dynamic: download-url
14
+ Dynamic: home-page
15
+ Dynamic: license
16
+ Dynamic: license-file
17
+ Dynamic: summary
@@ -3,7 +3,9 @@ README.md
3
3
  setup.cfg
4
4
  setup.py
5
5
  durationpy/__init__.py
6
+ durationpy/__init__.pyi
6
7
  durationpy/duration.py
8
+ durationpy/py.typed
7
9
  durationpy.egg-info/PKG-INFO
8
10
  durationpy.egg-info/SOURCES.txt
9
11
  durationpy.egg-info/dependency_links.txt
@@ -6,8 +6,9 @@ setup(
6
6
  url = 'https://github.com/icholy/durationpy',
7
7
  author = 'Ilia Choly',
8
8
  author_email = 'ilia.choly@gmail.com',
9
- download_url = 'https://github.com/icholy/durationpy/tarball/0.9',
10
- version = '0.9',
9
+ download_url = 'https://github.com/icholy/durationpy/tarball/0.11',
10
+ version = '0.11',
11
11
  packages = ['durationpy'],
12
+ package_data = {'durationpy': ['py.typed', '*.pyi']},
12
13
  license = 'MIT'
13
14
  )
File without changes
File without changes