add method to generate contact for mail creation
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
import random
|
||||||
|
|
||||||
|
import xlsxwriter
|
||||||
|
|
||||||
|
from src.person_name.extract_name_with_pinyinlist import read_pinyin_list_from_file
|
||||||
|
from src.pojo.mail_creation_pojo import MailCreationPojo
|
||||||
|
from src.utils.password_generator import generate_password
|
||||||
|
|
||||||
|
|
||||||
|
def write_mail_creation_pojo_to_excel(valid_contacts: list):
|
||||||
|
row = 0
|
||||||
|
col = 0
|
||||||
|
# Create a workbook and add a worksheet.
|
||||||
|
workbook = xlsxwriter.Workbook('mail_contacts_{}.xlsx'.format(len(valid_contacts)))
|
||||||
|
header_data = ['name', 'password']
|
||||||
|
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:
|
||||||
|
worksheet.write(row, col, "{}".format(info.name))
|
||||||
|
worksheet.write(row, col + 1, info.password)
|
||||||
|
row += 1
|
||||||
|
workbook.close()
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
pinyin_name_list = read_pinyin_list_from_file()
|
||||||
|
random.shuffle(pinyin_name_list)
|
||||||
|
_name_list = pinyin_name_list[0:100]
|
||||||
|
# write to excel
|
||||||
|
_generated_list = []
|
||||||
|
for _name in _name_list:
|
||||||
|
_password = generate_password()
|
||||||
|
_c = MailCreationPojo(_name, _password)
|
||||||
|
_generated_list.append(_c)
|
||||||
|
write_mail_creation_pojo_to_excel(_generated_list)
|
||||||
Reference in New Issue
Block a user