Skip to content

Commit

Permalink
Fix methods types
Browse files Browse the repository at this point in the history
  • Loading branch information
funilrys committed Jun 16, 2018
1 parent 1a3829c commit 0691fc1
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 46 deletions.
4 changes: 2 additions & 2 deletions PyFunceble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
from PyFunceble.production import Production

CURRENT_DIRECTORY = getcwd() + directory_separator
VERSION = "0.81.8.dev-beta"
VERSION = "0.82.0.dev-beta"

CONFIGURATION_FILENAME = ".PyFunceble.yaml"

Expand Down Expand Up @@ -125,7 +125,7 @@ def load_config(): # pragma: no cover
DirectoryStructure()


def command_line(): # pragma: no cover # pylint: disable=too-many-branches,too-many-statements
def _command_line(): # pragma: no cover # pylint: disable=too-many-branches,too-many-statements
"""
This function provide the command line arguments of PyFunceble.
"""
Expand Down
24 changes: 12 additions & 12 deletions PyFunceble/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
from PyFunceble.helpers import Dict, Directory, Download, File


class Load(object):
class Load(object): # pylint: disable=too-few-public-methods
"""
This class will help to load the configurations.
Expand All @@ -86,8 +86,8 @@ def __init__(self, path_to_config):
self.path_to_config += PyFunceble.CONFIGURATION_FILENAME

try:
self.load_config_file()
self.install_iana_config()
self._load_config_file()
self._install_iana_config()
except FileNotFoundError:

if "PYFUNCEBLE_AUTO_CONFIGURATION" not in environ:
Expand All @@ -100,18 +100,18 @@ def __init__(self, path_to_config):

if isinstance(response, str):
if response.lower() == "y":
self.install_production_config()
self.load_config_file()
self.install_iana_config()
self._install_production_config()
self._load_config_file()
self._install_iana_config()
break

elif response.lower() == "n":
raise Exception("Unable to find the configuration file.")

else:
self.install_production_config()
self.load_config_file()
self.install_iana_config()
self._install_production_config()
self._load_config_file()
self._install_iana_config()

for main_key in ["domains", "hosts", "splited"]:
PyFunceble.CONFIGURATION["outputs"][main_key]["directory"] = Directory(
Expand Down Expand Up @@ -141,7 +141,7 @@ def __init__(self, path_to_config):
{"done": Fore.GREEN + "✔", "error": Fore.RED + "✘"}
)

def load_config_file(self):
def _load_config_file(self):
"""
This method will load .PyFunceble.yaml.
"""
Expand All @@ -150,7 +150,7 @@ def load_config_file(self):
Dict.from_yaml(File(self.path_to_config).read())
)

def install_production_config(self):
def _install_production_config(self):
"""
This method download the production configuration and install it in the
current directory.
Expand All @@ -170,7 +170,7 @@ def install_production_config(self):
return Download(production_config_link, self.path_to_config).text()

@classmethod
def install_iana_config(cls):
def _install_iana_config(cls):
"""
This method download `iana-domains-db.json` if not present.
"""
Expand Down
10 changes: 5 additions & 5 deletions PyFunceble/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def bypass(cls):
AutoSave(True, is_bypass=True)

@classmethod
def print_header(cls):
def _print_header(cls):
"""
Decide if we print or not the header.
"""
Expand Down Expand Up @@ -307,7 +307,7 @@ def domain(self, domain=None, last_domain=None):
The last domain of the file we are testing.
"""

self.print_header()
self._print_header()

if domain:
PyFunceble.CONFIGURATION["domain"] = self._format_domain(domain)
Expand Down Expand Up @@ -425,7 +425,7 @@ def _format_adblock_decoded(cls, to_format, result=None):

return result

def adblock_decode(self, list_to_test):
def _adblock_decode(self, list_to_test):
"""
Convert the adblock format into a readable format which is understood
by the system.
Expand Down Expand Up @@ -491,7 +491,7 @@ def file(self):
AutoContinue().restore()

if PyFunceble.CONFIGURATION["adblock"]:
list_to_test = self.adblock_decode(list_to_test)
list_to_test = self._adblock_decode(list_to_test)
else:
list_to_test = list(map(self._format_domain, list_to_test))

Expand Down Expand Up @@ -553,7 +553,7 @@ def url(self, url_to_test=None, last_url=None):
The last url of the file we are testing.
"""

self.print_header()
self._print_header()

if url_to_test:
PyFunceble.CONFIGURATION["URL"] = url_to_test
Expand Down
10 changes: 5 additions & 5 deletions PyFunceble/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def _analytic_file(self, new_status, old_status):
True,
).data()

def special_blogspot(self):
def _special_blogspot(self):
"""
Handle the blogspot SPECIAL case.
"""
Expand Down Expand Up @@ -305,7 +305,7 @@ def special_blogspot(self):
] + self.domain_status
break

def special_wordpress_com(self):
def _special_wordpress_com(self):
"""
Handle the wordpress.com special case.
"""
Expand Down Expand Up @@ -358,16 +358,16 @@ def up_status_file(self):
"directory"
] + self.domain_status

self.special_blogspot()
self._special_blogspot()
elif PyFunceble.HTTP_CODE["active"] and PyFunceble.CONFIGURATION[
"http_code"
] in PyFunceble.HTTP_CODE[
"list"
][
"potentially_up"
]:
self.special_blogspot()
self.special_wordpress_com()
self._special_blogspot()
self._special_wordpress_com()

if self.source != "SPECIAL":
self.domain_status = PyFunceble.STATUS["official"]["up"]
Expand Down
10 changes: 5 additions & 5 deletions PyFunceble/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
from PyFunceble import directory_separator, path, requests


class Hash(object):
class Hash(object): # pylint: disable=too-few-public-methods
"""
Get and return the hash a file with the given algorithm.
Expand Down Expand Up @@ -141,7 +141,7 @@ def get(self):
return result


