mirror of
https://github.com/Steffo99/cfig.git
synced 2024-11-21 23:44:21 +00:00
✨ Allow config items cache to be cleared and refetched
This commit is contained in:
parent
d433bf486e
commit
b894ecafb4
1 changed files with 18 additions and 4 deletions
|
@ -198,10 +198,24 @@ class Configuration:
|
||||||
self.items[key] = item
|
self.items[key] = item
|
||||||
self.docs[key] = doc
|
self.docs[key] = doc
|
||||||
|
|
||||||
def fetch_all(self):
|
def fetch_all(self, clear: bool = True):
|
||||||
log.debug("Fetching now all configuration items...")
|
"""
|
||||||
for value in self.items.values():
|
Fetch all configuration values.
|
||||||
_ = value.__wrapped__
|
|
||||||
|
If values were fetched earlier, and the ``clear`` parameter is :data:`True`,
|
||||||
|
this will clear the cache and re-fetch them, possibly changing some items.
|
||||||
|
"""
|
||||||
|
|
||||||
|
if clear:
|
||||||
|
log.debug("Clearing the cached items...")
|
||||||
|
for item in self.items.values():
|
||||||
|
log.debug(f"Clearing: {item!r}")
|
||||||
|
del item.__wrapped__
|
||||||
|
|
||||||
|
log.debug("Fetching items...")
|
||||||
|
for item in self.items.values():
|
||||||
|
log.debug(f"Fetching: {item!r}")
|
||||||
|
_ = item.__wrapped__
|
||||||
|
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
|
|
Loading…
Reference in a new issue