first draft site creator

This commit is contained in:
vicky 2022-06-06 23:15:54 +02:00
parent b9ce985747
commit 5b61869329
1 changed files with 39 additions and 70 deletions

View File

@ -1,95 +1,64 @@
# Module sequencing the successive actions necessary for website building # Module sequencing the successive actions necessary for website building
import os
import bootstraparse.modules.config as config import rich
from bootstraparse.modules.pathresolver import b_path from bootstraparse.modules import pathresolver, sitecrawler, environment, config, export, parser, context_mngr
def create_website(): 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.
""" """
pass env = create_environment(origin, destination)
crwlr = create_crawler(origin, destination, env)
crwlr.set_all_preparsers()
for element, destination in crwlr:
save(preparse_parse(element), destination, env)
def create_environment(): 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.
""" """
pass env = environment.Environment()
env.config = config.ConfigLoader(pathresolver.b_path("configs"))
if os.path.exists(os.path.join(origin, "configs")):
env.config.add_folder(os.path.join(origin, "configs"))
env.template = config.ConfigLoader(pathresolver.b_path("templates"))
if os.path.exists(os.path.join(origin, "templates")):
env.template.add_folder(os.path.join(origin, "templates"))
env.export_mngr = export.ExportManager(env.config, env.template)
env.origin = origin
env.destination = destination
return env
def create_config(): def create_crawler(origin, destination, _env):
"""
Returns globalConfig as an object from parser_config.yml settings.
"""
return config.ConfigLoader(b_path("configs/"))
def create_crawler():
""" """
Returns crawler as an object for navigation in the user files. Returns crawler as an object for navigation in the user files.
""" """
pass return sitecrawler.SiteCrawler(origin, destination, _env)
def create_user_config(): def preparse_parse(preparser):
""" io = preparser.do_replacements()
Returns userConfig as an object from aliases.yaml, parsed_list = parser.parse_line(io)
glossary.yaml and website.yaml. output = context_mngr.ContextManager(parsed_list)()
""" return output
pass
def create_template(): def save(list_of_containers, destination, env):
""" rich.print(list_of_containers[0])
Returns a templateManager from templates for with open(destination, "w") as output_file:
generating the correct html files. output_file.write(export.ContextConverter(list_of_containers, env.export_mngr).process_pile().read())
"""
pass
def env_checker(): if __name__ == "__main__":
""" xpath = pathresolver.b_path("../../example_userfiles")
Verify all is in order for initialisation of dpath = pathresolver.b_path("../../example_output")
the parserEnvironment object and initialises. create_website(xpath, dpath)
"""
pass
def begin_crawling(p_env): # noqa : F811
"""
Starts reading every file in the userfiles and
adds them to the crawler object progressively.
"""
pass
def begin_pre_parsing(p_env): # noqa : F811
"""
Create an importTree and checks for conflicts or loops;
then replaces imports with their contents,
then replaces all aliases with their values.
"""
pass
def begin_parsing(p_env): # noqa : F811
"""
For each of the generated files,
parses element after element and creates
the graph representation of the website,
interacts with context_mngr.py to ascertain integrity
and deal with errors.
"""
pass
def begin_export(p_env): # noqa : F811
"""
Replaces all parsed values with their attributed
correspondences as per the template_manager
and exports the result as a website.
"""
pass