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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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
¶ 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 thatexecute()
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.
-
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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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 aNone
.
-
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.
- key_to_rename –
-
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: 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.
-
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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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.
-
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.
-
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.
-
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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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: -
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 toNone
, 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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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.
-
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.
-
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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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.
-
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.
-
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.
-
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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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 notstr
orbytes
.
-
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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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 alist
.
-
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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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.
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/latest/
- Project homepage:
- https://pyfunceble.github.io/
License:
Copyright 2017, 2018, 2019, 2020, 2021 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.