Merge branch 'master' of bitbucket.org:panleicim/appointment_tool

This commit is contained in:
Lei PAN
2024-06-25 18:37:57 +02:00
3 changed files with 15 additions and 5 deletions
+4 -4
View File
@@ -11,7 +11,7 @@ from src.utils.excel_reader import read_contacts, fr_phone_number_prefix, get_ra
def upload_contacts_list(): def upload_contacts_list():
_contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-05-16.xlsx") _contacts_to_book = read_contacts("/Users/lpan/Desktop/contact_list_2024-06-17.xlsx")
return _contacts_to_book return _contacts_to_book
@@ -61,7 +61,7 @@ def write_new_contacts_to_excel(valid_contacts: list, file_name=str(datetime.dat
col = 0 col = 0
# Create a workbook and add a worksheet. # Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('contact_list_{}.xlsx'.format(file_name)) workbook = xlsxwriter.Workbook('contact_list_{}.xlsx'.format(file_name))
header_data = ['name', 'phone', 'passport', 'email', 'store', 'ip_country','ua'] header_data = ['name', 'phone', 'passport', 'email', 'store', 'ip_country', 'ua']
worksheet = workbook.add_worksheet() worksheet = workbook.add_worksheet()
header_format = workbook.add_format({'bold': True}) header_format = workbook.add_format({'bold': True})
@@ -143,10 +143,10 @@ if __name__ == '__main__':
# contacts_to_book = upload_contacts_list() # contacts_to_book = upload_contacts_list()
# MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book) # MONGO_STORE_MANAGER.upload_contact_list(contacts_to_book)
# print("start at {}".format(datetime.datetime.now())) # print("start at {}".format(datetime.datetime.now()))
generate_valid_contact_list_for_day(segment_number=2) # generate_valid_contact_list_for_day(segment_number=2)
# generate_contact_from_mail_list("/Users/panlei/Downloads/邮箱及密码.xlsx") # generate_contact_from_mail_list("/Users/panlei/Downloads/邮箱及密码.xlsx")
# print("end at {}".format(datetime.datetime.now())) # print("end at {}".format(datetime.datetime.now()))
# generate_all_contact_list() generate_all_contact_list()
# merge_contact_list_files( # merge_contact_list_files(
# ["/Users/lpan/Desktop/contact_list_2024-05-07.xlsx", # ["/Users/lpan/Desktop/contact_list_2024-05-07.xlsx",
# "/Users/lpan/Desktop/contact_list_2024-05-06.xlsx", # "/Users/lpan/Desktop/contact_list_2024-05-06.xlsx",
+6 -1
View File
@@ -44,7 +44,8 @@ class ContactPojo:
u'first_name': self.first_name, u'first_name': self.first_name,
u'mail': self.mail, u'mail': self.mail,
u'store': self.store, u'store': self.store,
u'ip_country': self.ip_country u'ip_country': self.ip_country,
u'ua': self.ua
} }
return dest return dest
@@ -67,7 +68,11 @@ class ContactPojo:
ip_country = "FR" ip_country = "FR"
if source.get('ip_country'): if source.get('ip_country'):
ip_country = source['ip_country'] ip_country = source['ip_country']
ua = ""
if source.get('ua'):
ua = source['ua']
result = ContactPojo(phone_number=phone, passport_number=passport, mail=email, result = ContactPojo(phone_number=phone, passport_number=passport, mail=email,
last_name=last_name, first_name=first_name, store=store) last_name=last_name, first_name=first_name, store=store)
result.ip_country = ip_country result.ip_country = ip_country
result.ua = ua
return result return result
+5
View File
@@ -48,6 +48,10 @@ def read_contacts(file_name) -> list:
store = "random" store = "random"
if contact_dict.get('store') is not None: if contact_dict.get('store') is not None:
store = contact_dict['store'] store = contact_dict['store']
ua = ""
if contact_dict.get('ua') is not None:
ua = contact_dict['ua']
contact = ContactPojo(phone_number=contact_dict['phone'], contact = ContactPojo(phone_number=contact_dict['phone'],
last_name=last_name, last_name=last_name,
@@ -55,6 +59,7 @@ def read_contacts(file_name) -> list:
passport_number=contact_dict['passport'], passport_number=contact_dict['passport'],
mail=contact_dict['email'], store=store) mail=contact_dict['email'], store=store)
contact.ip_country = ip_country contact.ip_country = ip_country
contact.ua = ua
contact_list.append(contact) contact_list.append(contact)
return contact_list return contact_list