|
3 | 3 | from datetime import datetime |
4 | 4 | from distutils.util import strtobool |
5 | 5 | from itertools import chain |
6 | | -from typing import Any, Dict, Mapping, Optional |
| 6 | +from typing import Any, Dict, Mapping |
7 | 7 |
|
8 | 8 | from lxml import etree |
9 | 9 | from lxml.builder import ElementMaker |
@@ -224,9 +224,11 @@ def parse(self, resource: Resource, content: str) -> Mapping[str, Any]: |
224 | 224 | info['NextUpdate'] = next_update |
225 | 225 | resource.expire_time = iso2datetime(next_update) |
226 | 226 | elif config.respect_cache_duration: |
227 | | - now = utc_now() |
228 | | - now = now.replace(microsecond=0) |
229 | | - next_update = now + duration2timedelta(config.default_cache_duration) |
| 227 | + _duration = duration2timedelta(config.default_cache_duration) |
| 228 | + if not _duration: |
| 229 | + raise ValueError('Invalid default_cache_duration') |
| 230 | + now = utc_now().replace(microsecond=0) |
| 231 | + next_update = now + _duration |
230 | 232 | info['NextUpdate'] = next_update |
231 | 233 | resource.expire_time = next_update |
232 | 234 |
|
@@ -377,9 +379,9 @@ def entitiesdescriptor( |
377 | 379 | :param cache_duration: an XML timedelta expression, eg PT1H for 1hr |
378 | 380 | :param valid_until: a relative time eg 2w 4d 1h for 2 weeks, 4 days and 1hour from now. |
379 | 381 | :param copy: set to False to avoid making a copy of all the entities in list. This may be dangerous. |
380 | | - :param validate: set to False to skip schema validation of the resulting EntitiesDesciptor element. This is dangerous! |
381 | | - :param filter_invalid: remove invalid entitiesdescriptor elements from aggregate |
382 | | - :param nsmap: additional namespace definitions to include in top level entitiesdescriptor element |
| 382 | + :param validate: set to False to skip schema validation of the resulting EntitiesDescriptor element. This is dangerous! |
| 383 | + :param filter_invalid: remove invalid EntitiesDescriptor elements from aggregate |
| 384 | + :param nsmap: additional namespace definitions to include in top level EntitiesDescriptor element |
383 | 385 |
|
384 | 386 | Produce an EntityDescriptors set from a list of entities. Optional Name, cacheDuration and validUntil are affixed. |
385 | 387 | """ |
|
0 commit comments