PyFunceble.helpers package

Submodules

PyFunceble.helpers.command module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the command helpers. This helpers let us run Shell commands.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.command.CommandHelper(command: Union[str, list, None] = None, *, encoding: Optional[str] = None)[source]

Bases: object

Shell command execution.

Parameters:
  • command (str) – The command to execute.
  • encoding (str) – The encoding to use to decode the shell output.
command

Provides the current state of the _command attribute.

encoding

Provides the current state of the _encoding attribute.

execute(*, raise_on_error: bool = False) → str[source]

Execute the given command.

Parma raise_on_error:
 Raises on error if set to True.
Returns:The output of the command.
Raises:RuntimeError – When the exit code is not equal to 0.
run(rstrip: bool = True) → Generator[str, None, None][source]

Run the given command and yield each line(s) one by one.

Note

The difference between this method and execute() is that execute() wait for the process to end in order to return its output while this method return each line one by one - as they are outputed.

Parameters:rstrip (bool) – Deactivates the rstrip of the output.
run_to_stdout() → None[source]

Run the given command and print each line(s) to stdout.

set_command(value: Union[str, list]) → PyFunceble.helpers.command.CommandHelper[source]

Sets the command to use.

Parameters:value – The command to use/execute.
set_encoding(value: str) → PyFunceble.helpers.command.CommandHelper[source]

Sets the encoding to use.

Parameters:value – The value to set.

PyFunceble.helpers.dict module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the dict helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.dict.DictHelper(subject: Union[Any, dict, None] = None)[source]

Bases: object

Simplify some dict manipulation.

Parameters:main (dict) – The main dict to work with.
Raises:TypeError – When main is not a dict nor a list (tolarated).
flatten(*, separator: str = '.', previous: Optional[str] = None, data: Optional[Any] = None) → dict[source]

Flatten the current dictionnary.

Parameters:
  • separator – The separator to apply.
  • previous – The previous key we are working with.
  • data – The data to work with. If not given, we fallback to self.subject.
static from_json(json_str: str, return_dict_on_error: bool = True) → Union[List[Any], dict, None][source]

Converts a given JSON string to dict/list.

Parameters:
  • json_str – The JSON string ot convert.
  • return_dict_on_error – Returns a dict instead of a None.
static from_json_file(file_path: str, encoding: str = 'utf-8', return_dict_on_error: bool = True) → Union[List[Any], dict, None][source]

Reads the given file path and convert it’s content to dict/list (tolarated).

Parameters:
  • file_path – The file path.
  • return_dict_on_error – Return a dict instead of a NoneType.
Parma encoding:

The encoding to use.

static from_yaml(yaml_str) → Union[List[Any], dict][source]

Converts the given YAML string to dict/list.

Parameters:yaml_str (str) – The YAML string to convert.
static from_yaml_file(file_path: str, encoding: str = 'utf-8') → Union[List[Any], dict][source]

Converts a given YAML formatted file, into dict/list.

Parameters:
  • file_path – The file path.
  • encoding – The encoding to use.
has_same_keys_as(to_check: dict, loop: bool = False) → bool[source]

Checks if keys are presents in both given dict.

Parameters:
  • to_check – The dict to compare with.
  • loop – DO NOT USE, only used to tell us wen to return the list of dataset or the final result.
remove_key(key_to_remove: Union[str, List[str]]) → Union[Any, dict, None][source]

Remove a given key from a given dictionary.

Parameters:key_to_remove – The key(s) to delete.
Returns:The dict without the given key(s).
rename_key(key_to_rename: dict, strict: bool = True) → dict[source]

Rename the given keys from the given dictionary.

Parameters:
  • key_to_rename

    The key(s) to rename.

    Expected format: {old:new}

  • strict – Tell us if we have to rename the exact index or the index which looks like the given key(s)
Returns:

The well formatted dict.

set_subject(value: Any) → PyFunceble.helpers.dict.DictHelper[source]

Sets the subject to work with.

Parameters:value – The value to set.
subject

Provides the current state of the _subject attribute.

to_json(ensure_ascii: bool = False, indent: int = 4, sort_keys: bool = True, own_class: Optional[json.encoder.JSONEncoder] = None) → str[source]

Converts a given dict to JSON and return the json string.

Parameters:
  • ensure_ascii – Avoids unicode.
  • indent – The indentation to apply.
  • sort_keys – Sort the keys.
  • own_class – A class to use for the conversion to json.
to_json_file(file_path: str, ensure_ascii: bool = False, indent: int = 4, sort_keys: bool = True, encoding: str = 'utf-8', own_class: Optional[json.encoder.JSONEncoder] = None) → None[source]

