Engine

Problematic

  • How to auto continue?
  • How to auto save?
  • How to implement a proper debugger?
  • How to get subjects related to a tested subject?
  • How to work with different database types?
  • How to sort our outputs?

Documentation

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

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

Provides the engine interfaces.

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, 2020 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.

AutoContinue()

class PyFunceble.engine.auto_continue.AutoContinue(filename, parent_process=False)[source]

Provides the auto-continue subsystem.

_AutoContinue__generate_complements()

Generates the complements from the given list of tested.

_AutoContinue__get_or_generate_complements_json()

Gets or generates the complements while working with as JSON formatted database.

_AutoContinue__get_or_generate_complements_mysql()

Gets or generates the complements while working with as MySQL/MariaDB formatted database.

add(subject, status)[source]

Adds the given subject into the database.

classmethod authorization()[source]

Provides the execution authorization.

clean()[source]

Cleans the database.

get_already_tested()[source]

Returns the list of subjects which were already tested as a set.

get_or_generate_complements()[source]

Gets or generates the complements.

classmethod get_table_name()[source]

Returns the name of the table to use.

is_empty()[source]

Checks if the database related to the currently tested file is empty.

load()[source]

Loads previously saved database.

save()[source]

Saves the current state of the database.

update_counters()[source]

Updates the counters.

AutoSave()

class PyFunceble.engine.auto_save.AutoSave(start_time=None)[source]

Provides the autosave interface.

classmethod get_current_ci()[source]

Provides the current CI to use.

is_time_exceed()[source]

Checks if the end time is exceed.

process(test_completed=False)[source]

Processes the autosave base on the current state of the test.

Parameters:test_completed (bool) – Tell us if we finished the test.

Logger()

class PyFunceble.engine.logger.Logger(debug=False, on_screen=False, output_directory=None)[source]

Provides our logging logic.

_Logger__get_handler(handler_type)

Provides a handler for of the given type.

_Logger__init_loggers()

Initiates all loggers.

_Logger__set_output_directory(output_directory)

Shares the given output directory.

Note

If the given output directory does not exists, we create it.

Parameters:output_directory (string) – The output directory.
authorization(debug)[source]

Provides the operation authorization.

critical(message)[source]

Logs the critical message.

debug(message)[source]

Logs the debug message.

error(message)[source]

Logs the error message.

exception()[source]

Logs the exception message.

fatal(message)[source]

Logs the fatal message.

format_to_apply = '[%(asctime)s::%(levelname)s::%(origin_path)s:%(origin_line)s@%(origin_func)s](PID%(process)s:%(processName)s): %(message)s'

The format to apply.

classmethod get_origin_info()[source]

Returns the information about where the logger was triggered.

Returns:A tuple, which is composed of the following.

(trigger file path, trigger line, trigger function/method name)

Return type:tuple
info(message)[source]

Logs the info message.

init(output_directory=None)[source]

Initiates the logger.

root_logger_format = '[%(asctime)s::%(levelname)s](PID%(process)s:%(processName)s): %(message)s'

The format to parse to the root logger (if used).

warning(message)[source]

Logs the warning message.

Mining()

class PyFunceble.engine.mining.Mining(filename, parent_process=False)[source]

Manages the minig subsystem.

classmethod authorization()[source]

Provides the operation authorization.

classmethod get_history(url)[source]

Gets the history of the given url.

Parameters:url (str) – An URL to call.
Returns:The list of links.
Return type:list
classmethod get_table_name()[source]

Returns the name of the table to use.

list_of_mined()[source]

Provides the list of mined domains so that they can be tested.

Returns:The list of mined domains.

The returned format is the following:

[
    (index_to_delete_after_test, mined),
    (index_to_delete_after_test, mined),
    (index_to_delete_after_test, mined)
]
Return type:list
load()[source]

Loads the content of the database file.

mine(subject, subject_type)[source]

Searches for domain or URL related to the original URL or domain. If some are found, we add them into the database.

Parameters:
  • subject (str) – The subject we are working with.
  • subject_typ (str) –

    The type of the subject.

    Can me one of the following:

    • url
    • domain
remove(subject, history_member)[source]

Removes the given subject from the database assigned to the currently tested file.

Parameters:
  • subject (str) – The subject we are working with.
  • history_member (str) – The history member to delete.
save()[source]

Saves the content of the database into the database file.

MySQL()

class PyFunceble.engine.mysql.MySQL[source]

Provides our way to work with our mysql/mariadb database.

are_tables_present()[source]

Checks if all our tables are present.

classmethod authorization()[source]

Provides the authorization to operate.

create_tables_and_apply_patches()[source]

Creates the tables of the database and apply the patches.

errors

alias of pymysql.err.IntegrityError

classmethod get_int_cast_type()[source]

Provides the right integer casting.

init_post_connection()[source]

Initiate everything needed after the connection.

init_pre_connection()[source]

Initiate everything needed before the connection.

classmethod parse_env_file(env_file_location)[source]

Parses the environment file into something we understand.

Parameters:env_file_location (str) – The location of the file we have to parse.
classmethod parse_mysql_sql_file()[source]

Parses our mysql.sql file into something we understand.

save_to_env_file(envs, env_file_location)[source]

Saves the given dict of environment variable into our environment file.

Parameters:
  • envs (dict) – A dict of environment variables to save.
  • env_file_location (str) – The location of the file we have to update.

Sort()

class PyFunceble.engine.sort.Sort[source]

Provides some sorting presets which we can parse to PyFunceble.helpers.list.List.custom_format.

classmethod hierarchical(element)[source]

The idea behind this method is to sort a list of domain hierarchicaly.

Parameters:element (str) – The element we are currently reading.
Returns:The formatted element.
Return type:str

Note

For a domain like aaa.bbb.ccc.tdl.

A normal sorting is done in the following order:
  1. aaa
  2. bbb
  3. ccc
  4. tdl
This method allow the sorting to be done in the following order:
  1. tdl
  2. ccc
  3. bbb
  4. aaa
classmethod standard(element)[source]

Implements the standard and alphabetical sorting.

Parameters:element (str) – The element we are currently reading.
Returns:The formatted element.
Return type:str