Beispiel #1
0
def createPlayers(team):
    person = Person("en")
    adress = Address("en")
    players = []
    MAX_N = len(team)
    arrOfIds = [i + 1 for i in range(MAX_N)]
    for i in range(MAX_N):
        positions = [1, 2, 3, 4, 5]
        numbers   = [k for k in range(1, 99, 1)]
        curTeamID = choice(arrOfIds)
        arrOfIds.remove(curTeamID)
        for _ in range(len(positions)):
            curID       = str(len(players) + 1)
            teamID      = str(curTeamID)
            name        = person.full_name()
            position    = choice(positions)
            height      = str(randint(150, 220)) 
            weight      = str(person.weight()) 
            number      = str(choice(numbers))
            age         = str(person.age()) 
            country     = adress.country(allow_random=True)
            positions.remove(position)
            numbers.remove(int(number))
            players.append([curID, teamID, name, position, height, weight, number, age, country])
    f = open("Players.csv", "w", encoding='utf-8')
    for player in players:
        line = str(player[0]) + ',' + str(player[1]) + ',' + str(player[2]) + ',' +\
               str(player[3]) + ',' + str(player[4]) + ',' + str(player[5]) + ',' +\
               str(player[6]) + ',' + str(player[7]) + ',' + str(player[8]) + '\n'
        f.write(line)
    f.close()   
Beispiel #2
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(),
        )