diff --git a/src/bootstraparse/bparse.py b/src/bootstraparse/bparse.py index a1385d8..c303efd 100644 --- a/src/bootstraparse/bparse.py +++ b/src/bootstraparse/bparse.py @@ -1,4 +1,4 @@ # Main program, use this to start parsing -def totest(): - print("This is a test") \ No newline at end of file +def to_test(): + print("This is a test") diff --git a/src/bootstraparse/modules/config.py b/src/bootstraparse/modules/config.py index 599a0b4..053323a 100644 --- a/src/bootstraparse/modules/config.py +++ b/src/bootstraparse/modules/config.py @@ -3,23 +3,23 @@ import yaml -class ConfigLoader(): +class ConfigLoader: """ Reads config files. """ def __init__(self, configfile): with open(configfile, "r") as f: - self.loadedconf = yaml.safe_load(f) + self.loaded_conf = yaml.safe_load(f) def __getitem__(self, item): try: - return self.loadedconf[item] + return self.loaded_conf[item] except KeyError: print("Argument", item, "not found.") def __repr__(self): - return(self.loadedconf.__repr__()) + return self.loaded_conf.__repr__() class UserConfig(ConfigLoader): diff --git a/src/bootstraparse/modules/environment.py b/src/bootstraparse/modules/environment.py index 55d701c..9c017ce 100644 --- a/src/bootstraparse/modules/environment.py +++ b/src/bootstraparse/modules/environment.py @@ -1,9 +1,6 @@ # Module for containing super important variables -import rich - - class Environment: """ Object containing all the important variables, diff --git a/src/bootstraparse/modules/pathresolver.py b/src/bootstraparse/modules/pathresolver.py index 6c75b53..c09bf83 100644 --- a/src/bootstraparse/modules/pathresolver.py +++ b/src/bootstraparse/modules/pathresolver.py @@ -3,28 +3,28 @@ import os -class pathresolver(): +class PathResolver: """ - Intialised with a relative path and returns the translated absolute path + Initialised with a relative path and returns the translated absolute path """ - def __init__(self, basepath): - self.basepath = os.path.normpath(basepath) + def __init__(self, base_path): + self.base_path = os.path.normpath(base_path) - def __call__(self, relativepath='.'): - return self.giveabsolute(relativepath) + def __call__(self, relative_path='.'): + return self.give_absolute(relative_path) - def giveabsolute(self, relativepath='.'): - return os.path.normpath(os.path.join(self.basepath, relativepath)) + def give_absolute(self, relative_path='.'): + return os.path.normpath(os.path.join(self.base_path, relative_path)) -class boostrapath(pathresolver): +class BoostraPath(PathResolver): """ - Initialises pathresolver with the path of the bootstraparse installation folder + Initialises PathResolver with the path of the bootstraparse installation folder """ def __init__(self): - calculatedpath = os.path.join(__file__, "../../") - super().__init__(calculatedpath) + calculated_path = os.path.join(__file__, "../../") + super().__init__(calculated_path) -bpath = boostrapath() +b_path = BoostraPath() diff --git a/src/bootstraparse/modules/sitecreator.py b/src/bootstraparse/modules/sitecreator.py index afc517b..ead751e 100644 --- a/src/bootstraparse/modules/sitecreator.py +++ b/src/bootstraparse/modules/sitecreator.py @@ -1,7 +1,7 @@ # Module sequencing the successive actions necessary for website building import bootstraparse.modules.config as config -from bootstraparse.modules.pathresolver import bpath +from bootstraparse.modules.pathresolver import b_path def create_website(): @@ -24,7 +24,7 @@ def create_config(): """ Returns globalConfig as an object from parser_config.yml settings. """ - return config.GlobalConfig(bpath("configs/parser_config.yml")) + return config.GlobalConfig(b_path("configs/parser_config.yml")) def create_crawler(): diff --git a/src/bootstraparse/testrun.py b/src/bootstraparse/testrun.py deleted file mode 100644 index c66e6f0..0000000 --- a/src/bootstraparse/testrun.py +++ /dev/null @@ -1,6 +0,0 @@ -from bootstraparse.modules.pathresolver import bpath -import bootstraparse.modules.sitecreator - - -print(bpath()) -print(bootstraparse.modules.sitecreator.create_config()) diff --git a/tests/modules/test_environmemt.py b/tests/modules/test_environmemt.py index 001166d..f199613 100644 --- a/tests/modules/test_environmemt.py +++ b/tests/modules/test_environmemt.py @@ -1,8 +1,7 @@ -from logging import exception import bootstraparse.modules.environment as e -def test_was_initialised(): +def test_wasInitialised(): test_check = e.Environment() for k in test_check._wasInitialised.values(): assert k is False @@ -11,7 +10,7 @@ def test_was_initialised(): def test_integrity_check(): test_check = e.Environment() custom_test_p = [p for p in test_check._mParams.keys()] - custom_test_v = [False for p in test_check._mParams.values()] + custom_test_v = [False for _ in test_check._mParams.values()] # Test all False # rich.inspect(test_check) @@ -40,7 +39,7 @@ def test_integrity_check(): assert test_check.integrity_check() is False - custom_test_v = [True for p in test_check._mParams.values()] + custom_test_v = [True for _ in test_check._mParams.values()] test_check._wasInitialised = dict(zip(custom_test_p, custom_test_v)) # Test all True # rich.inspect(test_check) @@ -59,18 +58,18 @@ def test_getter(): assert test_check.test_param == "test_value" try: - test_check.purposefullyunexistingparameter + test_check.purposefully_non_existing_parameter except AttributeError: pass except Exception: - assert False # Not AttributeError when getting unexisting parameter + assert False # Not AttributeError when getting non-existing parameter try: - test_check._purposefullyunexistingparameter + test_check._purposefully_non_existing_parameter except AttributeError: pass except Exception: - assert False # Not AttributeError when getting _unexisting parameter + assert False # Not AttributeError when getting underscored non-existing parameter def test_setter(): @@ -86,14 +85,14 @@ def test_setter(): assert test_check.test_param == "second_test_value" try: - test_check.purposefullyunexistingparameter = "test_value" + test_check.purposefully_non_existing_parameter = "test_value" except AttributeError: pass except Exception: - assert False # Not AttributeError when getting unexisting parameter + assert False # Not AttributeError when getting non-existing parameter - test_check._purposefullyunexistingparameter = "test_value" - assert test_check._purposefullyunexistingparameter == "test_value" + test_check._purposefully_non_existing_parameter = "test_value" + assert test_check._purposefully_non_existing_parameter == "test_value" if __name__ == "__main__": diff --git a/tests/modules/test_pathresolver.py b/tests/modules/test_pathresolver.py index a39cd10..2de1beb 100644 --- a/tests/modules/test_pathresolver.py +++ b/tests/modules/test_pathresolver.py @@ -1,26 +1,22 @@ -import bootstraparse.modules.pathresolver as pathr +import bootstraparse.modules.pathresolver as path_r import os import re -pathlike_regexp = r'^([A-z]\:\\|/).+[/\\]src[/\\]bootstraparse[/\\]?$' +path_like_regexp = r'^([A-z]\:\\|/).+[/\\]src[/\\]bootstraparse[/\\]?$' test_path = '/a/b/c/test' test_path_win = test_path.replace('/', '\\') -def test_pathresolver(): - path = pathr.pathresolver(test_path) +def test_PathResolver(): + path = path_r.PathResolver(test_path) assert path() == os.path.normpath(test_path) assert path().replace('/', '\\') == test_path_win assert path().replace('\\', '/') == test_path -def test_boostrapath(): - assert re.match(pathlike_regexp, pathr.boostrapath().giveabsolute()) is not None +def test_BoostraPath(): + assert re.match(path_like_regexp, path_r.BoostraPath().give_absolute()) is not None -def test_bpath(): - assert re.match(pathlike_regexp, pathr.bpath()) is not None - - -if __name__ == "__main__": - print(test_pathresolver()) +def test_b_path(): + assert re.match(path_like_regexp, path_r.b_path()) is not None diff --git a/tests/test_bparse.py b/tests/test_bparse.py index 54f4eb9..394b753 100644 --- a/tests/test_bparse.py +++ b/tests/test_bparse.py @@ -2,6 +2,5 @@ from bootstraparse import bparse -def test_totest(): - assert bparse.totest() is None - +def test_to_test(): + assert bparse.to_test() is None