def sample_profile(): payload = {} zipcode, city, state = barnum.create_city_state_zip() payload["demographics"] = [{ "age": randint(18, 100), "gender": choice(["Male", "Female", "Other"]), "income": randint(10, 1000) * 1000, "city": city, "state": state, "zipcode": zipcode }] return payload
def check_if_weather_api_works_and_user_can_get_weather_for_given_city(): #wygeneruj miasto city = barnum.create_city_state_zip()[1] driver.get(site_url + "weather") cityInput = driver.find_element_by_name("city") cityInput.send_keys(city) cityInput.send_keys(Keys.RETURN) try: #sprawdź czy są dane z pogodą assert city in driver.page_source logging.info("WeatherApi works") except AssertionError: logging.info("Weather api ERROR city: %s", city)
def __init__(self, type_, created, name, coordinates): self.id = get_random_id() self.type = type_ self.created = created self.card = barnum.create_cc_number() self.phone = barnum.create_phone() self.identification = [ get_random_id(), name, barnum.create_birthday(18, 80).toordinal() ] zipcode, city, state = barnum.create_city_state_zip() longitude, latitude = coordinates[zipcode] self.location = [zipcode, city, state, longitude, latitude]
def createManufacturerData(numberValues, lastIndex): valuesList = list() phonePattern = re.compile(r'^\D*(\d{3})\D*(\d{3})\D*(\d{4})\D*(\d*)$') for i in range(numberValues): address = barnum.create_city_state_zip() phone = phonePattern.search(barnum.create_phone()).groups() # Create list with all the values for the MANUFACTURER table valuesList.append([ lastIndex + i, # MAN_CODE attribute barnum.create_company_name(), # MAN_COMPANY barnum.create_street(), # MAN_STREET address[1], # MAN_CITY address[2], # MAN_STATE int(address[0]), # MAN_ZIP int(phone[0]), # MAN_AREACODE phone[1] + "-" + phone[2], # MAN_PHONE ((barnum.create_cc_number())[1])[0] # MAN_ACCNUM ]) return valuesList
def generate(): record_list = [] meter_list = load_db() if len(meter_list) == 0: print('ERROR - empty file!!!!!!!') else: for meter in meter_list: # Fullname name_tuple = barnum.create_name() fullname = name_tuple[0] + ' ' + name_tuple[1] # Zip, city, state zip_tuple = barnum.create_city_state_zip() zipcode = zip_tuple[0] city = zip_tuple[1] state = zip_tuple[2] # House no. and street street = barnum.create_street() # Phone no. phone = barnum.create_phone() # create and print cis data record cis_data_row = [ str(uuid.uuid4()), fullname, zipcode, city, state, street, phone, meter ] print(cis_data_row) record_list.append(cis_data_row) write('cis_data.csv', record_list)
from faker import Faker import random import json from geopy.geocoders import Nominatim import barnum CATEGORIES = ['Accessoires', 'Bademode', 'Blazer', 'Blusen', 'Fleece', 'Freizeitmode', 'Hosen', 'Jacken', 'Jeans', 'Kleider', 'Mäntel', 'Pullover & Strick', 'Röcke', 'Schmuck', 'Schürzen & Kasacks', 'Shirtjacken', 'Shirts', 'Tops', 'Tuniken', 'Westen', 'Ballerinas', 'Gesundheitsschuhe', 'Halbschuhe', 'Hausschuhe', 'Pantoletten', 'Pumps', 'Sandaletten', 'Stiefel', 'Stiefeletten'] PROFILE = Faker().profile() PROFILE.pop('ssn') PROFILE.pop('blood_group') PROFILE.pop('website') PROFILE.pop('username') PROFILE.pop('residence') PROFILE.pop('current_location') geolocator = Nominatim(user_agent="kafka-producer") address = barnum.create_city_state_zip() location = geolocator.geocode('{} United States'.format(address[1])) PROFILE['longitude'] = location.longitude PROFILE['latitude'] = location.latitude PROFILE['birthdate'] = str(PROFILE['birthdate']) PROFILE['article'] = random.choice(CATEGORIES) PROFILE['address'] = ' '.join(address) print(json.dumps(PROFILE))
delta = end - start int_delta = (delta.days * 24 * 60 * 60) + delta.seconds random_second = random.randrange(int_delta) return start + timedelta(seconds=random_second) def create_object_id(when): # when = barnum.create_date(past=True, max_years_past=2, max_years_future=2) epoch = datetime.utcfromtimestamp(0) since_epoch = int((when - epoch).total_seconds()) return ObjectId(oid="%6x" % since_epoch + str(ObjectId())[8:]) for i in range(0, n): try: (zipcode, city, state) = barnum.create_city_state_zip() for j in range(0, 5): location = geolocator.geocode("%s, %s %s, USA" % (city, state, zipcode)) if location != None: rlocation = geolocator.reverse( "%s, %s" % (location.latitude, location.longitude)) print rlocation.address[-3:] if rlocation.address[-3:] == "USA": break print ': %s, %s, %s' % (zipcode, city, state) print ': %s' % rlocation print "." if location != None: name = barnum.create_name() now = datetime.utcnow()
entertainments = 100 into = 30000 city = [] name = [] surname = [] df = pd.DataFrame({ 'ID': [], 'IDbussines': [], 'Name': [], 'Surname': [], 'Age': [], 'Fanpages': [], 'Origin': [] }) for i in range(viewers): zip, city, state = barnum.create_city_state_zip() name, surname = barnum.create_name() df = df.append( { 'ID': '%.12g' % i, 'IDbussines': '%.12g' % rnd.randint(10000000000, 99999999999), 'Name': name, 'Surname': surname, 'Age': barnum.create_birthday(10, 80), 'Fanpages': '%.12g' % rnd.randint(0, 5), 'Origin': city }, ignore_index=True) df.to_csv("viewers.csv", index=False) '''df = pd.DataFrame({'ID': [], 'ViewerID': [], 'PostID': [], 'Like': [], 'Comment':[], 'Share': []})
'''Store default parameters for game mechanics''' import os import random import pathlib path = pathlib.Path(__file__).parent.absolute() import barnum import pyfiglet random.seed(12345) poss_teams = [barnum.create_city_state_zip()[1] for i in range(16)][:16] save_dir = '{0}/../data/games/'.format(path) def check_save_dir(): if os.path.isdir(save_dir) is False: os.mkdir(save_dir) welcome_message = pyfiglet.figlet_format('Match\nSimulator\n2020\n') image_dir = '{0}/../data/image/'.format(path) gui_background = '{0}{1}'.format(image_dir, 'puma-40-20-artificial-grass-2.jpg') dow = { 'monday': 0, 'mo': 0, 'tuesday': 1,
def generate_address(): street = barnum.create_street() zip, city, state = barnum.create_city_state_zip() return street, city, state, zip