objectstore-client 0.2.2__tar.gz → 0.2.3__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.
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/PKG-INFO +1 -1
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/pyproject.toml +1 -1
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/metadata.py +24 -14
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/LICENSE.md +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/README.md +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/__init__.py +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/auth.py +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/client.py +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/errors.py +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/metrics.py +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/multipart.py +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/presign.py +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/py.typed +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/scope.py +0 -0
- {objectstore_client-0.2.2 → objectstore_client-0.2.3}/src/objectstore_client/utils.py +0 -0
|
@@ -148,37 +148,47 @@ def parse_expiration(value: str) -> ExpirationPolicy | None:
|
|
|
148
148
|
|
|
149
149
|
|
|
150
150
|
def format_timedelta(delta: timedelta) -> str:
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
"""
|
|
152
|
+
Formats a duration in the wire format, such as `400d 1m 30s`.
|
|
153
|
+
|
|
154
|
+
Days are the largest unit, components that are zero are omitted, and a zero duration
|
|
155
|
+
is written as `0s`. Any sub-second remainder is truncated.
|
|
156
|
+
"""
|
|
157
|
+
minutes, seconds = divmod(delta.seconds, 60)
|
|
158
|
+
hours, minutes = divmod(minutes, 60)
|
|
159
|
+
|
|
160
|
+
components = ((delta.days, "d"), (hours, "h"), (minutes, "m"), (seconds, "s"))
|
|
161
|
+
output = " ".join(f"{value}{unit}" for value, unit in components if value)
|
|
157
162
|
|
|
158
|
-
return output
|
|
163
|
+
return output or "0s"
|
|
159
164
|
|
|
160
165
|
|
|
161
166
|
TIME_SPLIT = re.compile(r"[^\W\d_]+|\d+")
|
|
162
167
|
|
|
163
168
|
|
|
164
169
|
def parse_timedelta(delta: str) -> timedelta:
|
|
170
|
+
"""
|
|
171
|
+
Parses a duration in the wire format, such as `400d 1m 30s`.
|
|
172
|
+
|
|
173
|
+
Units are matched exactly, so anything outside the wire format raises a
|
|
174
|
+
`ValueError` rather than being mistaken for a unit it merely starts with.
|
|
175
|
+
"""
|
|
165
176
|
words = TIME_SPLIT.findall(delta)
|
|
166
177
|
seconds = 0
|
|
167
178
|
|
|
168
179
|
for num, unit in itertools_batched(words, n=2, strict=True):
|
|
169
180
|
num = int(num)
|
|
170
|
-
multiplier = 0
|
|
171
181
|
|
|
172
|
-
if unit
|
|
173
|
-
multiplier = 86400 * 7
|
|
174
|
-
elif unit.startswith("d"):
|
|
182
|
+
if unit == "d":
|
|
175
183
|
multiplier = 86400
|
|
176
|
-
elif unit
|
|
184
|
+
elif unit == "h":
|
|
177
185
|
multiplier = 3600
|
|
178
|
-
elif unit
|
|
186
|
+
elif unit == "m":
|
|
179
187
|
multiplier = 60
|
|
180
|
-
elif unit
|
|
188
|
+
elif unit == "s":
|
|
181
189
|
multiplier = 1
|
|
190
|
+
else:
|
|
191
|
+
raise ValueError(f"unknown time unit {unit!r} in duration {delta!r}")
|
|
182
192
|
|
|
183
193
|
seconds += num * multiplier
|
|
184
194
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|