Converts the given dict to JSON and save the result into a given file path.

Parameters:
  • file_path – The file path.
  • ensure_ascii – Avoids unicode.
  • indent – The indentation to apply.
  • sortkeys – Sorts the keys.
  • encoding – The encoding to apply.
  • own_class – A class to use for the conversion to json.
to_yaml(encoding: str = 'utf-8', default_flow_style: bool = False, indent: int = 4, allow_unicode: bool = True, sort_keys: bool = True) → str[source]

Converts the given dict/list to the YAML format and return the result.

Parameters:
  • encoding (str) – The encoding to use.
  • default_flow_style (bool) – Uses the default flow style.
  • indent (int) – The indentation to apply.
  • allow_unicode (bool) – Allows the decoding of unicode chars.
  • sort_keys (bool) – Sors the keys.
Return type:

dict|list

to_yaml_file(file_path: str, encoding: str = 'utf-8', default_flow_style: bool = False, indent: int = 4, allow_unicode: bool = True, sort_keys: bool = True) → None[source]

Converts the given dict/list to YAML and save the result into a file.

Parameters:
  • file_path – The file path.
  • encoding – The encoding.
  • default_flow_style – Uses the default flow style.
  • indent – The indentation to apply.
  • allow_unicode – Allows the decoding of unicode chars.
  • sort_keys – Sorts the keys.
unflatten(*, separator: str = '.', data: Optional[Any] = None)[source]

Unflatten a previously flatten dictionnary.

Parameters:separator – The separator to split.

PyFunceble.helpers.directory module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the directory helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.directory.DirectoryHelper(path: Optional[str] = None)[source]

Bases: object

Simplify the directories manipulation.

:param str dir_path the path to work with.

create() → PyFunceble.helpers.directory.DirectoryHelper[source]

Creates the given directory path.

Returns:The output of self.exists after the directory creation.
delete() → PyFunceble.helpers.directory.DirectoryHelper[source]

Deletes the given directory path.

Returns:not self.exists after the directory deletion.
exists() → bool[source]

Checks if the given directory exists.

static get_current(*, with_end_sep: bool = False) → str[source]

Returns the current directory path.

Parameters:with_end_sep (bool) – Add a directory separator at the end.
join_path(*args) → str[source]

Joins the given arguments with the given path.

list_all_files() → List[str][source]

Lists all files of the current path.

list_all_subdirectories() → List[str][source]

Provides the list of all subdirectories of the current path.

path

Provides the current state of the _path attribute.

realpath

Returns the real path of the current path.

set_path(value: str) → PyFunceble.helpers.directory.DirectoryHelper[source]

Sets the directory path to work with.

Parameters:value – The path to set.

PyFunceble.helpers.download module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the download helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.download.DownloadHelper(url: Optional[str] = None, *, certificate_validation: bool = True, retries: int = 3)[source]

Bases: object

Simplification of the downloads.

Parameters:
  • url (str) –
  • retry (int) – The number of time we have to retry before raising an exception.
certificate_validation

Provides the current state of the certificate_validation attribute.

download_text(*, destination: Optional[str] = None) → str[source]

Download the body of the set url.

Note

if destination is set to None, we only return the output.

Otherwise, we save the output into the given destination, but we also return the output.

Parameters:destination – The download destination.
Raises:UnableToDownload – When could not unable to download the URL.
retries

Provides the current state of the _retries attributes.

set_certificate_validation(value: bool) → PyFunceble.helpers.download.DownloadHelper[source]

Sets the value of the certificate validation.

Parameters:value – The value to set.
set_retries(value: int) → PyFunceble.helpers.download.DownloadHelper[source]

Sets the number of retries we are allowed to perform before raising an exception.

Parameters:value – The number of retry to apply.i
set_url(value: str) → PyFunceble.helpers.download.DownloadHelper[source]

Sets the url to work with.

Parameters:value – The URL to set.
url

Provides the current state of the _url attribute.

PyFunceble.helpers.environment_variable module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the environment variable helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.environment_variable.EnvironmentVariableHelper(name: Optional[str] = None, env_file_path: Optional[str] = None)[source]

Bases: object

Simplify the way we work with environment variable.

Parameters:name (str) – The name of the environment variable to work with.
delete() → PyFunceble.helpers.environment_variable.EnvironmentVariableHelper[source]

Deletes the given environment variable if exists.

delete_from_env_file() → PyFunceble.helpers.environment_variable.EnvironmentVariableHelper[source]

Deletes the given environment file from the given dotenv file.

Warning

This method also delete the environment variable from the current environment.

env_file_path

