diff --git a/src/bootstraparse/modules/config.py b/src/bootstraparse/modules/config.py index 053323a..69ab667 100644 --- a/src/bootstraparse/modules/config.py +++ b/src/bootstraparse/modules/config.py @@ -23,11 +23,17 @@ class ConfigLoader: class UserConfig(ConfigLoader): + """ + Reads user config file. + """ def __init__(self, configfile): super().__init__(configfile) class GlobalConfig(ConfigLoader): + """ + Reads global config file. + """ def __init__(self, configfile): super().__init__(configfile) diff --git a/src/bootstraparse/modules/environment.py b/src/bootstraparse/modules/environment.py index 9c017ce..25d3c10 100644 --- a/src/bootstraparse/modules/environment.py +++ b/src/bootstraparse/modules/environment.py @@ -30,12 +30,18 @@ class Environment: self._wasInitialised = {p: False for p in self._mParams} def integrity_check(self): + """ + Checks if all mandatory parameters are set. + """ for value in self._wasInitialised.values(): if value is False: return False return True def __getattr__(self, attribute): + """ + Getter for all parameters. + """ if attribute[0] == "_": super().__getattribute__(attribute) elif attribute in self._mParams: @@ -46,6 +52,9 @@ class Environment: raise AttributeError(attribute) def __setattr__(self, attribute, value): + """ + Setter for all parameters. + """ if attribute[0] == "_": super().__setattr__(attribute, value) elif attribute in self._mParams: diff --git a/src/bootstraparse/modules/preparser.py b/src/bootstraparse/modules/preparser.py index 7bf6cb8..8e44e68 100644 --- a/src/bootstraparse/modules/preparser.py +++ b/src/bootstraparse/modules/preparser.py @@ -13,12 +13,17 @@ class PreParser: def __init__(self, path, __env): self.path = path self.__env = __env - self.path_resolved = pr.pathresolver(path) + self.path_resolved = pr.PathResolver(path) def open(self): pass def make_import_list(self): + """ + Creates a list of all files to be imported. + Makes sure that the files are not already imported through a previous import statement. + Recursively build a list of PreParser object for each file to be imported. + """ import_list = self.parse_import_list() for e in import_list: pp = PreParser(e, self.__env) @@ -27,14 +32,23 @@ class PreParser: # todo: check for recursion errors def parse_import_list(self): + """ + Parses the import list of the file. + """ import_list = [] # parsing the file return [self.path_resolved(p) for p in import_list] # converts relative paths to absolute and returns a table def close(self): + """ + Closes the file. + """ pass def __del__(self): + """ + Destructor. + """ self.close() @@ -42,4 +56,3 @@ if __name__ == "__main__": site_path = "../../../example_userfiles/index.bpr" __env = environment.Environment() # rich.inspect(__env) -