mirror of
https://github.com/samba-team/samba.git
synced 2025-12-14 20:23:54 +03:00
python: Reformat code
Signed-off-by: Jo Sutton <josutton@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
This commit is contained in:
@@ -85,19 +85,21 @@ def nt_time_from_string(s: str) -> NtTime:
|
||||
UTC).
|
||||
"""
|
||||
try:
|
||||
if s == 'now':
|
||||
if s == "now":
|
||||
dt = datetime.datetime.now(datetime.timezone.utc)
|
||||
elif re.match(r'^\d{14}\.0Z$', s):
|
||||
elif re.match(r"^\d{14}\.0Z$", s):
|
||||
# "20230127223641.0Z"
|
||||
dt = datetime.datetime.strptime(s, '%Y%m%d%H%M%S.0Z')
|
||||
dt = datetime.datetime.strptime(s, "%Y%m%d%H%M%S.0Z")
|
||||
else:
|
||||
dt = datetime.datetime.fromisoformat(s)
|
||||
except ValueError:
|
||||
raise ValueError("Expected a date in either "
|
||||
"ISO8601 'YYYY-MM-DD HH:MM:SS' format, "
|
||||
"LDAP timestamp 'YYYYmmddHHMMSS.0Z', "
|
||||
"or the literal string 'now'. "
|
||||
f" Got '{s}'.")
|
||||
raise ValueError(
|
||||
"Expected a date in either "
|
||||
"ISO8601 'YYYY-MM-DD HH:MM:SS' format, "
|
||||
"LDAP timestamp 'YYYYmmddHHMMSS.0Z', "
|
||||
"or the literal string 'now'. "
|
||||
f" Got '{s}'."
|
||||
)
|
||||
|
||||
if dt.tzinfo is None:
|
||||
# This is a cursed timestamp with no timezone info. We have to
|
||||
|
||||
Reference in New Issue
Block a user