Ejemplo n.º 1
0
def generate_random_data(count):
    db = flask_sqlalchemy.get_state(current_app).db
    User.query.delete(synchronize_session='evaluate')
    for x in range(count):
        p = Person(locales.EN)

        date_created = datetime.datetime.now() - datetime.timedelta(
            days=p.work_experience() * 365)
        user = User(email=p.email(),
                    password="******",
                    date_created=date_created)
        user.set_password(user.password)
        db.session.add(user)
        print_progress_bar(x + 1,
                           count,
                           prefix='Progress:',
                           suffix='Complete',
                           length=50)
        if x % 10 == 0:
            db.session.commit()

    db.session.commit()
Ejemplo n.º 2
0
#!/usr/bin/env python3
# -*- conding:utf8 -*-

from mimesis import Person, Address, Business, Payment, Text, Food
from mimesis.enums import Gender

print('#' * 5 + '个人信息' + '#' * 5)
person = Person('zh')
# 可以传递性别给full_name()
print(person.full_name(Gender.MALE))
print(person.level_of_english())
print(person.nationality())
print(person.work_experience())
print(person.political_views())
print(person.worldview())

# 自定义名字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')
Ejemplo n.º 3
0
    def person(
        cls,
        *,
        locale=Locales.EN,
        qualification=None,
        age=None,
        blood_type=None,
        email=None,
        first_name=None,
        last_name=None,
        gender=None,
        height=None,
        id=None,
        language=None,
        nationality=None,
        occupation=None,
        phone=None,
        title=None,
        university=None,
        weight=None,
        work_experience=None,
    ):
        '''
            Create an Person Data Entity object.

            All individual fields are automatically randomly generated based on locale. If provided, the corresponding values are overriden.

            Note:
                All individual fields are randomly generated. Don't expect correct correlation e.g. correct postal code for the generated city.

            Keyword Arguments:
                locale: Approprite Random.locale.<local_name> object. Default is Random.locale.EN
                qualification: Educational Qualification
                age: Age
                blood_type: Blood type
                email: Email address
                first_name: First name
                last_name: Last name
                gender: Gender
                height: Height
                id: Identifier
                language: Language
                nationality: Nationality
                occupation: Occupation
                phone: Phone number
                title: Title
                university: University
                weight: Weight
                work_experience: Work Experience
        '''
        person = Person(locale=locale)
        from arjuna.engine.data.entity.person import Person as ArjPerson

        first_name = first_name is not None and first_name or person.first_name(
        )
        last_name = last_name is not None and last_name or person.last_name()
        return ArjPerson(
            qualification=qualification is not None and qualification
            or person.academic_degree(),
            age=age is not None and age or person.age(),
            blood_type=blood_type is not None and blood_type
            or person.blood_type(),
            email=email is not None and email or person.email(),
            first_name=first_name,
            last_name=last_name,
            name=first_name + " " + last_name,
            gender=gender is not None and gender or person.gender(),
            height=height is not None and height or person.height(),
            id=id is not None and id or person.identifier(),
            language=language is not None and language or person.language(),
            nationality=nationality is not None and nationality
            or person.nationality(),
            occupation=occupation is not None and occupation
            or person.occupation(),
            phone=phone is not None and phone or person.telephone(),
            title=title is not None and title or person.title(),
            university=university is not None and university
            or person.university(),
            weight=weight is not None and weight or person.weight(),
            work_experience=work_experience is not None and work_experience
            or person.work_experience(),
        )