Coverage for /home/delusionalinsanity/bbrepos/matyan/src/matyan/fetchers/base.py: 71%

# Coverage for /home/delusionalinsanity/bbrepos/matyan/src/matyan/fetchers/base.py : 71%

## 28 statements 20 run 8 missing 0 excluded

Hot-keys on this page

r m x p toggle line displays

j k next/prev highlighted chunk

0 (zero) top of page

1 (one) first highlighted chunk

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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | from typing import Dict, Type from ..config import CONFIG from ..registry import Registry __author__ = 'Artur Barseghyan' __copyright__ = '2019 Artur Barseghyan' __license__ = 'GPL-2.0-only OR LGPL-2.0-or-later' __all__ = ( 'BaseFetcher', 'FetcherRegistry', ) class FetcherRegistry(Registry): """Fetcher registry.""" REGISTRY: Dict[str, Type] = {} class BaseFetcher(metaclass=FetcherRegistry): uid: str = None instance: Type retries: int = 0 max_retries: int = 10 def __init__(self, *args, **kwargs): if not self.uid: raise NotImplementedError self.instance = self.get_instance() def get_config(self) -> Dict[str, str]: return dict(CONFIG[self.uid]) def get_instance(self) -> Type: raise NotImplementedError def fetch_issue_data(self, issue_id: str) -> Dict[str, str]: raise NotImplementedError def should_continue(self) -> bool: return self.retries < self.max_retries def register_error(self) -> None: self.retries += 1