sitecreator.py : Doc and rtypes
This commit is contained in:
parent
6100f716b5
commit
ef9b53fcbc
|
|
@ -8,6 +8,11 @@ def create_website(origin, destination):
|
||||||
"""
|
"""
|
||||||
First function called by bparse.py,
|
First function called by bparse.py,
|
||||||
calls all other modules in the right order.
|
calls all other modules in the right order.
|
||||||
|
:param origin: The path of the website to be built.
|
||||||
|
:param destination: The destination path of the built website.
|
||||||
|
:type origin: str
|
||||||
|
:type destination: str
|
||||||
|
:return: 0 if everything went well, 1 otherwise.
|
||||||
"""
|
"""
|
||||||
env = create_environment(origin, destination)
|
env = create_environment(origin, destination)
|
||||||
crwlr = create_crawler(origin, destination, env)
|
crwlr = create_crawler(origin, destination, env)
|
||||||
|
|
@ -22,6 +27,12 @@ def create_environment(origin, destination):
|
||||||
"""
|
"""
|
||||||
Returns parserEnvironment as an object containing
|
Returns parserEnvironment as an object containing
|
||||||
everything needed for app execution.
|
everything needed for app execution.
|
||||||
|
:param origin: The path of the website to be built.
|
||||||
|
:param destination: The destination path of the built website.
|
||||||
|
:type origin: str
|
||||||
|
:type destination: str
|
||||||
|
:return: Environment object.
|
||||||
|
:rtype: environment.Environment
|
||||||
"""
|
"""
|
||||||
env = environment.Environment()
|
env = environment.Environment()
|
||||||
env.config = config.ConfigLoader(pathresolver.b_path("configs"))
|
env.config = config.ConfigLoader(pathresolver.b_path("configs"))
|
||||||
|
|
@ -42,11 +53,26 @@ def create_environment(origin, destination):
|
||||||
def create_crawler(origin, destination, _env):
|
def create_crawler(origin, destination, _env):
|
||||||
"""
|
"""
|
||||||
Returns crawler as an object for navigation in the user files.
|
Returns crawler as an object for navigation in the user files.
|
||||||
|
:param origin: The path of the website to be built.
|
||||||
|
:param destination: The destination path of the built website.
|
||||||
|
:param _env: The environment object.
|
||||||
|
:type origin: str
|
||||||
|
:type destination: str
|
||||||
|
:type _env: environment.Environment
|
||||||
|
:return: Crawler object.
|
||||||
|
:rtype: sitecrawler.SiteCrawler
|
||||||
"""
|
"""
|
||||||
return sitecrawler.SiteCrawler(origin, destination, _env)
|
return sitecrawler.SiteCrawler(origin, destination, _env)
|
||||||
|
|
||||||
|
|
||||||
def preparse_parse(preparser):
|
def preparse_parse(preparser):
|
||||||
|
"""
|
||||||
|
Returns a list of containers from a preparser.
|
||||||
|
:param preparser: The preparser object.
|
||||||
|
:type preparser: parser.Preparser
|
||||||
|
:return: List of containers.
|
||||||
|
:rtype: list
|
||||||
|
"""
|
||||||
io = preparser.do_replacements()
|
io = preparser.do_replacements()
|
||||||
parsed_list = parser.parse_line(io)
|
parsed_list = parser.parse_line(io)
|
||||||
output = context_mngr.ContextManager(parsed_list, name=preparser.name)()
|
output = context_mngr.ContextManager(parsed_list, name=preparser.name)()
|
||||||
|
|
@ -54,6 +80,15 @@ def preparse_parse(preparser):
|
||||||
|
|
||||||
|
|
||||||
def save(list_of_containers, destination, env):
|
def save(list_of_containers, destination, env):
|
||||||
|
"""
|
||||||
|
Saves the list of containers in the destination path.
|
||||||
|
:param list_of_containers: The list of containers to be saved.
|
||||||
|
:param destination: The destination path.
|
||||||
|
:param env: The environment object.
|
||||||
|
:type list_of_containers: list
|
||||||
|
:type destination: str
|
||||||
|
:type env: environment.Environment
|
||||||
|
"""
|
||||||
with open(destination, "w") as output_file:
|
with open(destination, "w") as output_file:
|
||||||
output_file.write(export.ContextConverter(list_of_containers, env.export_mngr, destination).process_pile().read())
|
output_file.write(export.ContextConverter(list_of_containers, env.export_mngr, destination).process_pile().read())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue