module

headfake.field.faker

Classes
  • NameField Base for a name field which uses faker to generate. The supplied 'gender_field' points to the field in the fieldset which generates the gender value. It uses this field and row value to determine whether the generated name is male or female.
  • TimeField Create mock time using faker
  • FirstNameField Generate first name based on gender using the faker module (see NameField).
  • LastNameField Generate last name using the faker module.
  • MiddleNameField Mock middle name field.
  • AddressField Mock address line field.
  • PostcodeField Mock postcode field.
  • PhoneField Mock phone number field.
  • EmailField Create mock email using faker
  • PasswordField Create mock password using faker
  • TextField Generate text using the faker.lorem provider. 'max_length' controls how long the text is allowed to be.
  • MemoField Generate paragraphs using the faker.lorem provider. 'sentences' controls the exact number of sentences, when 'exact' is set to True, when set to False it will return a variable number of sentences (never less than 1) +- 40% of the 'sentences' parameter.
class

headfake.field.faker.NameField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, gender_field)

Bases
headfake.field.core.FakerField headfake.field.core.Field

Base for a name field which uses faker to generate. The supplied 'gender_field' points to the field in the fieldset which generates the gender value. It uses this field and row value to determine whether the generated name is male or female.

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset Fieldset to initialise from
Returns

None

class

headfake.field.faker.TimeField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, format='%H:%M')

Bases
headfake.field.core.FakerField headfake.field.core.Field

Create mock time using faker

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset (headfake.Fieldset) Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

class

headfake.field.faker.FirstNameField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, gender_field)

Bases
headfake.field.faker.NameField headfake.field.core.FakerField headfake.field.core.Field

Generate first name based on gender using the faker module (see NameField).

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset Fieldset to initialise from
Returns

None

class

headfake.field.faker.LastNameField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, gender_field)

Bases
headfake.field.faker.NameField headfake.field.core.FakerField headfake.field.core.Field

Generate last name using the faker module.

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset Fieldset to initialise from
Returns

None

class

headfake.field.faker.MiddleNameField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, gender_field, first_name_field)

Bases
headfake.field.faker.NameField headfake.field.core.FakerField headfake.field.core.Field

Mock middle name field.

Methods
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row The current data row as a dictionary
Returns

Dictionary containing multiple fields OR a single field value

class

headfake.field.faker.AddressField(line_no, transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING)

Bases
headfake.field.core.FakerField headfake.field.core.Field

Mock address line field.

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset (headfake.Fieldset) Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

class

headfake.field.faker.PostcodeField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING)

Bases
headfake.field.core.FakerField headfake.field.core.Field

Mock postcode field.

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset (headfake.Fieldset) Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

class

headfake.field.faker.PhoneField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, type='default')

Bases
headfake.field.core.FakerField headfake.field.core.Field

Mock phone number field.

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset (headfake.Fieldset) Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

class

headfake.field.faker.EmailField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, safe=True)

Bases
headfake.field.core.FakerField headfake.field.core.Field

Create mock email using faker

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset (headfake.Fieldset) Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

class

headfake.field.faker.PasswordField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, length=16, special_chars=True, digits=True, upper_case=True, lower_case=True)

Bases
headfake.field.core.FakerField headfake.field.core.Field

Create mock password using faker

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset (headfake.Fieldset) Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

class

headfake.field.faker.TextField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, max_length=50)

Bases
headfake.field.core.FakerField headfake.field.core.Field

Generate text using the faker.lorem provider. 'max_length' controls how long the text is allowed to be.

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset (headfake.Fieldset) Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value

class

headfake.field.faker.MemoField(transformers=NOTHING, final_transformers=NOTHING, name='field_1', hidden=False, error_value=None, transform=NOTHING, fake=NOTHING, sentences=3, exact=False)

Bases
headfake.field.core.FakerField headfake.field.core.Field

Generate paragraphs using the faker.lorem provider. 'sentences' controls the exact number of sentences, when 'exact' is set to True, when set to False it will return a variable number of sentences (never less than 1) +- 40% of the 'sentences' parameter.

Methods
  • init_from_fieldset(fieldset) Initialises field in fieldset.
  • next_value(row) (Union(any, dict(str: any))) Gets next generated value for field.
method
init_from_fieldset(fieldset)

Initialises field in fieldset.

This is run once all fields have been setup. It is generally used by fields in the fieldset to obtain information from other fields in the fieldset for later use.

Parameters
  • fieldset (headfake.Fieldset) Fieldset to initialise from
Returns

None

method
next_value(row)

Gets next generated value for field.

Acts as a decorator around the private '_next_value' method. If 'transformers' have been provided in the constructor they will act on the value after it has been generated.

Parameters
  • row (dict(str: any)) The current data row as a dictionary
Returns (Union(any, dict(str: any)))

Dictionary containing multiple fields OR a single field value