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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: str | list | None = None, *, encoding: str | None = None)[source]
Bases:
object
Shell command execution.
- Parameters:
- 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.
- set_command(value: str | list) CommandHelper [source]
Sets the command to use.
- Parameters:
value – The command to use/execute.
- set_encoding(value: str) 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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: 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: str | None = None, data: Any | None = 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) 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) 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) 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') 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: str | List[str]) 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) DictHelper [source]
Sets the subject to work with.
- Parameters:
value – The value to set.
- to_json(ensure_ascii: bool = False, indent: int = 4, sort_keys: bool = True, own_class: JSONEncoder | None = 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: JSONEncoder | None = 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.
- 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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: str | None = None)[source]
Bases:
object
Simplify the directories manipulation.
:param str dir_path the path to work with.
- create() DirectoryHelper [source]
Creates the given directory path.
- Returns:
The output of
self.exists
after the directory creation.
- delete() 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.
- set_path(value: str) 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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: str | None = None, *, certificate_validation: bool = True, retries: int = 3)[source]
Bases:
object
Simplification of the downloads.
- Parameters:
- property certificate_validation: bool
Provides the current state of the
certificate_validation
attribute.
- download_text(*, destination: str | None = 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.
- set_certificate_validation(value: bool) DownloadHelper [source]
Sets the value of the certificate validation.
- Parameters:
value – The value to set.
- set_retries(value: int) 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) DownloadHelper [source]
Sets the url to work with.
- Parameters:
value – The URL to set.
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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: str | None = None, env_file_path: str | None = 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() EnvironmentVariableHelper [source]
Deletes the given environment variable if exists.
- delete_from_env_file() EnvironmentVariableHelper [source]
Deletes the given environment file from the given dotenv file.
Warning
This method also delete the environment variable from the current environment.
- get_value(*, default: Any | None = None) 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: Any | None = None) Any | str [source]
Returns the value of the given environment variable if it exists in the given file path.
- set_env_file_path(value: str) EnvironmentVariableHelper [source]
Sets the location of the environment file to work with.
- Parameters:
value – The name to set.
- set_name(value: str) EnvironmentVariableHelper [source]
Sets the name of the environment variable to work with.
- Parameters:
value – The name to set.
- set_value(value: str) EnvironmentVariableHelper [source]
Sets the given value into the given environment variable name.
- set_value_in_env_file(value: str) 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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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:
PyFuncebleException
Describes the helper (related) exceptions.
- exception PyFunceble.helpers.exceptions.UnableToDownload[source]
Bases:
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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: str | None = None)[source]
Bases:
object
Simplify the file manipulations.
- Parameters:
path (str) – The file path to work with.
- copy(destination: str) FileHelper [source]
Copy the globaly given file path to the given destination.
- Parameters:
destination (str) – The destination of the copy.
- delete() FileHelper [source]
Deletes the given file path if it exists.
- move(destination) FileHelper [source]
Move the globally given file path to the given destination.
- Parameters:
destination (str) – The destination of the file.
- read(*, encoding: str = 'utf-8') str | None [source]
Read the given file path and return it’s content.
- Parameters:
encoding (str) – The encoding to use.
- set_path(value: str) FileHelper [source]
Sets the path to work with.
- Parameters:
value – The path to work with.
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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: str | None = 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.
- 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) 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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: List[Any] | None = 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) 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() ListHelper [source]
Removes the duplicates of the current list.
- remove_empty() ListHelper [source]
Removes the empty entries of the given list.
- set_subject(value: List[Any]) ListHelper [source]
Sets the subject to work with.
- Parameters:
value – The subject to work with.
- sort(*, reverse: bool = False) ListHelper [source]
Sorts the given list (of string preferably).
- param bool reverse:
Tell us if we have to reverse the list.
- property 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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: Any | None = 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.
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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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: str | None = 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.
- 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) 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.
- 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) RegexHelper [source]
Sets the regex to work with.
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:
- Contributors:
- Project link:
- Project documentation:
- Project homepage:
License:
Copyright 2017, 2018, 2019, 2020, 2022, 2023, 2024 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
https://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.