Provides the current state of the _env_file_path attribute.

exists() → bool[source]

Checks if the given environment variable name exists.

get_value(*, default: Optional[Any] = None) → Union[Any, str][source]

Returns the value of the given environment variable name (if exists.)

Parameters:default – The default value to return.
get_value_from_env_file(*, default: Optional[Any] = None) → Union[Any, str][source]

Returns the value of the given environment variable if it exists in the given file path.

name

Provides the current state of the _name attribute.

set_env_file_path(value: str) → PyFunceble.helpers.environment_variable.EnvironmentVariableHelper[source]

Sets the location of the environment file to work with.

Parameters:value – The name to set.
set_name(value: str) → PyFunceble.helpers.environment_variable.EnvironmentVariableHelper[source]

Sets the name of the environment variable to work with.

Parameters:value – The name to set.
set_value(value: str) → PyFunceble.helpers.environment_variable.EnvironmentVariableHelper[source]

Sets the given value into the given environment variable name.

Parameters:value (str) – The value to set.
Raises:TypeError – When value is not a value.
set_value_in_env_file(value: str) → PyFunceble.helpers.environment_variable.EnvironmentVariableHelper[source]

Sets the given value and save it into the given dotenv file.

Warning

This method also set the environment variable from the current environment.

Parameters:value – The value to set.

PyFunceble.helpers.exceptions module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the exceptions related to the helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
exception PyFunceble.helpers.exceptions.PyFuncebleHelperException[source]

Bases: PyFunceble.exceptions.PyFuncebleException

Describes the helper (related) exceptions.

exception PyFunceble.helpers.exceptions.UnableToDownload[source]

Bases: PyFunceble.helpers.exceptions.PyFuncebleHelperException

Describes a failing download.

PyFunceble.helpers.file module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the file helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.file.FileHelper(path: Optional[str] = None)[source]

Bases: object

Simplify the file manipulations.

Parameters:path (str) – The file path to work with.
copy(destination: str) → PyFunceble.helpers.file.FileHelper[source]

Copy the globaly given file path to the given destination.

Parameters:destination (str) – The destination of the copy.
delete() → PyFunceble.helpers.file.FileHelper[source]

Deletes the given file path if it exists.

exists() → bool[source]

Checks if the given file path exists.

get_size() → int[source]

Provides the size (in bytes) of the given file path.

is_empty() → bool[source]

Checks if the given file path is empty.

join_path(*args) → str[source]

Joins the given arguments with the given path.

move(destination) → PyFunceble.helpers.file.FileHelper[source]

Move the globally given file path to the given destination.

Parameters:destination (str) – The destination of the file.
open(*args, **kwargs) → io.open[source]

A wrapper for the built-in open function.

path

Provides the current state of the _path attribute.

read(*, encoding: str = 'utf-8') → Optional[str][source]

Read the given file path and return it’s content.

Parameters:encoding (str) – The encoding to use.
read_bytes() → Optional[bytes][source]

Read the given file ath and returns it’s bytes contetn.

set_path(value: str) → PyFunceble.helpers.file.FileHelper[source]

Sets the path to work with.

Parameters:value – The path to work with.
write(data: Any, *, overwrite: bool = False, encoding: str = 'utf-8') → PyFunceble.helpers.file.FileHelper[source]

Write the given data into the given file path.

Parameters:
  • data – The data to write.
  • encoding – The encoding to use while opening the file.

PyFunceble.helpers.hash module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the hashing helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.hash.HashHelper(algo: Optional[str] = None)[source]

Bases: object

Simplify the hashing of data or file content.

Parameters:algo (str) – The algorithm to use for hashing.
Raises:ValueError – When the given algo is not known.
algo

Provides the current state fo the _algo attribute.

hash_data(data: Union[str, bytes]) → str[source]

Hashes the given data.

Parameters:data – The data to hash.
Raises:TypeError – When data is not str or bytes.
hash_file(file_path: str) → str[source]

Hashes the content of the given file.

Parameters:file_path – The path of the file to read.
set_algo(value: str) → PyFunceble.helpers.hash.HashHelper[source]

Sets the algorithm to work with.

Parameters:value – The name of the hash to use.

PyFunceble.helpers.list module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the list helpers

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.list.ListHelper(subject: Optional[List[Any]] = None)[source]

Bases: object

Simplify the list manipulation.

Parameters:
  • subject – The list to work with.
  • remove_empty (bool) – Process the deletion of empty strings.
custom_sort(key_method: Any, *, reverse: bool = False) → PyFunceble.helpers.list.ListHelper[source]

Sorts the list with the given key method.

