|
5 | 5 | """ |
6 | 6 | from __future__ import annotations |
7 | 7 |
|
8 | | -import logging |
9 | 8 | import os |
10 | 9 | import traceback |
11 | 10 | from collections import deque |
12 | 11 | from copy import deepcopy |
13 | 12 | from datetime import datetime |
14 | 13 | from threading import Condition, Lock |
15 | | -from typing import Deque, Optional, Dict, Mapping, Any, Callable, Tuple |
16 | | -from requests.adapters import Response |
| 14 | +from typing import Any, Callable, Deque, Dict, Optional, Tuple |
| 15 | +from urllib.parse import quote as urlescape |
17 | 16 |
|
18 | 17 | import requests |
| 18 | +from requests.adapters import Response |
19 | 19 |
|
20 | 20 | from .constants import config |
21 | 21 | from .exceptions import ResourceException |
22 | 22 | from .fetch import make_fetcher |
23 | 23 | from .logs import get_log |
24 | 24 | from .parse import parse_resource |
25 | | -from urllib.parse import quote as urlescape |
26 | | - |
27 | | -from .utils import ( |
28 | | - Watchable, |
29 | | - hex_digest, |
30 | | - img_to_data, |
31 | | - non_blocking_lock, |
32 | | - url_get, |
33 | | - utc_now, |
34 | | - resource_string, |
35 | | - resource_filename, |
36 | | - safe_write, |
37 | | -) |
| 25 | +from .utils import Watchable, hex_digest, img_to_data, non_blocking_lock, resource_string, safe_write, url_get, utc_now |
38 | 26 |
|
39 | 27 | requests.packages.urllib3.disable_warnings() |
40 | 28 |
|
@@ -244,10 +232,9 @@ def walk(self): |
244 | 232 | yield cn |
245 | 233 |
|
246 | 234 | def is_expired(self) -> bool: |
247 | | - if self.never_expires: |
| 235 | + if self.never_expires or self.expire_time is None: |
248 | 236 | return False |
249 | | - now = utc_now() |
250 | | - return self.expire_time is not None and self.expire_time < now |
| 237 | + return self.expire_time < utc_now() |
251 | 238 |
|
252 | 239 | def is_valid(self) -> bool: |
253 | 240 | return not self.is_expired() and self.last_seen is not None and self.last_parser is not None |
|
0 commit comments