diff --git a/chains/bareket.py b/chains/bareket.py index 3d8d066..c20590d 100644 --- a/chains/bareket.py +++ b/chains/bareket.py @@ -1,5 +1,6 @@ from chains.mahsaneiHashook import MahsaneiHashook +from supermarket_chain import SupermarketChain -class Bareket(MahsaneiHashook): +class Bareket(MahsaneiHashook, SupermarketChain): pass diff --git a/chains/cerberus_web_client.py b/chains/cerberus_web_client.py index 47c7670..24cedf3 100644 --- a/chains/cerberus_web_client.py +++ b/chains/cerberus_web_client.py @@ -26,6 +26,5 @@ class CerberusWebClient: return download_url @property - @abstractmethod def username(self): - pass + return repr(type(self)) diff --git a/chains/co_op.py b/chains/co_op.py index d03d972..429fc6e 100644 --- a/chains/co_op.py +++ b/chains/co_op.py @@ -1,5 +1,6 @@ from chains.mahsaneiHashook import MahsaneiHashook +from supermarket_chain import SupermarketChain -class CoOp(MahsaneiHashook): +class CoOp(MahsaneiHashook, SupermarketChain): pass diff --git a/chains/dor_alon.py b/chains/dor_alon.py index b175509..171fa31 100644 --- a/chains/dor_alon.py +++ b/chains/dor_alon.py @@ -4,8 +4,3 @@ from supermarket_chain import SupermarketChain class DorAlon(CerberusWebClient, SupermarketChain): _date_hour_format = '%Y-%m-%d %H:%M:%S' - _class_name = 'DorAlon' - - @property - def username(self): - return self._class_name diff --git a/chains/freshmarket.py b/chains/freshmarket.py index dcfbdad..cab96c3 100644 --- a/chains/freshmarket.py +++ b/chains/freshmarket.py @@ -4,8 +4,3 @@ from supermarket_chain import SupermarketChain class Freshmarket(CerberusWebClient, SupermarketChain): _date_hour_format = '%Y-%m-%d %H:%M:%S' - _class_name = 'Freshmarket' - - @property - def username(self): - return self._class_name diff --git a/chains/hazi_hinam.py b/chains/hazi_hinam.py index bacedff..e4a8731 100644 --- a/chains/hazi_hinam.py +++ b/chains/hazi_hinam.py @@ -4,8 +4,3 @@ from supermarket_chain import SupermarketChain class HaziHinam(CerberusWebClient, SupermarketChain): _date_hour_format = '%Y-%m-%d %H:%M:%S' - _class_name = 'HaziHinam' - - @property - def username(self): - return self._class_name diff --git a/chains/keshet.py b/chains/keshet.py index 99a382e..bebfd86 100644 --- a/chains/keshet.py +++ b/chains/keshet.py @@ -4,8 +4,3 @@ from supermarket_chain import SupermarketChain class Keshet(CerberusWebClient, SupermarketChain): _date_hour_format = '%Y-%m-%d %H:%M:%S' - _class_name = 'Keshet' - - @property - def username(self): - return self._class_name diff --git a/chains/mahsaneiHashook.py b/chains/mahsaneiHashook.py index cf1d3c3..b14f9ce 100644 --- a/chains/mahsaneiHashook.py +++ b/chains/mahsaneiHashook.py @@ -22,7 +22,7 @@ class MahsaneiHashook(SupermarketChain): req_res: requests.Response = requests.get(url) soup = BeautifulSoup(req_res.text, features='lxml') suffix: str = soup.find('a', href=lambda value: value and category.name.replace('s', '') in value - and f'-{store_id:03d}-20' in value).attrs['href'] + and f'-{store_id:03d}-20' in value).attrs['href'] down_url: str = prefix + suffix print(down_url) return down_url diff --git a/chains/osher_ad.py b/chains/osher_ad.py index d4afc4e..b367920 100644 --- a/chains/osher_ad.py +++ b/chains/osher_ad.py @@ -3,10 +3,4 @@ from supermarket_chain import SupermarketChain class OsherAd(CerberusWebClient, SupermarketChain): - _date_hour_format = '%Y-%m-%d %H:%M:%S' - _class_name = 'OsherAd' - - @property - def username(self): - return self._class_name diff --git a/chains/rami_levi.py b/chains/rami_levi.py index 2c078c2..94224b5 100644 --- a/chains/rami_levi.py +++ b/chains/rami_levi.py @@ -4,8 +4,3 @@ from supermarket_chain import SupermarketChain class RamiLevi(CerberusWebClient, SupermarketChain): _date_hour_format = '%Y-%m-%d %H:%M:%S' - _class_name = 'RamiLevi' - - @property - def username(self): - return self._class_name diff --git a/chains/shufersal.py b/chains/shufersal.py index 0752a41..0f6e8a8 100644 --- a/chains/shufersal.py +++ b/chains/shufersal.py @@ -4,7 +4,7 @@ from bs4 import BeautifulSoup from supermarket_chain import SupermarketChain -class ShuferSal(SupermarketChain): +class Shufersal(SupermarketChain): @staticmethod def get_download_url(store_id: int, category: SupermarketChain.XMLFilesCategory, session: requests.Session) -> str: diff --git a/chains/stop_market.py b/chains/stop_market.py index f9fcd52..5374c7b 100644 --- a/chains/stop_market.py +++ b/chains/stop_market.py @@ -4,8 +4,7 @@ from supermarket_chain import SupermarketChain class StopMarket(CerberusWebClient, SupermarketChain): _date_hour_format = '%Y-%m-%d %H:%M:%S' - _class_name = 'Stop_Market' @property def username(self): - return self._class_name + return 'Stop_Market' diff --git a/chains/tiv_taam.py b/chains/tiv_taam.py index ed94e23..faf71b2 100644 --- a/chains/tiv_taam.py +++ b/chains/tiv_taam.py @@ -4,7 +4,3 @@ from supermarket_chain import SupermarketChain class TivTaam(CerberusWebClient, SupermarketChain): _class_name = 'TivTaam' - - @property - def username(self): - return self._class_name diff --git a/chains/victory.py b/chains/victory.py index 7181876..77de5a7 100644 --- a/chains/victory.py +++ b/chains/victory.py @@ -1,5 +1,6 @@ from chains.mahsaneiHashook import MahsaneiHashook +from supermarket_chain import SupermarketChain -class Victory(MahsaneiHashook): +class Victory(MahsaneiHashook, SupermarketChain): pass diff --git a/chains/yohananof.py b/chains/yohananof.py index c2eac74..6810c52 100644 --- a/chains/yohananof.py +++ b/chains/yohananof.py @@ -4,8 +4,3 @@ from supermarket_chain import SupermarketChain class Yohananof(CerberusWebClient, SupermarketChain): _date_hour_format = '%Y-%m-%d %H:%M:%S' - _class_name = 'Yohananof' - - @property - def username(self): - return self._class_name diff --git a/main.py b/main.py index 5640b35..5b450f2 100644 --- a/main.py +++ b/main.py @@ -29,7 +29,7 @@ from chains import ( Path(RESULTS_DIRNAME).mkdir(exist_ok=True) Path(RAW_FILES_DIRNAME).mkdir(exist_ok=True) -chain_dict = {repr(chain): chain() for chain in SupermarketChain.__subclasses__()} +chain_dict = {repr(chain): chain() if callable(chain) else None for chain in SupermarketChain.__subclasses__()} if __name__ == '__main__': parser = ArgumentParser() diff --git a/supermarket_chain.py b/supermarket_chain.py index d4d29d8..3390935 100644 --- a/supermarket_chain.py +++ b/supermarket_chain.py @@ -126,8 +126,3 @@ class SupermarketChain(object, metaclass=Meta): manufacturer=item.find(re.compile(r'Manufacture[r]?Name')).text, code=item.find('ItemCode').text ) - - @classmethod - @abstractmethod - def __repr__(cls): - pass