[dt] replace 'datetime' imports
This commit is contained in:
@@ -19,7 +19,6 @@ import getpass
|
||||
import logging
|
||||
import requests
|
||||
import threading
|
||||
from datetime import datetime
|
||||
from xml.etree import ElementTree
|
||||
from requests.adapters import HTTPAdapter
|
||||
from .message import Message
|
||||
@@ -313,7 +312,7 @@ class Extractor():
|
||||
seconds = float(seconds)
|
||||
until = now + seconds
|
||||
elif until:
|
||||
if isinstance(until, datetime):
|
||||
if isinstance(until, dt.datetime):
|
||||
# convert to UTC timestamp
|
||||
until = dt.to_ts(until)
|
||||
else:
|
||||
@@ -327,7 +326,7 @@ class Extractor():
|
||||
return
|
||||
|
||||
if reason:
|
||||
t = datetime.fromtimestamp(until).time()
|
||||
t = dt.datetime.fromtimestamp(until).time()
|
||||
isotime = f"{t.hour:02}:{t.minute:02}:{t.second:02}"
|
||||
self.log.info("Waiting until %s (%s)", isotime, reason)
|
||||
time.sleep(seconds)
|
||||
@@ -652,7 +651,7 @@ class Extractor():
|
||||
self.log.warning(
|
||||
"cookies: %s/%s expired at %s",
|
||||
cookie.domain.lstrip("."), cookie.name,
|
||||
datetime.fromtimestamp(cookie.expires))
|
||||
dt.datetime.fromtimestamp(cookie.expires))
|
||||
continue
|
||||
|
||||
elif diff <= 86400:
|
||||
@@ -694,7 +693,7 @@ class Extractor():
|
||||
ts = self.config(key, default)
|
||||
if isinstance(ts, str):
|
||||
try:
|
||||
ts = int(datetime.strptime(ts, fmt).timestamp())
|
||||
ts = int(dt.parse(ts, fmt).timestamp())
|
||||
except ValueError as exc:
|
||||
self.log.warning("Unable to parse '%s': %s", key, exc)
|
||||
ts = default
|
||||
|
||||
Reference in New Issue
Block a user