add method to check names

This commit is contained in:
2024-05-17 21:50:01 +02:00
parent 677db7399e
commit 6a6d81e388
+3 -41
View File
@@ -98,8 +98,8 @@ class ExcelHelper:
mail_list_in_json = pandas.read_excel(file_name).to_json(orient='records') mail_list_in_json = pandas.read_excel(file_name).to_json(orient='records')
contact_dict_list = json.loads(mail_list_in_json) contact_dict_list = json.loads(mail_list_in_json)
for contact_dict in contact_dict_list: for contact_dict in contact_dict_list:
if contact_dict['mail']: if contact_dict['email']:
mail = contact_dict['mail'].strip() mail = contact_dict['email'].strip()
pwd = contact_dict['password'] pwd = contact_dict['password']
contact = MailAddress(mail, pwd) contact = MailAddress(mail, pwd)
contact_list.append(contact) contact_list.append(contact)
@@ -171,19 +171,6 @@ def get_random_cn_phone_numbers():
return prefix + _phone_number return prefix + _phone_number
def generate_email_from_name(first_name: str, last_name: str) -> str:
length = 2 # number of characters in the string.
ran = ''.join(random.choices(string.digits, k=length))
separator = ['.', '_', '']
domains = ['gmail.com', 'hotmail.com', 'yahoo.com', 'aol.com', 'outlook.com', 'hotmail.fr', 'gmx.com',
'hotmail.com', 'yahoo.com', 'aol.com', 'hotmail.com']
email = "{}{}{}{}@{}".format(last_name.lower(), random.choice(separator),
first_name.replace("-", "").replace("'", "").lower(), ran,
random.choice(domains))
print(email)
return email
def get_random_id_number() -> str: def get_random_id_number() -> str:
# write_the_valid_profiles_to_excel() # write_the_valid_profiles_to_excel()
S = 8 # number of characters in the string. S = 8 # number of characters in the string.
@@ -193,31 +180,6 @@ def get_random_id_number() -> str:
return ran return ran
def write_destinaire_email(valid_contacts: list, generate_passport=True):
row = 0
col = 0
# Create a workbook and add a worksheet.
workbook = xlsxwriter.Workbook('real_contacts_{}.xlsx'.format(len(valid_contacts)))
header_data = ['name', 'phone', 'passport', 'email']
worksheet = workbook.add_worksheet()
header_format = workbook.add_format({'bold': True})
for col_num, data in enumerate(header_data):
worksheet.write(row, col_num, data, header_format)
row = row + 1
for info in valid_contacts:
info.phone = get_random_fr_phone_numbers()
info.passport = get_random_passport_id_number()
info.mail = generate_email_from_name(info.first_name, info.last_name)
# Iterate over the data and write it out row by row.
worksheet.write(row, col, "{} {}".format(info.last_name, info.first_name))
worksheet.write(row, col + 1, info.phone)
worksheet.write(row, col + 2, info.passport)
worksheet.write(row, col + 3, info.mail)
row += 1
workbook.close()
def save_mails_to_db(): def save_mails_to_db():
excel_reader = ExcelHelper() excel_reader = ExcelHelper()
emails = excel_reader.read_email_pojo("~/Downloads/邮箱及密码.xlsx") emails = excel_reader.read_email_pojo("~/Downloads/邮箱及密码.xlsx")
@@ -237,5 +199,5 @@ if __name__ == '__main__':
save_mails_to_db() save_mails_to_db()
# for mail in excel_reader.read_mails_and_pwd(): # for mail in excel_reader.read_mails_and_pwd():
# MONGO_STORE_MANAGER.insert_email(mail) # MONGO_STORE_MANAGER.insert_email(mail)
# for i in range(1, 100): # for i in range(1, 300):
# print(get_random_fr_phone_numbers()) # print(get_random_fr_phone_numbers())