Added minimal doc to most functions & methods
This commit is contained in:
parent
e781ec68a7
commit
bc28c78a48
|
|
@ -23,11 +23,17 @@ class ConfigLoader:
|
||||||
|
|
||||||
|
|
||||||
class UserConfig(ConfigLoader):
|
class UserConfig(ConfigLoader):
|
||||||
|
"""
|
||||||
|
Reads user config file.
|
||||||
|
"""
|
||||||
def __init__(self, configfile):
|
def __init__(self, configfile):
|
||||||
super().__init__(configfile)
|
super().__init__(configfile)
|
||||||
|
|
||||||
|
|
||||||
class GlobalConfig(ConfigLoader):
|
class GlobalConfig(ConfigLoader):
|
||||||
|
"""
|
||||||
|
Reads global config file.
|
||||||
|
"""
|
||||||
def __init__(self, configfile):
|
def __init__(self, configfile):
|
||||||
super().__init__(configfile)
|
super().__init__(configfile)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,12 +30,18 @@ class Environment:
|
||||||
self._wasInitialised = {p: False for p in self._mParams}
|
self._wasInitialised = {p: False for p in self._mParams}
|
||||||
|
|
||||||
def integrity_check(self):
|
def integrity_check(self):
|
||||||
|
"""
|
||||||
|
Checks if all mandatory parameters are set.
|
||||||
|
"""
|
||||||
for value in self._wasInitialised.values():
|
for value in self._wasInitialised.values():
|
||||||
if value is False:
|
if value is False:
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def __getattr__(self, attribute):
|
def __getattr__(self, attribute):
|
||||||
|
"""
|
||||||
|
Getter for all parameters.
|
||||||
|
"""
|
||||||
if attribute[0] == "_":
|
if attribute[0] == "_":
|
||||||
super().__getattribute__(attribute)
|
super().__getattribute__(attribute)
|
||||||
elif attribute in self._mParams:
|
elif attribute in self._mParams:
|
||||||
|
|
@ -46,6 +52,9 @@ class Environment:
|
||||||
raise AttributeError(attribute)
|
raise AttributeError(attribute)
|
||||||
|
|
||||||
def __setattr__(self, attribute, value):
|
def __setattr__(self, attribute, value):
|
||||||
|
"""
|
||||||
|
Setter for all parameters.
|
||||||
|
"""
|
||||||
if attribute[0] == "_":
|
if attribute[0] == "_":
|
||||||
super().__setattr__(attribute, value)
|
super().__setattr__(attribute, value)
|
||||||
elif attribute in self._mParams:
|
elif attribute in self._mParams:
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,17 @@ class PreParser:
|
||||||
def __init__(self, path, __env):
|
def __init__(self, path, __env):
|
||||||
self.path = path
|
self.path = path
|
||||||
self.__env = __env
|
self.__env = __env
|
||||||
self.path_resolved = pr.pathresolver(path)
|
self.path_resolved = pr.PathResolver(path)
|
||||||
|
|
||||||
def open(self):
|
def open(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def make_import_list(self):
|
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()
|
import_list = self.parse_import_list()
|
||||||
for e in import_list:
|
for e in import_list:
|
||||||
pp = PreParser(e, self.__env)
|
pp = PreParser(e, self.__env)
|
||||||
|
|
@ -27,14 +32,23 @@ class PreParser:
|
||||||
# todo: check for recursion errors
|
# todo: check for recursion errors
|
||||||
|
|
||||||
def parse_import_list(self):
|
def parse_import_list(self):
|
||||||
|
"""
|
||||||
|
Parses the import list of the file.
|
||||||
|
"""
|
||||||
import_list = []
|
import_list = []
|
||||||
# parsing the file
|
# parsing the file
|
||||||
return [self.path_resolved(p) for p in import_list] # converts relative paths to absolute and returns a table
|
return [self.path_resolved(p) for p in import_list] # converts relative paths to absolute and returns a table
|
||||||
|
|
||||||
def close(self):
|
def close(self):
|
||||||
|
"""
|
||||||
|
Closes the file.
|
||||||
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
|
"""
|
||||||
|
Destructor.
|
||||||
|
"""
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -42,4 +56,3 @@ if __name__ == "__main__":
|
||||||
site_path = "../../../example_userfiles/index.bpr"
|
site_path = "../../../example_userfiles/index.bpr"
|
||||||
__env = environment.Environment()
|
__env = environment.Environment()
|
||||||
# rich.inspect(__env)
|
# rich.inspect(__env)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue