Configuration

Problematics

  • How can we avoid the usage of tool.py?
  • How can we make personalization more simple?
  • How can we automaticaly merge the new configuration with the local one?

Documentation

The tool to check the availability or syntax of domains, IPv4 or URL.

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

This submodule will provide the configuration loading and construction logic.

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

License:

MIT License

Copyright (c) 2017, 2018, 2019 Nissar Chababy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
class PyFunceble.config.Load(path_to_config)[source]

Help us load the configuration(s) file(s).

Parameters:path_to_config (str) – The possible path to the configuration to load.
_install_db_type_files()[source]

Create the .db_type directory if it does not exists and update its content.

_install_directory_structure_file()[source]

Download the latest version of dir_structure_production.json.

_install_iana_config()[source]

Download iana-domains-db.json if not present.

_install_production_config()[source]

Download the production configuration and install it in the current directory.

_install_psl_config()[source]

Download public-suffix.json if not present.

_load_config_file()[source]

Load .PyFunceble.yaml into the system.

classmethod _set_path_to_configs(path_to_config)[source]

Set the paths to the configuration files.

Parameters:path_to_config (str) – The possible path to the config to load.
Returns:The path to the config to read (0), the path to the default configuration to read as fallback.(1)
Return type:tuple
class PyFunceble.config.Merge(configuration_path)[source]

Merge the old into the new configuration file.

Parameters:configuration_path (str) – The path to the configuration file to update.
_load()[source]

Execute the logic behind the merging.

_merge_values()[source]

Simply merge the older into the new one.

_save()[source]

Save the new configuration inside the configuration file.

class PyFunceble.config.Version(used=False)[source]

Compare the local with the upstream version.

Parameters:used (bool) – True: Version is configured for simple usage. False: Version compare local with upstream.
classmethod check_versions(local, upstream)[source]

Compare the given versions.

Parameters:
  • local (list) – The local version converted by split_versions().
  • upstream (list) – The upstream version converted by split_versions().
Returns:

  • True: local < upstream
  • None: local == upstream
  • False: local > upstream

Return type:

bool|None

classmethod check_versions_literally(local, upstream)[source]

Compare the given versions literally.

Parameters:
  • local (str) – The local version converted by split_versions().
  • upstream (str) – The upstream version converted by split_versions().
Returns:

  • True: local == upstream
  • False: local != upstream

Return type:

bool

compare()[source]

Compare the current version with the upstream saved version.

classmethod is_cloned()[source]

Let us know if we are currently in the cloned version of PyFunceble which implicitly mean that we are in developement mode.

classmethod right_url_from_version(url)[source]

Convert the GitHub URL to the right one depending of the branch or version we are working with.

Parameters:url (str) – The URL to convert.
Returns:The converted URL.
Return type:str
classmethod split_versions(version, return_non_digits=False)[source]

Convert the versions to a shorter one.

Parameters:
  • version (str) – The version to split.
  • return_non_digits (bool) – Activate the return of the non-digits parts of the splitted version.
Returns:

The splitted version name/numbers.

Return type:

list