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 domains, IPv4, IPv6 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:

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.

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.