def get_user_data(test_locale='en'): person = {} user = Personal(test_locale) address = Address(test_locale) person['first_name'], person['last_name'] = user.full_name(gender='male').split() common.success("Generated user name '%s %s'" % (person['first_name'], person['last_name'])) person['email'] = user.email(gender='male') common.success("Generated email '%s'" % person['email']) person['street'] = address.address() person['city'] = address.city() person['state'] = address.state() person['postcode'] = address.postal_code() common.success("Generated address '%s %s, %s, %s'" % (person['postcode'], person['state'], person['city'], person['street'])) person['password'] = ''.join(random.SystemRandom().choice(string.digits + string.ascii_letters) for _ in range(10)) common.success("Generated password '%s'" % person['password']) if (test_locale == 'en'): person['country_code'] = 'US' person['country'] = 'United States' person['state_code'] = 'IA' person['state'] = 'Iowa' elif (test_locale == 'ru'): person['country_code'] = 'RU' person['country'] = 'Russian Federation' person['state_code'] = None person['state'] = None else: person['country_code'] = None person['country'] = None person['state_code'] = None person['state'] = None common.success("Generated country '%s' and state '%s'" % (person['country'], person['state'])) return person
now = datetime.datetime.now() def random_date(start, end): """Generate a random datetime between `start` and `end`""" return start + datetime.timedelta( # Get a random amount of seconds between `start` and `end` seconds=random.randint(0, int((end - start).total_seconds())), ) for i in range(50): event = Event() myID = "" for i in range(14): myID += random.choice(string.ascii_letters + string.digits) images = ["one.jpg", "two.jpg", "three.jpg", "four.jpg"] event.id = myID event.title = text.sentence() event.link = "https://google.com" event.description = text.quote() event.date = str(random_date(now, now + datetime.timedelta(600))) event.category = text.words(quantity=4) event.address = address.address() event.city = address.city() event.lat = str(round(random.uniform(37, 40.8), 7)) event.lng = str(round(random.uniform(-108.9, -102.2), 7)) event.image = random.choice(images) ans = event.toJSON() #print(ans) table.put_item(Item=ans)