-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add meta function to clear caches (#57)
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Meta-functions to be applied module-wide. | ||
""" | ||
|
||
try: | ||
from charset_normalizer.cd import encoding_languages | ||
from charset_normalizer.md import is_suspiciously_successive_range | ||
from charset_normalizer.utils import is_accentuated | ||
# prevent possible changes in function names | ||
except ImportError: | ||
pass | ||
|
||
from .core import compare_reference | ||
from .extractors import try_date_expr | ||
from .settings import MAX_FILE_SIZE, MIN_FILE_SIZE | ||
from .validators import date_validator, filter_ymd_candidate | ||
|
||
|
||
def reset_caches() -> None: | ||
"""Reset all known LRU caches used to speed-up processing. | ||
This may release some memory.""" | ||
# htmldate | ||
compare_reference.cache_clear() | ||
date_validator.cache_clear() | ||
filter_ymd_candidate.cache_clear() | ||
try_date_expr.cache_clear() | ||
# charset_normalizer | ||
try: | ||
encoding_languages.cache_clear() | ||
is_suspiciously_successive_range.cache_clear() | ||
is_accentuated.cache_clear() | ||
# prevent possible changes in function names | ||
except NameError: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters