PyFunceble.config package

Submodules

PyFunceble.config.compare module

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

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

Provides the configuration comparision interface.

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.config.compare.ConfigComparison(*, local_config: Optional[dict] = None, upstream_config: Optional[dict] = None)[source]

Bases: object

Provides an interface for comparing 2 configuration.

DELETED_CORE = ['dns_lookup_over_tcp', 'generate_json', 'header_printed', 'iana_whois_server', 'idna_conversion', 'logs', 'maximal_processes', 'multiprocess_merging_mode', 'multiprocess', 'no_http_codes', 'outputs', 'shadow_file', 'status', 'store_whois_record', 'unified']
NEW_STATUS_CODES = {'potentially_down': [451], 'potentially_up': [308, 403, 418, 421, 422, 423, 424, 426, 428, 431, 506, 507, 508, 510, 511], 'up': [102, 207, 208, 226, 429]}
OLD_TO_NEW = {'adblock': 'cli_decoding.adblock', 'aggressive': 'cli_decoding.adblock_aggressive', 'auto_continue': 'cli_testing.autocontinue', 'ci': 'cli_testing.ci.active', 'ci_autosave_commit': 'cli_testing.ci.commit_message', 'ci_autosave_final_commit': 'cli_testing.ci.end_commit_message', 'ci_autosave_minutes': 'cli_testing.ci.max_exec_minutes', 'ci_branch': 'cli_testing.ci.branch', 'ci_distribution_branch': 'cli_testing.ci.distribution_branch', 'command': 'cli_testing.ci.command', 'command_before_end': 'cli_testing.ci.end_command', 'cooldown_time': 'cli_testing.cooldown_time', 'custom_ip': 'cli_testing.hosts_ip', 'days_between_db_retest': 'cli_testing.days_between.db_retest', 'days_between_inactive_db_clean': 'cli_testing.days_between.db_clean', 'db_type': 'cli_testing.db_type', 'debug': 'debug.active', 'dns_server': 'dns.server', 'filter': 'cli_testing.file_filter', 'generate_complements': 'cli_testing.complements', 'generate_hosts': 'cli_testing.file_generation.hosts', 'hierarchical_sorting': 'cli_testing.sorting_mode.hierarchical', 'inactive_database': 'cli_testing.inactive_db', 'less': 'cli_testing.display_mode.less', 'local': 'cli_testing.local_network', 'mining': 'cli_testing.mining', 'no_files': 'cli_testing.file_generation.no_file', 'plain_list_domain': 'cli_testing.file_generation.plain', 'print_dots': 'cli_testing.display_mode.dots', 'quiet': 'cli_testing.display_mode.dots', 'reputation': 'lookup.reputation', 'rpz': 'cli_decoding.rpz', 'show_execution_time': 'cli_testing.display_mode.execution_time', 'show_percentage': 'cli_testing.display_mode.percentage', 'simple': 'cli_testing.display_mode.simple', 'syntax': 'cli_testing.testing_mode.syntax', 'timeout': 'lookup.timeout', 'use_reputation_data': 'lookup.reputation', 'whois_database': 'cli_testing.whois_db', 'wildcard': 'cli_decoding.wildcard'}
OLD_TO_NEW_NEGATE = {'no_special': 'lookup.special', 'no_whois': 'lookup.whois', 'split': 'cli_testing.file_generation.unified_results'}
dict_helper = <PyFunceble.helpers.dict.DictHelper object>
get_merged() → dict[source]

Provides the merged configuration.

is_local_identical() → bool[source]

Checks if the local configuration is identical to the upstream one.

local_config

Provides the current state of the _local_config.

set_local_config(value: dict) → PyFunceble.config.compare.ConfigComparison[source]

Sets the local configuration to work with.

set_upstream_config(value: dict) → PyFunceble.config.compare.ConfigComparison[source]

Sets the upstram configuration to work with.

upstream_config

Provides the current state of the _upstream_config.

PyFunceble.config.loader module

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

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

Provides the configuration loader.

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.config.loader.ConfigLoader(merge_upstream: Optional[bool] = None)[source]

Bases: object

Provides the interface which loads and updates the configuration (if needed).

Parameters:merge_upstream

Authorizes the merging of the upstream configuration.

Note

If value is set to None (default), we fallback to the PYFUNCEBLE_AUTO_CONFIGURATION environment variable.

static conditional_switch(config: dict) → dict[source]

Given the configuration that we are going to load, switches some of setting.

Parameters:config – The configuration we are going to load.
config_file_exist() → bool[source]

Checks if the config file exists.

custom_config

Provides the current state of the _custom_config attribute.

default_config_file_exist() → bool[source]

Checks if the default configuration file exists.

destroy() → PyFunceble.config.loader.ConfigLoader[source]

Destroys everything loaded.

dict_helper = <PyFunceble.helpers.dict.DictHelper object>
classmethod download_dynamic_infrastructure_files() → PyFunceble.config.loader.ConfigLoader[source]

Downloads all the dynamicly (generated) infrastructure files.

Note

Downloaded if missing:
  • The IANA dump file.
  • The Public Suffix dump file.
file_helper = <PyFunceble.helpers.file.FileHelper object>
get_config_file_content() → dict[source]

Provides the content of the configuration file or the one already loaded.

get_configured_value(entry: str) → Any[source]

Provides the currently configured value.

Parameters:

entry

An entry to check.

multilevel should be separated with a point.

Raises:
  • RuntimeError – When the configuration is not loaded yet.
  • ValueError – When the given entry is not found.
install_missing_infrastructure_files() → PyFunceble.config.loader.ConfigLoader[source]

Installs the missing files (when needed).

Note

Installed if missing:
  • The configuration file.
  • The directory structure file.
static is_already_loaded() → bool[source]

Checks if the configuration was already loaded.

merge_upstream

Provides the current state of the _merge_upstream attribute.

path_to_config = None
path_to_default_config = None
path_to_overwrite_config = None
reload_config()[source]

Reload the configuration (if it was already loaded) after launching the decorated method.

set_custom_config(value: dict) → PyFunceble.config.loader.ConfigLoader[source]

Sets the custom configuration to set after loading.

Side Effect:
Directly inject into the configuration variables if it was already loaded.
set_merge_upstream(value: bool) → PyFunceble.config.loader.ConfigLoader[source]

Updates the value of _merge_upstream attribute.

start() → PyFunceble.config.loader.ConfigLoader[source]

Starts the loading processIs.

Module contents

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

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

Provides the configuration related submodules.

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.