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()
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 pi_push_all_records(self, n_record_limit: int) -> bool: """ Called when a tool has no incoming data connection. :param n_record_limit: Set it to <0 for no limit, 0 for no records, and >0 to specify the number of records. :return: True for success, False for failure. """ if not self.is_initialized: return False # Save a reference to the RecordInfo passed into this function in the global namespace, so we can access it later. record_info_out = Sdk.RecordInfo(self.alteryx_engine) # Adds the new field to the record. for field in self.column_name: self.output_field = record_info_out.add_field(field, self.output_type, size=self.field_size) # Lets the downstream tools know what the outgoing record metadata will look like, based on record_info_out. self.output_anchor.init(record_info_out) # Creating a new, empty record creator based on record_info_out's record layout. record_creator = record_info_out.construct_record_creator() #import pdb; pdb.set_trace() #sophs code: for record in range(self.record_limit): for field in enumerate(record_info_out): if field[1].name == 'number_float': mimesis_object = Numbers() record_value = str( mimesis_object.float_number(end=10000, precision=6)) if field[1].name == 'number_float_positive': mimesis_object = Numbers() record_value = str( mimesis_object.float_number(start=0, end=10000, precision=6)) if field[1].name == 'number_int': mimesis_object = Numbers() record_value = str( mimesis_object.integer_number(start=-32767, end=32767)) if field[1].name == 'number_int_positive': mimesis_object = Numbers() record_value = str( mimesis_object.integer_number(start=0, end=32767)) if field[1].name == 'address_street_address': mimesis_object = Address(self.Locale) record_value = mimesis_object.address() if field[1].name == 'address_coordinates': mimesis_object = Address(self.Locale) record_value = str(mimesis_object.coordinates()) if field[1].name == 'address_country': mimesis_object = Address(self.Locale) record_value = mimesis_object.country(allow_random=True) if field[1].name == 'address_postal_code': mimesis_object = Address(self.Locale) record_value = mimesis_object.postal_code() if field[1].name == 'code_imei': mimesis_object = Code() record_value = mimesis_object.imei() if field[1].name == 'code_isbn': mimesis_object = Code() record_value = mimesis_object.isbn() if field[1].name == 'code_pin': mimesis_object = Code() record_value = mimesis_object.pin() if field[1].name == 'food_dish': mimesis_object = Food(self.Locale) record_value = mimesis_object.dish() if field[1].name == 'food_fruit': mimesis_object = Food(self.Locale) record_value = mimesis_object.fruit() if field[1].name == 'food_vegetables': mimesis_object = Food(self.Locale) record_value = mimesis_object.vegetable() if field[1].name == 'internet_url': mimesis_object = Internet() record_value = mimesis_object.home_page() if field[1].name == 'internet_ipv4': mimesis_object = Internet() record_value = mimesis_object.ip_v4() if field[1].name == 'internet_mac': mimesis_object = Internet() record_value = mimesis_object.mac_address() if field[1].name == 'person_blood_type': mimesis_object = Person(self.Locale) record_value = mimesis_object.blood_type() if field[1].name == 'person_email': mimesis_object = Person(self.Locale) record_value = mimesis_object.email() if field[1].name == 'person_full_name': mimesis_object = Person(self.Locale) record_value = mimesis_object.full_name() if field[1].name == 'person_nationality': mimesis_object = Person(self.Locale) record_value = mimesis_object.nationality() if field[1].name == 'person_occupation': mimesis_object = Person(self.Locale) record_value = mimesis_object.occupation() if field[1].name == 'person_telephone': mimesis_object = Person(self.Locale) record_value = mimesis_object.telephone() if field[1].name == 'science_atomic_number': mimesis_object = Science(self.Locale) record_value = str(mimesis_object.atomic_number()) if field[1].name == 'science_chemical_element': mimesis_object = Science(self.Locale) record_value = mimesis_object.chemical_element() if field[1].name == 'transport_airplane': mimesis_object = Transport() record_value = mimesis_object.airplane() if field[1].name == 'transport_car': mimesis_object = Transport() record_value = mimesis_object.car() if field[1].name == 'transport_truck': mimesis_object = Transport() record_value = mimesis_object.truck() if field[1].name == 'transport_vehicle_reg_code': mimesis_object = Transport() record_value = mimesis_object.vehicle_registration_code() if field[1].name == 'business_company_name': mimesis_object = Business() record_value = mimesis_object.company() if field[1].name == 'business_company_type': mimesis_object = Business() record_value = mimesis_object.company_type() if field[1].name == 'file_filename': mimesis_object = File() record_value = mimesis_object.file_name() if field[1].name == 'file_file_extension': mimesis_object = File() record_value = mimesis_object.extension() if field[1].name == 'file_mime_type': mimesis_object = File() record_value = mimesis_object.mime_type() if field[1].name == 'file_size': mimesis_object = File() record_value = mimesis_object.size() record_info_out[field[0]].set_from_string( record_creator, record_value) out_record = record_creator.finalize_record() self.output_anchor.push_record(out_record, False) record_creator.reset() # Make sure that the output anchor is closed. self.output_anchor.close() return True
def ii_push_record(self, in_record: object) -> bool: """ Responsible for pushing records out. Called when an input record is being sent to the plugin. :param in_record: The data for the incoming record. :return: False if there's a downstream error, or if there's an error with the field name, otherwise True. """ if not self.parent.is_initialized: return False #create the new fields record_value = None for field in enumerate(self.record_info_out): if field[1].name == 'number_float': mimesis_object = Numbers() record_value = str( mimesis_object.float_number(end=10000, precision=6)) if field[1].name == 'number_float_positive': mimesis_object = Numbers() record_value = str( mimesis_object.float_number(start=0, end=10000, precision=6)) if field[1].name == 'number_int': mimesis_object = Numbers() record_value = str( mimesis_object.integer_number(start=-32767, end=32767)) if field[1].name == 'number_int_positive': mimesis_object = Numbers() record_value = str( mimesis_object.integer_number(start=0, end=32767)) if field[1].name == 'address_street_address': mimesis_object = Address(self.Locale) record_value = mimesis_object.address() if field[1].name == 'address_coordinates': mimesis_object = Address(self.Locale) record_value = str(mimesis_object.coordinates()) if field[1].name == 'address_country': mimesis_object = Address(self.Locale) record_value = mimesis_object.country(allow_random=True) if field[1].name == 'address_postal_code': mimesis_object = Address(self.Locale) record_value = mimesis_object.postal_code() if field[1].name == 'code_imei': mimesis_object = Code() record_value = mimesis_object.imei() if field[1].name == 'code_isbn': mimesis_object = Code() record_value = mimesis_object.isbn() if field[1].name == 'code_pin': mimesis_object = Code() record_value = mimesis_object.pin() if field[1].name == 'food_dish': mimesis_object = Food(self.Locale) record_value = mimesis_object.dish() if field[1].name == 'food_fruit': mimesis_object = Food(self.Locale) record_value = mimesis_object.fruit() if field[1].name == 'food_vegetables': mimesis_object = Food(self.Locale) record_value = mimesis_object.vegetable() if field[1].name == 'internet_url': mimesis_object = Internet() record_value = mimesis_object.home_page() if field[1].name == 'internet_ipv4': mimesis_object = Internet() record_value = mimesis_object.ip_v4() if field[1].name == 'internet_mac': mimesis_object = Internet() record_value = mimesis_object.mac_address() if field[1].name == 'person_blood_type': mimesis_object = Person(self.Locale) record_value = mimesis_object.blood_type() if field[1].name == 'person_email': mimesis_object = Person(self.Locale) record_value = mimesis_object.email() if field[1].name == 'person_full_name': mimesis_object = Person(self.Locale) record_value = mimesis_object.full_name() if field[1].name == 'person_nationality': mimesis_object = Person(self.Locale) record_value = mimesis_object.nationality() if field[1].name == 'person_occupation': mimesis_object = Person(self.Locale) record_value = mimesis_object.occupation() if field[1].name == 'person_telephone': mimesis_object = Person(self.Locale) record_value = mimesis_object.telephone() if field[1].name == 'science_atomic_number': mimesis_object = Science(self.Locale) record_value = str(mimesis_object.atomic_number()) if field[1].name == 'science_chemical_element': mimesis_object = Science(self.Locale) record_value = mimesis_object.chemical_element() if field[1].name == 'transport_airplane': mimesis_object = Transport() record_value = mimesis_object.airplane() if field[1].name == 'transport_car': mimesis_object = Transport() record_value = mimesis_object.car() if field[1].name == 'transport_truck': mimesis_object = Transport() record_value = mimesis_object.truck() if field[1].name == 'transport_vehicle_reg_code': mimesis_object = Transport() record_value = mimesis_object.vehicle_registration_code() if field[1].name == 'business_company_name': mimesis_object = Business() record_value = mimesis_object.company() if field[1].name == 'business_company_type': mimesis_object = Business() record_value = mimesis_object.company_type() if field[1].name == 'file_filename': mimesis_object = File() record_value = mimesis_object.file_name() if field[1].name == 'file_file_extension': mimesis_object = File() record_value = mimesis_object.extension() if field[1].name == 'file_mime_type': mimesis_object = File() record_value = mimesis_object.mime_type() if field[1].name == 'file_size': mimesis_object = File() record_value = mimesis_object.size() self.record_info_out[field[0]].set_from_string( self.record_creator, record_value) out_record = self.record_creator.finalize_record() #self.parent.output_anchor.push_record(out_record, False) self.record_creator.reset() # Copy the data from the incoming record into the outgoing record. self.record_creator.reset() self.record_copier.done_adding() self.record_copier.copy(self.record_creator, in_record) # Push the record downstream and quit if there's a downstream error. if not self.parent.output_anchor.push_record(out_record): return False return True
def f2(self, seed): return File(seed=seed)
def file(self): return File()
def _files(self, seed): return File(seed=seed), File(seed=seed)
def file(): return File()
def file_el(): """ :return: """ return File()