Allow to run the METS command twice (correctly reinit the cache)
Refs https://redmine.teklia.com/issues/5512
I got
[11:26:57] INFO Creating element type ASIDE in target corpus c0ad8ba5-4691-4249-a055-11ede0a46aa0… __init__.py:246
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /home/users/mblanco/data/finlam/mets_import.py:38 in <module> │
│ │
│ 35 │ │ logger.error(f"Folder {path.name} not found") │
│ 36 │ │ continue │
│ 37 │ │
│ ❱ 38 │ run( │
│ 39 │ │ path=files.pop(), │
│ 40 │ │ corpus_id="c0ad8ba5-4691-4249-a055-11ede0a46aa0", # FINLAM | Fascicules de Press │
│ 41 │ │ element_id=folder_id, │
│ │
│ /home/users/mblanco/dev/arkindex/cli/arkindex_cli/commands/upload/mets/__init__.py:144 in run │
│ │
│ 141 │ │ ) │
│ 142 │ │
│ 143 │ # Setup cache next to mets file │
│ ❱ 144 │ Cache(path.parent / f"{path.stem}_cache.json") │
│ 145 │ │
│ 146 │ # Publish all elements recursively starting from root │
│ 147 │ try: │
│ │
│ /home/users/mblanco/dev/arkindex/cli/arkindex_cli/commands/upload/mets/cache.py:12 in __init__ │
│ │
│ 9 │ _instance = None # singleton │
│ 10 │ │
│ 11 │ def __init__(self, path): │
│ ❱ 12 │ │ assert Cache._instance is None, "Already called" │
│ 13 │ │ │
│ 14 │ │ self.path = path │
│ 15 │ │ if path.exists(): │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
AttributeError: type object 'Cache' has no attribute '_instance'
Exception ignored in: <function Cache.__del__ at 0x7f085c999cf0>
Traceback (most recent call last):
File "/home/users/mblanco/dev/arkindex/cli/arkindex_cli/commands/upload/mets/cache.py", line 25, in __del__
logger.info(f"Saving cache to {self.path}")
AttributeError: 'Cache' object has no attribute 'path'
when I tried to use the "mets" command twice with this script