53def maintenance(force: bool = True, debug: bool = False):
54 """perform maintenance of the cache"""
55 root_log = logging.getLogger()
56 if debug:
57 root_log.setLevel(logging.DEBUG)
58 else:
59 root_log.handlers = []
60 handler = logging.StreamHandler()
61 handler.setFormatter(logging.Formatter("%(message)s"))
62 logger.addHandler(handler)
63 logger.setLevel(logging.DEBUG)
64
65 state_t0 = CACHE.state()
66 CACHE.maintenance(force=force)
67 state_t1 = CACHE.state()
68 state_delta = state_t0 - state_t1
69 print("The cache has been reduced by:")
70 print(state_delta.report("\n- {descr}: {val}").lstrip("\n"))
71
72