has added binaproject clients
This commit is contained in:
35
chains/binaproject_web_client.py
Normal file
35
chains/binaproject_web_client.py
Normal file
@@ -0,0 +1,35 @@
|
||||
import json
|
||||
import requests
|
||||
|
||||
from supermarket_chain import SupermarketChain
|
||||
|
||||
|
||||
class BinaProjectWebClient:
|
||||
_date_hour_format = '%Y-%m-%d %H:%M:%S'
|
||||
_update_date_format = '%Y-%m-%d %H:%M:%S'
|
||||
_path_prefix = ""
|
||||
_hostname_suffix = ".binaprojects.com"
|
||||
|
||||
def get_download_url(self, store_id: int, category: SupermarketChain.XMLFilesCategory, session: requests.Session) \
|
||||
-> str:
|
||||
hostname = f"http://{self.hostname_prefix}{self.hostname_suffix}"
|
||||
url = '/'.join([hostname, self.path_prefix, "MainIO_Hok.aspx"])
|
||||
req_res: requests.Response = session.get(url)
|
||||
jsons_files = json.loads(req_res.text)
|
||||
suffix = next(cur_json["FileNm"] for cur_json in jsons_files if f'-{store_id:03d}-20' in cur_json["FileNm"]
|
||||
and category.name.replace('s', '') in cur_json["FileNm"])
|
||||
down_url: str = '/'.join([hostname, self.path_prefix, "Download", suffix])
|
||||
print(down_url)
|
||||
return down_url
|
||||
|
||||
@property
|
||||
def hostname_prefix(self):
|
||||
return repr(type(self))
|
||||
|
||||
@property
|
||||
def path_prefix(self):
|
||||
return type(self)._path_prefix
|
||||
|
||||
@property
|
||||
def hostname_suffix(self):
|
||||
return type(self)._hostname_suffix
|
@@ -1,6 +1,4 @@
|
||||
import json
|
||||
from abc import abstractmethod
|
||||
|
||||
import requests
|
||||
|
||||
from supermarket_chain import SupermarketChain
|
||||
|
7
chains/king_store.py
Normal file
7
chains/king_store.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from chains.binaproject_web_client import BinaProjectWebClient
|
||||
from supermarket_chain import SupermarketChain
|
||||
|
||||
|
||||
class KingStore(BinaProjectWebClient, SupermarketChain):
|
||||
_path_prefix = "Food_Law"
|
||||
_hostname_suffix = ".co.il"
|
6
chains/maayan2000.py
Normal file
6
chains/maayan2000.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from chains.binaproject_web_client import BinaProjectWebClient
|
||||
from supermarket_chain import SupermarketChain
|
||||
|
||||
|
||||
class Maayan2000(BinaProjectWebClient, SupermarketChain):
|
||||
pass
|
6
chains/shefa_birkat_hashem.py
Normal file
6
chains/shefa_birkat_hashem.py
Normal file
@@ -0,0 +1,6 @@
|
||||
from chains.binaproject_web_client import BinaProjectWebClient
|
||||
from supermarket_chain import SupermarketChain
|
||||
|
||||
|
||||
class ShefaBirkatHashem(BinaProjectWebClient, SupermarketChain):
|
||||
pass
|
7
chains/shuk_hayir.py
Normal file
7
chains/shuk_hayir.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from chains.binaproject_web_client import BinaProjectWebClient
|
||||
from supermarket_chain import SupermarketChain
|
||||
|
||||
|
||||
class ShukHayir(BinaProjectWebClient, SupermarketChain):
|
||||
@property
|
||||
def hostname_prefix(self): return "shuk-hayir"
|
@@ -4,7 +4,6 @@ from supermarket_chain import SupermarketChain
|
||||
|
||||
class StopMarket(CerberusWebClient, SupermarketChain):
|
||||
_date_hour_format = '%Y-%m-%d %H:%M:%S'
|
||||
|
||||
@property
|
||||
def username(self):
|
||||
return 'Stop_Market'
|
||||
|
@@ -3,4 +3,4 @@ from supermarket_chain import SupermarketChain
|
||||
|
||||
|
||||
class TivTaam(CerberusWebClient, SupermarketChain):
|
||||
_class_name = 'TivTaam'
|
||||
pass
|
||||
|
@@ -1,26 +1,6 @@
|
||||
import json
|
||||
import requests
|
||||
|
||||
from chains.binaproject_web_client import BinaProjectWebClient
|
||||
from supermarket_chain import SupermarketChain
|
||||
|
||||
|
||||
class ZolVebegadol(SupermarketChain):
|
||||
_date_hour_format = '%Y-%m-%d %H:%M:%S'
|
||||
_update_date_format = '%Y-%m-%d %H:%M:%S'
|
||||
item_tag_name = 'Item'
|
||||
|
||||
@property
|
||||
def update_date_format(self):
|
||||
return ZolVebegadol.date_hour_format
|
||||
|
||||
@staticmethod
|
||||
def get_download_url(store_id: int, category: SupermarketChain.XMLFilesCategory, session: requests.Session) -> str:
|
||||
prefix = "http://zolvebegadol.binaprojects.com"
|
||||
url = prefix + "/MainIO_Hok.aspx"
|
||||
req_res: requests.Response = session.get(url)
|
||||
jsons_files = json.loads(req_res.text)
|
||||
suffix = next(cur_json["FileNm"] for cur_json in jsons_files if f'-{store_id:03d}-20' in cur_json["FileNm"]
|
||||
and category.name.replace('s', '') in cur_json["FileNm"])
|
||||
down_url: str = '/'.join([prefix, "Download", suffix])
|
||||
print(down_url)
|
||||
return down_url
|
||||
class ZolVebegadol(BinaProjectWebClient, SupermarketChain):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user