def generate_vCard(): gender_initial = gender_vcard_list[random.randint(0, 4)] gender = None if gender_initial == 'M': gender = 'Male' elif gender_initial == 'F': gender = 'Female' (first_name, last_name) = gen_data.create_name(gender=gender) adr = gen_data.create_street() zip, city, state = gen_data.create_city_state_zip() properties = [] properties.append('FN:{} {}\r\n'.format(first_name, last_name)) if random.randint(0, 1): properties.append('N:{};{};;;\r\n'.format(last_name, first_name)) if random.randint(0, 1): properties.append('TEL:tel:{}\r\n'.format(gen_data.create_phone())) if random.randint(0, 1): properties.append('GENDER:{}\r\n'.format(gender_initial)) if random.randint(0, 1): properties.append('EMAIL:{}\r\n'.format( gen_data.create_email(name=(first_name, last_name)).lower())) if random.randint(0, 1): properties.append('IMPP:sip:{}@{}\r\n'.format(first_name.lower(), 'sip.linphone.org')) if random.randint(0, 1): properties.append('ADR:;;{};{};{};{};\r\n'.format( adr, city, state, zip)) if random.randint(0, 1): properties.append('NOTE:{}\r\n'.format(gen_data.create_sentence())) if random.randint(0, 1): properties.append('ORG:{}\r\n'.format(gen_data.create_company_name())) if random.randint(0, 1): properties.append('BDAY:{0:%Y%m%d}\r\n'.format( gen_data.create_birthday())) shuffle(properties) vCard = 'BEGIN:VCARD\r\n' vCard += 'VERSION:4.0\r\n' for property in properties: vCard += property vCard += 'END:VCARD\r\n' return vCard
def generate_vCard(): gender_initial = gender_vcard_list[random.randint(0, 4)] gender = None if gender_initial == 'M': gender = 'Male' elif gender_initial == 'F': gender = 'Female' (first_name, last_name) = gen_data.create_name(gender=gender) adr = gen_data.create_street() zip, city, state = gen_data.create_city_state_zip() properties = [] properties.append('FN:{} {}\r\n'.format(first_name, last_name)) if random.randint(0, 1): properties.append('N:{};{};;;\r\n'.format(last_name, first_name)) if random.randint(0, 1): properties.append('TEL:tel:{}\r\n'.format(gen_data.create_phone())) if random.randint(0, 1): properties.append('GENDER:{}\r\n'.format(gender_initial)) if random.randint(0, 1): properties.append('EMAIL:{}\r\n'.format(gen_data.create_email(name=(first_name, last_name)).lower())) if random.randint(0, 1): properties.append('IMPP:sip:{}@{}\r\n'.format(first_name.lower(), 'sip.linphone.org')) if random.randint(0, 1): properties.append('ADR:;;{};{};{};{};\r\n'.format(adr, city, state, zip)) if random.randint(0, 1): properties.append('NOTE:{}\r\n'.format(gen_data.create_sentence())) if random.randint(0, 1): properties.append('ORG:{}\r\n'.format(gen_data.create_company_name())) if random.randint(0, 1): properties.append('BDAY:{0:%Y%m%d}\r\n'.format(gen_data.create_birthday())) shuffle(properties) vCard = 'BEGIN:VCARD\r\n' vCard += 'VERSION:4.0\r\n' for property in properties: vCard += property vCard += 'END:VCARD\r\n' return vCard
from barnum import gen_data import csv with open('demographic.csv','w') as csvfile: csvwriter =csv.writer(csvfile, delimiter=' ') for i in range (0,100): name=gen_data.create_name() job_title=gen_data.create_job_title() phone=gen_data.create_phone() address=gen_data.create_city_state_zip() csvwriter.writerow([name,job_title,phone,address]) csvfile.close()
sys.stdout.write('\n') #TODO need to create some email folders myOwnPhoneNumberURI = "tel:+11111111111" previousContacts = [] previousEmailAddresses = [] previousIMAccounts = [] allchars = string.maketrans('','') for dummy in range (0, count): firstName, lastName = gen_data.create_name() zip, city, state = gen_data.create_city_state_zip() postalAddressID=str(random.randint(0, sys.maxint)) UID = str(random.randint(0, sys.maxint)) phoneNumber = gen_data.create_phone() phoneUri = 'tel:+1' + phoneNumber.translate(allchars,' -()') birthDay = gen_data.create_birthday() streetAddress = gen_data.create_street() emailAddress = gen_data.create_email(name=(firstName, lastName)) xmppAddress = str(firstName+"." + lastName + "@gmail.com").lower() hasIMAccount = False hasPhoneNumber = False jobTitle = gen_data.create_job_title() generatePostalAddress() generateEmailAddress() #Only every 3rd have Phone or IM to add variation. if random.randint(0, 3) > 2 or count == 1: generateIMAccount(gen_data, str)
def get_phone_number(): return gen_data.create_phone()
import random from barnum import gen_data import addressbook_pb2 # Barnum generates US data but that's ok for the example names = [gen_data.create_name() for _ in range(0, 15)] phones = [gen_data.create_phone() for _ in range(0, 30)] postcodes = [gen_data.create_city_state_zip() for _ in range(0, 15)] streets = [gen_data.create_street() for _ in range(0, 30)] contacts = [] for name in names: address = {} # Simulate the fact that postcode are optionals if random.choice([True, False]): address['postcode'] = random.choice(postcodes)[0] address['address_lines'] = random.sample(streets, random.randint(0, 2)) phone_numbers = [] for _ in range(0, random.randint(0, 2)): phone_numbers.append({ 'type': random.choice(['MOBILE', 'LANDLINE']), 'number': random.choice(phones) }) contacts.append({ 'first_name': name[0], 'last_name': name[1], 'address': address,
import random from barnum import gen_data import addressbook_pb2 # Barnum generates US data but that's ok for the example names = [gen_data.create_name() for _ in range(0, 15)] phones = [gen_data.create_phone() for _ in range(0, 30)] postcodes = [gen_data.create_city_state_zip() for _ in range(0, 15)] streets = [gen_data.create_street() for _ in range(0, 30)] contacts = [] for name in names: address = {} # Simulate the fact that postcode are optionals if random.choice([True, False]): address['postcode'] = random.choice(postcodes)[0] address['address_lines'] = random.sample(streets, random.randint(0, 2)) phone_numbers = [] for _ in range(0, random.randint(0, 2)): phone_numbers.append({ 'type': random.choice(['MOBILE', 'LANDLINE']), 'number': random.choice(phones) }) contacts.append({ 'first_name': name[0], 'last_name': name[1], 'address': address, 'phone_numbers': phone_numbers
sys.stdout.write('\n') #TODO need to create some email folders myOwnPhoneNumberURI = "tel:+11111111111" previousContacts = [] previousEmailAddresses = [] previousIMAccounts = [] allchars = string.maketrans('', '') for dummy in range(0, count): firstName, lastName = gen_data.create_name() zip, city, state = gen_data.create_city_state_zip() postalAddressID = str(random.randint(0, sys.maxint)) UID = str(random.randint(0, sys.maxint)) phoneNumber = gen_data.create_phone() phoneUri = 'tel:+1' + phoneNumber.translate(allchars, ' -()') birthDay = gen_data.create_birthday() streetAddress = gen_data.create_street() emailAddress = gen_data.create_email(name=(firstName, lastName)) xmppAddress = str(firstName + "." + lastName + "@gmail.com").lower() hasIMAccount = False hasPhoneNumber = False jobTitle = gen_data.create_job_title() generatePostalAddress() generateEmailAddress() #Only every 3rd have Phone or IM to add variation. if random.randint(0, 3) > 2 or count == 1: generateIMAccount(gen_data, str)
from barnum import gen_data import json f = open('Users_old.txt', 'r') f_out = open('Users.txt', 'w') for line in f.readlines(): line = line.strip().split('\t') new_line = [] new_line.append(line[0]) new_line.append(line[1]) new_line.append(line[2]) info = {} info['birthday'] = str(gen_data.create_birthday(min_age=18, max_age=60)) info['email'] = gen_data.create_email(tld="com") info['mobile'] = gen_data.create_phone() tmp = gen_data.create_city_state_zip() info['city'] = tmp[1] + ', ' + tmp[2] new_line.append(json.dumps(info)) f_out.write('\t'.join(new_line) + '\n') f.close() f_out.close()