Converter

Problematic

How can we convert some data into something else or something our system understand.

Documentation

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

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

Provides the converters.

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:

Copyright 2017, 2018, 2019, 2020 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.

ConverterBase()

class PyFunceble.converter.base.ConverterBase(data_to_convert)[source]

Provides the converter base.

Parameters:data_to_convert – The data to convert.
get_converted()[source]

Provides the converted data.

AdBlock()

class PyFunceble.converter.adblock.AdBlock(data_to_convert, aggressive=False)[source]

Converts an adblock filter line to a list os subject to test.

_AdBlock__decode_v1(data)

Decodes the v1.

Parameters:data (str) – A string to decode.
Return type:list
_AdBlock__decode_v2(data)

Decodes the v2.

Parameters:data (str) – A string to decode.
Return type:list
_AdBlock__decode_v3(data)

Decodes the v3.

Parameters:data (str) – A string to decode.
Return type:list
_AdBlock__decode_v4(data)

Decodes the v4.

Parameters:data (str) – A string to decode.
Return type:list
extract_base(subject)[source]

Extracts the base of the given element.

As an example:
given "hello.world/?is=beautiful" returns "hello.world"
Parameters:subject – The subject to work with.
extract_from_options(options)[source]

Exctracts the relevant data from the list of options.

Parameters:options (list) – The list of options of a rule.
Returns:The list of domains.
Return type:list
format_decoded(decoded, result=None)[source]

Formats the extracted adblock line in order to be compatible with what the system understand.

Parameters:
  • decoded (str) – The decoded data to work with.
  • result (list) – A list of the result of this method.
Returns:

The list of domains or IP compatible with the system.

Return type:

list

get_converted()[source]

Converts and return the result of the conversion.

Return type:list
classmethod ignore_it(subject)[source]

Checks if we have to ignore the given subject.

Parameters:subject (str) – The subject ot work with.
Returns:The result of the check.
Return type:bool
remove_ignored(subject)[source]

Removes the ignored element from the given list of subject.

Digit2Digits()

class PyFunceble.converter.digit2digits.Digit2Digits(data_to_convert)[source]

Converts a given digit to a 2 digits string.

File()

class PyFunceble.converter.file.File(data_to_convert)[source]

Converts a line to a subject to test.

get_converted()[source]

Provides the converted data.

Warning

This method returns return None if no subject of interest was found.

Return type:None, str, list

InternalUrl()

class PyFunceble.converter.internal_url.InternalUrl(data_to_convert)[source]

Converter of the internal URLs.

Note

The internal URLs are actually the URL that has nothing to do with what we are going to test.

They are only relevant for the software itself.

Parameters:data_to_convert (str) – The data to convert
to_right_url()[source]

Process the conversion to the right URL.