class Command(object):
class Command(object): # pylint: disable=too-few-public-methods
"""
Shell command execution.
"""
Expand All @@ -150,7 +150,7 @@ def __init__(self, command): # pragma: no cover
self.decode_type = "utf-8"
self.command = command

def decode_output(self, to_decode):
def _decode_output(self, to_decode):
"""
Decode the output of a shell command in order to be readable.
Expand All @@ -176,9 +176,9 @@ def execute(self):
(output, error) = process.communicate()

if process.returncode != 0: # pragma: no cover
return self.decode_output(error)
return self._decode_output(error)

return self.decode_output(output)
return self._decode_output(output)


class Dict(object):
Expand Down
10 changes: 5 additions & 5 deletions PyFunceble/iana.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
from PyFunceble.lookup import Lookup


class IANA(object): # pragma: no cover
class IANA(object): # pragma: no cover # pylint: disable=too-few-public-methods
"""
Logic behind the update of `iana-domains-db.json`
"""
Expand All @@ -82,7 +82,7 @@ def __init__(self):
self.update()

@classmethod
def data(cls):
def _data(cls):
"""
Get the database from IANA website.
"""
Expand All @@ -91,7 +91,7 @@ def data(cls):
return Download(iana_url, return_data=True).text()

@classmethod
def referer(cls, extension):
def _referer(cls, extension):
"""
Return the referer for the given extension.
Expand Down Expand Up @@ -277,14 +277,14 @@ def _extensions(self, line):
]

if matched:
self.iana_db.update({matched: self.referer(matched)})
self.iana_db.update({matched: self._referer(matched)})

def update(self):
"""
Update the content of the `iana-domains-db` file.
"""

list(map(self._extensions, self.data().split("\n")))
list(map(self._extensions, self._data().split("\n")))
Dict(self.iana_db).to_json(self.destination)

if not PyFunceble.CONFIGURATION["quiet"]:
Expand Down
6 changes: 3 additions & 3 deletions PyFunceble/prints.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def __init__(self, to_print, template, output_file=None, only_on_file=False):

self.currently_used_header = {}

def before_header(self):
def _before_header(self):
"""
Print informations about PyFunceble and the date of generation of a file
into a given path, if doesn't exist.
Expand Down Expand Up @@ -255,7 +255,7 @@ def header(
self.currently_used_header = to_print

if not do_not_print:
self.before_header()
self._before_header()
for formated_template in self._header_constructor(to_print):
if not self.only_on_file:
print(formated_template)
Expand Down Expand Up @@ -358,7 +358,7 @@ def data(self): # pragma: no cover

to_print = self._data_constructor(to_print_size)

self.before_header()
self._before_header()

for data in self._header_constructor(to_print, False):
if self.template.lower() in PyFunceble.STATUS["list"][
Expand Down
2 changes: 1 addition & 1 deletion docs/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Code documentation
==================

.. automodule:: PyFunceble
:members: test, command_line
:members: test

Helpers
-------
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ def _get_long_description():
test_suite="setup._test_suite",
entry_points={
"console_scripts": [
"PyFunceble=PyFunceble:command_line",
"pyfunceble=PyFunceble:command_line",
"PyFunceble=PyFunceble:_command_line",
"pyfunceble=PyFunceble:_command_line",
]
},
)
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def test_adblock_decode(self):
This method test that the adblock decoding system is working proprely
"""

actual = Core.adblock_decode(Core, self.lines)
actual = Core._adblock_decode(Core, self.lines)

self.assertEqual(self.expected, actual)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def setUp(self):
"sha512": "f193ad6ee2cfbecd580225d8e6bfb9df1910e5ca6135b21b03ae208a007f71e9b57b55e299d27157551a18ef4dfdde23c96aaea796064846edc6cd25ac7eaf7f", # pylint: disable=line-too-long
}

def test_hash_data(self):
def testhash_data(self):
"""
This method will test Hash.hash_data().
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/test_prints.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def test_before_header(self, header_constructor_patch):
PyFunceble.LINKS["repo"], PyFunceble.CURRENT_TIME + " "
)

Prints(None, None, output_file=self.file, only_on_file=False).before_header()
Prints(None, None, output_file=self.file, only_on_file=False)._before_header()

self.assertEqual(expected, File(self.file).read())

Expand All @@ -139,7 +139,7 @@ def test_before_header(self, header_constructor_patch):
header_constructor_patch.return_value = ["Hello World!"]
Prints(
None, "Generic_File", output_file=self.file, only_on_file=False
).before_header()
)._before_header()

self.assertEqual(expected, File(self.file).read())

Expand Down
4 changes: 2 additions & 2 deletions version.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
current_version: 0.81.8.dev-beta
current_version: 0.82.0.dev-beta
deprecated: [0.0.0, 0.0.1, 0.65.0, 0.67.1, 0.68.0, 0.69.3, 0.69.5, 0.70.4, 0.71.2,
0.72.7, 0.73.1, 0.74.5, 0.75.1, 0.76.2, 0.77.0, 0.78.0, 0.79.1, 0.80.9]
0.72.7, 0.73.1, 0.74.5, 0.75.1, 0.76.2, 0.77.0, 0.78.0, 0.79.1, 0.80.9, 0.81.8]
force_update:
minimal_version: [0.0.0, 0.0.1]
status: true

0 comments on commit 0691fc1

Please sign in to comment.