import os from typing import List class ProviderBase: paths: List[str] downloaded: bool regex: str _TEST = [{ "url": "https://i.imgur.com/fXLMjfp.jpg", "paths": ["source_fXLMjfp.jpg"], }] def __init__(self, url: str): self.url = url self.paths = [] self.downloaded = False def download(self): pass def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): if self.paths: for path in self.paths: if os.path.exists(path): os.unlink(path)