class CSVData: def __init__(self): self.person = Person(locale='zh') self.address = Address(locale='zh') self.code = Code() self.business = Business(locale='zh') self.text = Text(locale='zh') self.datetime = Datetime(locale='zh') self.file = File() self.path = Path() self.internet = Internet() self.structure = Structure() def mime_data(self): # col1 = self.person.full_name() col1 = self.person.last_name() + self.person.first_name() col2 = self.address.city() col3 = self.address.street_name() col4 = self.address.calling_code() col5 = self.address.longitude() col6 = self.code.imei() col7 = self.business.company() col8 = self.text.hex_color() col9 = self.datetime.formatted_datetime() col10 = self.datetime.time() col11 = self.file.file_name() col12 = self.path.dev_dir() col13 = self.internet.ip_v4() col14 = self.internet.ip_v6() col15 = self.internet.home_page() col16 = self.internet.stock_image() col17 = self.internet.user_agent() col18 = self.internet.mac_address() col19 = self.person.email() col20 = self.person.telephone() col21 = self.code.issn() col22 = self.person.social_media_profile() col23 = self.structure.html() line = '\"{0}\", \"{1}\", \"{2}\", \"{3}\", {4}, \"{5}\", \"{6}\" , \"{7}\" , \"{8}\" , \"{9}\" , \"{10}\" , \"{11}\" , \"{12}\" , \"{13}\" , \"{14}\" , \"{15}\" , \"{16}\" , \"{17}\" , \"{18}\" , \"{19}\" , \"{20}\" , \"{21}\" , \"{22}\"\n'.format( col1, col2, col3, col4, col5, col6, col7, col8, col9, col10, col11, col12, col13, col14, col15, col16, col17, col18, col19, col20, col21, col22, col23) # line = "mime data" # print(line) return line
def generate(): inserts = [] counter = 350 business = Business('en') address = Address('en') internet = Internet('en') for index in range(counter, 15000, 1): inserts.append( template.substitute(id=index, name=business.company().replace("'", "''"), address=address.address().replace("'", "''"), credit=random.randint(300, 1000000), website=internet.home_page().replace( "'", "''"))) inserts_file = open('result_scripts/customers.sql', 'w', encoding='utf-8') inserts_file.writelines('\n'.join(inserts)) inserts_file.close()
# 自定义名字pattern templates = ['l-d', 'U-d'] for item in templates: print(person.username(template=item)) print('\n') print('#' * 5 + '地址' + '#' * 5) address = Address('zh') print(address.coordinates()) print(address.city()) print('\n') print('#' * 5 + '地址' + '#' * 5) business = Business('zh') print(business.company()) print(business.company_type()) print('\n') print('#' * 5 + '支付' + '#' * 5) payment = Payment('zh') print(payment.paypal()) print(payment.credit_card_expiration_date()) print('\n') print('#' * 5 + '文字' + '#' * 5) text = Text('zh') print(text.alphabet()) print(text.answer()) print(text.quote()) print(text.title())
def _generate_organization_data(locale='ru') -> dict: business = Business(locale) return { 'id': uuid.uuid4(), 'name': business.company(), }
def generatorStr(columns, numbOfEl): # двумерный массив: название столбца, тип arrDictGenerator = [] strNew = [] for j in range(0, numbOfEl): dictGenerator = {} marqModel = ['', ''] for i in range(1, len(columns)): if columns[i][0] == 'sex': if 'sex' not in dictGenerator: data = generatorGender() dictGenerator[i] = data if columns[i][0] == 'last_name': if 'sex' in dictGenerator: gender = dictGenerator.get('sex') else: gender = generatorGender() dictGenerator['sex'] = gender dictGenerator['last_name'] = generatorLastName(gender) if columns[i][0] == 'first_name': if 'sex' in dictGenerator: gender = dictGenerator.get('sex') else: gender = generatorGender() dictGenerator['sex'] = gender dictGenerator['first_name'] = generatorFirstName(gender) if columns[i][0] == ('OGRN'): r = rsp() data = r.ogrn() dictGenerator['OGRN'] = data if columns[i][0] == 'marque' and 'model' not in dictGenerator: dictGenerator['marque'] = '0' elif columns[i][0] == 'marque' and 'model' in dictGenerator and marqModel == ['', '']: tr = Transport() carStr = tr.car() carArr = carStr.split(' ') dictGenerator['marque'] = carArr[0] marqModel[0] = carArr[0] if len(carArr) > 2: strCar = '' for i in range(1, len(carArr)): strCar += str(i) marqModel[1] = strCar elif len(carArr) < 2: marqModel[1] = '' else: marqModel[1] = carArr[1] elif columns[i][0] == 'marque' and 'model' in dictGenerator and marqModel != ['','']: dictGenerator['marque'] = marqModel[0] if columns[i][0] == 'model' and 'marque' not in dictGenerator: dictGenerator['model'] = '0' elif columns[i][0] == 'model' and 'marque' in dictGenerator and marqModel == ['','']: tr = Transport() carStr = tr.car() carArr = carStr.split(' ') marqModel[0] = carArr[0] if len(carArr) > 2: strCar = '' for i in range(1, len(carArr)): strCar += str(i) marqModel[1] = strCar elif len(carArr) < 2: marqModel[1] = '' else: marqModel[1] = carArr[1] dictGenerator['model'] = marqModel[1] if dictGenerator['marque'] == '0': dictGenerator['marque'] = marqModel[0] elif columns[i][0] == 'model' and 'marque' in dictGenerator and marqModel != ['','']: if dictGenerator['marque'] == '0': dictGenerator['marque'] = marqModel[0] dictGenerator['model'] = marqModel[1] if columns[i][0] == 'name': comp = Business() dictGenerator['name'] = comp.company() if columns[i][0] == 'deal_date': dictGenerator['deal_date'] = generatorDate() if columns[i][0] == 'city': addr = Address() dictGenerator['city'] = addr.city() if columns[i][0] == 'transmission': dictGenerator['transmission'] = generatorTrans() if columns[i][0] == 'engine': dictGenerator['engine'] = generatorEngine() if columns[i][0] == 'color': dictGenerator['color'] = generatorColor() if columns[i][0] == 'VIN': vin = generatorVIN() dictGenerator['VIN'] = vin if columns[i][0] == 'kilometrage': dictGenerator[columns[i][0]] = random.randrange(5000, 150000, 5000) if columns[i][0] == 'salary': dictGenerator[columns[i][0]] = random.randrange(1000, 6000, 100) if columns[i][0] == 'power': dictGenerator[columns[i][0]] = random.randrange(130, 220, 10) if columns[i][0] == 'price': dictGenerator[columns[i][0]] = random.randrange(1300, 40000, 1000) if columns[i][1] == 'int' and columns[i][0] not in dictGenerator: dictGenerator[columns[i][0]] = 0 if columns[i][1] == 'tinyint': dictGenerator[columns[i][0]] = 0 if columns[i][1] == 'varchar(255)' and columns[i][0] not in dictGenerator: colstr = '' for j in (0, 12): colstr += random.choice(string.ascii_letters) dictGenerator[columns[i][0]] = colstr arrDictGenerator.append(dictGenerator) #print(dictGenerator) return arrDictGenerator