aboutsummaryrefslogtreecommitdiff
path: root/importer/providers/providerbase.py
blob: 51b525e6b9a6d9f7a4bd7f7c8afc31c0d21423c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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, **kwargs):
        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)