|
3 | 3 | An abstraction layer for metadata fetchers. Supports both synchronous and asynchronous fetchers with cache.
|
4 | 4 |
|
5 | 5 | """
|
| 6 | + |
6 | 7 | from __future__ import annotations
|
7 | 8 |
|
8 | 9 | import os
|
@@ -192,7 +193,7 @@ class ResourceInfo(BaseModel):
|
192 | 193 | state: Optional[ResourceLoadState] = None
|
193 | 194 | http_headers: Dict[str, Any] = Field({})
|
194 | 195 | reason: Optional[str] = None
|
195 |
| - status_code: Optional[str] = None # HTTP status code as string. TODO: change to int |
| 196 | + status_code: Optional[str] = None # HTTP status code as string. TODO: change to int |
196 | 197 | parser_info: Optional[ParserInfo] = None
|
197 | 198 | expired: Optional[bool] = None
|
198 | 199 | exception: Optional[BaseException] = None
|
@@ -221,6 +222,7 @@ def _format_key(k: str) -> str:
|
221 | 222 |
|
222 | 223 | return res
|
223 | 224 |
|
| 225 | + |
224 | 226 | class Resource(Watchable):
|
225 | 227 | def __init__(self, url: Optional[str], opts: ResourceOpts):
|
226 | 228 | super().__init__()
|
@@ -280,7 +282,7 @@ def cleanup(self) -> Iterable[Callable]: # TODO: move classes to make this work
|
280 | 282 | def __str__(self):
|
281 | 283 | return "Resource {} expires at {} using ".format(
|
282 | 284 | self.url if self.url is not None else "(root)", self.expire_time
|
283 |
| - ) + ",".join(["{}={}".format(k, v) for k, v in sorted(list(self.opts.dict().items()))]) |
| 285 | + ) + ",".join(["{}={}".format(k, v) for k, v in sorted(list(self.opts.model_dump().items()))]) |
284 | 286 |
|
285 | 287 | def reload(self, fail_on_error=False):
|
286 | 288 | with non_blocking_lock(self.lock):
|
@@ -485,7 +487,7 @@ def parse(self, getter: Callable[[str], Response]) -> Deque[Resource]:
|
485 | 487 | info.expired = False
|
486 | 488 |
|
487 | 489 | if info.parser_info:
|
488 |
| - for (eid, error) in list(info.parser_info.validation_errors.items()): |
| 490 | + for eid, error in list(info.parser_info.validation_errors.items()): |
489 | 491 | log.error(error)
|
490 | 492 | else:
|
491 | 493 | log.debug(f'Parser did not produce anything (probably ok) when parsing {self.url} {info}')
|
|
0 commit comments