Skip to content

Staff

Generate snailz experimental staff by creating random first and last names.

staff(options)

Main driver for snailz experimental staff creation.

  • options.params: path to parameter file (see params.StaffParams for fields).
  • options.outfile: optional path to saved output file.

Generated data is written as CSV to the specified output file.

Parameters:

Name Type Description Default
options Namespace

see above.

required
Source code in snailz/staff.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def staff(options: Namespace) -> None:
    '''Main driver for snailz experimental staff creation.

    -   options.params: path to parameter file (see params.StaffParams for fields).
    -   options.outfile: optional path to saved output file.

    Generated data is written as CSV to the specified output file.

    Args:
        options: see above.
    '''
    options.params = load_params(StaffParams, options.params)
    random.seed(options.params.seed)
    faker.Faker.seed(options.params.seed)
    fake = faker.Faker(options.params.locale)
    people = _make_people(options.params, fake)
    _save(options, people)

_make_people(params, fake)

Create people.

Parameters:

Name Type Description Default
params StaffParams

staff generation parameters.

required
fake Faker

fake name generator.

required

Returns:

Type Description
DataFrame

Dataframe containing staff ID, personal name, and family name.

Source code in snailz/staff.py
32
33
34
35
36
37
38
39
40
41
42
43
def _make_people(params: StaffParams, fake: faker.Faker) -> pl.DataFrame:
    '''Create people.

    Args:
        params: staff generation parameters.
        fake: fake name generator.

    Returns:
        Dataframe containing staff ID, personal name, and family name.
    '''
    people = [(i+1, fake.first_name(), fake.last_name()) for i in range(params.num)]
    return pl.DataFrame(people, schema=('staff_id', 'personal', 'family'), orient='row')

_save(options, people)

Save results to file or show on standard output.

Parameters:

Name Type Description Default
options Namespace

controlling options.

required
people DataFrame

dataframe of staff ID, personal name, and family name.

required
Source code in snailz/staff.py
46
47
48
49
50
51
52
53
54
55
56
def _save(options: Namespace, people: pl.DataFrame) -> None:
    '''Save results to file or show on standard output.

    Args:
        options: controlling options.
        people: dataframe of staff ID, personal name, and family name.
    '''
    if options.outfile:
        people.write_csv(Path(options.outfile))
    else:
        people.write_csv(sys.stdout)