faker_file package

Subpackages

Submodules

faker_file.base module

class faker_file.base.BytesValue(value, *args, **kwargs)[source]

Bases: bytes

data: Dict[str, Any]
faker_file.base.DEFAULT_FORMAT_FUNC(generator: Union[Faker, Generator, Provider], content: str) str
class faker_file.base.DynamicTemplate(content_modifiers: List[Tuple[Callable, Dict[str, Any]]])[source]

Bases: object

Dynamic template.

class faker_file.base.FileMixin[source]

Bases: object

File mixin.

extension: str
formats: List[str]
generator: Union[Faker, Generator, Provider]
numerify: Callable
random_element: Callable
class faker_file.base.StringList(strings: Optional[List[str]] = None, separator: str = ' ')[source]

Bases: object

String list.

Usage example:

my_string = StringList(separator="
“)

my_string += “grape” my_string += “peaches” print(my_string)

add_string(value: str) None[source]
remove_string(value: str) None[source]
class faker_file.base.StringValue(value, *args, **kwargs)[source]

Bases: str

data: Dict[str, Any]
faker_file.base.parse_format_func(generator: Union[Faker, Generator, Provider], content: str) str[source]
faker_file.base.pystr_format_func(generator: Union[Faker, Generator, Provider], content: str) str[source]
faker_file.base.returns_list(func: Callable) bool[source]

Checks if callable returns a list of Union[BytesValue, StringValue].

Returns True if it’s a List. Returns False otherwise.

faker_file.constants module

faker_file.helpers module

faker_file.helpers.load_class_from_path(full_path: str) Type[source]

Load a class from a given full path string identifier.

Parameters:

full_path – The full path to the class, e.g. ‘module.submodule.MyClass’.

Returns:

The loaded class.

Raise:

If the module cannot be found or the class does not exist in the module, it raises ImportError.

Usage example:

my_class = load_class_from_path("module.submodule.MyClass")
instance = my_class()
faker_file.helpers.random_pop(lst: list) Any[source]

Randomly pops element from the given list. Alters the list.

Parameters:

lst – List to pop element from.

Returns:

A single element from the list.

Usage example:

from faker_file.helpers import random_pop
my_list = [1, 2, 3, 4, 5]
element = random_pop(my_list)
faker_file.helpers.wrap_text(text: str, wrap_chars_after: int) str[source]

faker_file.registry module

class faker_file.registry.FileRegistry[source]

Bases: object

Stores list StringValue instances.

from faker import Faker
from faker_file.providers.txt_file import TxtFileProvider

FAKER = Faker()
FAKER.add_provider(TxtFileProvider)

txt_file_1 = FAKER.txt_file()
txt_file_2 = FAKER.txt_file()
...
txt_file_n = FAKER.txt_file()

# The FileRegistry._registry would then contain this:
{
    txt_file_1,
    txt_file_2,
    ...,
    txt_file_n,
}
add(string_value: StringValue) None[source]
clean_up() None[source]
remove(string_value: Union[StringValue, str]) bool[source]
search(value: str) Optional[StringValue][source]

Module contents