ЛР3 - БПИ2302 Федоров - на 3 #58

Open
Fedoroff wants to merge 3 commits from Fedoroff/mtusi2026lab3:solution/BPI2302-fedorov into main
2 changed files with 16 additions and 3 deletions
Showing only changes of commit 982a3a5a38 - Show all commits
+1 -1
View File
@@ -1,4 +1,4 @@
PYTHON ?= python3
PYTHON ?= py -3
BASE_URL ?= http://localhost:8080
CA_FILE ?=
ACTION_SCRIPT ?=
+15 -2
View File
@@ -29,8 +29,21 @@ def timestamp(value):
'timestamp must be UTC ending in Z'
)
try:
return dt.datetime.fromisoformat(value[:-1] + '+00:00')
except ValueError as exc:
normalized = value[:-1] + '+00:00'
if '.' in normalized:
prefix, fraction = normalized.split('.', 1)
digits, timezone = fraction.split('+', 1)
if not digits.isdigit() or len(digits) > 9:
raise ValueError('invalid fractional seconds')
digits = digits[:6].ljust(6, '0')
normalized = f'{prefix}.{digits}+{timezone}'
return dt.datetime.fromisoformat(normalized)
except (ValueError, TypeError) as exc:
raise Failure(f'invalid RFC3339 timestamp: {value!r}') from exc
def validate(value, schema, where='response'):