Skip to content

Instantly share code, notes, and snippets.

View pskd73's full-sized avatar

Pramod Kumar pskd73

View GitHub Profile
class LogisticService:
def is_serviceable(self, postal_code) -> bool:
mn, mx = self.get_postal_code_range()
# use exception list here
if mn <= postal_code <= mx and postal_code not in self.get_exception_postal_codes():
return True
return False
...
def get_exception_postal_codes(self) -> list:
return []
def assign_logistic_service(order):
for logistic in logistic_services:
if logistic.is_serviceable(order.postal_code):
# if hack
if logistic.__class__.__name__ == 'DoneTodayLogisticService':
if order.postal_code in [690040, 690041]:
continue
logistic.make_shipping_request()
return logistic.__class__.__name__
class LogisticService:
def is_serviceable(self, postal_code) -> bool:
mn, mx = self.get_postal_code_range()
if mn <= postal_code <= mx:
return True
return False
@abstractmethod
def get_postal_code_range(self) -> Tuple(int, int):
pass
@pskd73
pskd73 / basic_if.py
Last active February 24, 2020 17:24
if 690034 <= postal_code <= 695000:
return "DoneTodayLogistics"
elif ...:
...
@pskd73
pskd73 / fdf_explore.py
Created August 30, 2018 12:13
Merge pdfs by BytesIO
"""Script to generate templates and merge with docs to sign them"""
import io
from fpdf import Template
from PyPDF2 import PdfFileWriter, PdfFileReader
def create_elements(el_dict):
"""Creates a elements dict to customize the template"""
final_dict = []