aboutsummaryrefslogtreecommitdiff
path: root/importer/providers/providerbase.py
blob: 374b9af5220446d23b63d9b6c64632344061d462 (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):
        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)