Parameters:
  • key_method (function|method) – A function or method to use to format the readed element before sorting.
  • reverse (bool) – Tell us if we have to reverse the list.
remove_duplicates() → PyFunceble.helpers.list.ListHelper[source]

Removes the duplicates of the current list.

remove_empty() → PyFunceble.helpers.list.ListHelper[source]

Removes the empty entries of the given list.

set_subject(value: List[Any]) → PyFunceble.helpers.list.ListHelper[source]

Sets the subject to work with.

Parameters:value – The subject to work with.
sort(*, reverse: bool = False) → PyFunceble.helpers.list.ListHelper[source]

Sorts the given list (of string preferably).

param bool reverse:
 Tell us if we have to reverse the list.
subject

Provides the current state of the _subject attribute.

PyFunceble.helpers.merge module

The tool to check the availability or syntax of dosubject, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the merging helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.merge.Merge(subject: Optional[Any] = None)[source]

Bases: object

Simplify the merging of dict and list.

Parameters:subject – The subject to work with.
into(origin: Any, strict: bool = True) → Any[source]

Process the mergin.

Parameters:
  • origin – The original data.
  • strict – Activates the strict mode.
set_subject(value: Any) → PyFunceble.helpers.merge.Merge[source]

Sets the subject to work with.

Parameters:value – The subject to work with.
Raises:TypeError – When value is not a list.
subject

Provides the current state of the _subject attribute.

PyFunceble.helpers.regex module

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the regular expressions helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
class PyFunceble.helpers.regex.RegexHelper(regex: Optional[str] = None, escape_regex: bool = False)[source]

Bases: object

Simplify the regex matching and usage.

Parameters:
  • regex (str) – The regex to use.
  • escape_regex – Escapes the given regex.
escape_regex = False
get_matching_list(data: List[str]) → List[str][source]

Returns the strings which does the match the regex in the given data.

get_not_matching_list(data: List[str]) → List[str][source]

Returns the strings which does not the match the regex in the given data.

match(data: str, *, rematch: bool = False, group: int = 0, return_match: bool = True) → Union[bool, str, List[str]][source]

Checks if the given data match the given regex string.

Parameters:
  • data – The data to work with.
  • rematch

    The equivalent of the $BASH_REMATCH but in Python.

    It’s basically a list of all groups.

  • group – The group to return when return_match is set to True.
  • return_match – Return the part that match the given regex string.
regex

Provides the current state of the _regex attribute.

replace_match(data: str, replacement: str, *, occurences: int = 0, multiline: bool = False) → str[source]

Replaces the string which match the regex string with the given replacement.

Parameters:
  • data – The data to work with.
  • replacement – The replacement of the matched regex.
  • occurences

    The number of occurences to replace.

    Note

    0 means all occurences.

set_regex(value: str) → PyFunceble.helpers.regex.RegexHelper[source]

Sets the regex to work with.

Parameters:value – The regex to work with.
Raises:TypeError – When value is not str.
split(data: str) → List[str][source]

Split the reference of the given regex.

Parameters:data (str) – The data to work with.
Return type:list

Module contents

The tool to check the availability or syntax of domain, IP or URL.

██████╗ ██╗   ██╗███████╗██╗   ██╗███╗   ██╗ ██████╗███████╗██████╗ ██╗     ███████╗
██╔══██╗╚██╗ ██╔╝██╔════╝██║   ██║████╗  ██║██╔════╝██╔════╝██╔══██╗██║     ██╔════╝
██████╔╝ ╚████╔╝ █████╗  ██║   ██║██╔██╗ ██║██║     █████╗  ██████╔╝██║     █████╗
██╔═══╝   ╚██╔╝  ██╔══╝  ██║   ██║██║╚██╗██║██║     ██╔══╝  ██╔══██╗██║     ██╔══╝
██║        ██║   ██║     ╚██████╔╝██║ ╚████║╚██████╗███████╗██████╔╝███████╗███████╗
╚═╝        ╚═╝   ╚═╝      ╚═════╝ ╚═╝  ╚═══╝ ╚═════╝╚══════╝╚═════╝ ╚══════╝╚══════╝

Provides the helpers.

Author:
Nissar Chababy, @funilrys, contactTATAfunilrysTODTODcom
Special thanks:
https://pyfunceble.github.io/#/special-thanks
Contributors:
https://pyfunceble.github.io/#/contributors
Project link:
https://github.com/funilrys/PyFunceble
Project documentation:
https://pyfunceble.readthedocs.io/en/dev/
Project homepage:
https://pyfunceble.github.io/

License:

Copyright 2017, 2018, 2019, 2020, 2022 Nissar Chababy

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.