This commit is contained in:
Maximilien Rigaut 2022-06-16 00:50:24 +02:00
parent 62da1bacc3
commit 22b19d4481
No known key found for this signature in database
GPG Key ID: 4F14B23709ADA5B1
13 changed files with 63 additions and 60 deletions

View File

@ -1,4 +1,5 @@
@[start]['bootstrap'] @[start]['Bootstraparse']
Structural Elements: Structural Elements:
<<div <<div

View File

@ -1,5 +1,5 @@
""" """
Bootstraparse is a tool to parse a folder and create a website from it. Bootstraparse is a tool to parse a folder and create a website from it.
After installing it with pip, you can use it by running the following command: After installing it with pip, you can use it by running the following command:
bootstraparse <origin> <destination> - bootstraparse <origin> <destination>
""" """

View File

@ -1,9 +1,9 @@
"""Interprets config files """Interprets config files
The Config will be loaded by the environment at runtime and should be accessed that way The Config will be loaded by the environment at runtime and should be accessed that way
Usage: Usage:
from bootstraparse.modules.config import ConfigLoader - from bootstraparse.modules.config import ConfigLoader
config = ConfigLoader([list of config files], extensions=[list of extensions]) - config = ConfigLoader([list of config files], extensions=[list of extensions])
config['file']['key'] - config['file']['key']
The ConfigLoader class has load_from_file and load_from_folder methods and __getitem__ for accessing loaded elements The ConfigLoader class has load_from_file and load_from_folder methods and __getitem__ for accessing loaded elements
""" """
import os import os

View File

@ -1,15 +1,15 @@
"""Interprets where the parser is located and resolves errors """Interprets where the parser is located and resolves errors
You're probably here for the ContextManager class. You're probably here for the ContextManager class.
Containers have class_name, debug_map and validate methods for debug, Containers have class_name, debug_map and validate methods for debug,
self.content: accessible via __getitem__, __setitem__, add, __len__, __iter__ and __getslice__. - self.content: accessible via __getitem__, __setitem__, add, __len__, __iter__ and __getslice__.
self.optionals: accessible via __rshift__ (remapped to return self.map[other]()) - self.optionals: accessible via __rshift__ (remapped to return self.map[other]())
and self.map: accessible via __invert__ (remapped to return self.optionals) - and self.map: accessible via __invert__ (remapped to return self.optionals)
Usage: Usage:
from bootstraparse.modules.context_mngr import ContextManager - from bootstraparse.modules.context_mngr import ContextManager
ctx = ContextManager() - ctx = ContextManager()
container = BaseContainer() - container = BaseContainer()
container[number] -> The number element in the content - container[number] -> The number element in the content
"class_insert" >> container[number] -> Get an element from one of the mapped methods - "class_insert" >> container[number] -> Get an element from one of the mapped methods
""" """
from bootstraparse.modules import syntax, error_mngr, export from bootstraparse.modules import syntax, error_mngr, export
from bootstraparse.modules.error_mngr import MismatchedContainerError, log_exception, log_message, LonelyOptionalError # noqa from bootstraparse.modules.error_mngr import MismatchedContainerError, log_exception, log_message, LonelyOptionalError # noqa

View File

@ -1,19 +1,20 @@
"""Module for containing super important variables """Module for containing super important variables
Environment has self._mParams for mandatory parameters, self._sParams for secondary parameters and Environment has self._mParams for mandatory parameters, self._sParams for secondary parameters and
self.wasInitialised and integrity_check for debug. - self.wasInitialised and integrity_check for debug.
__getattr__ and __setattr__ check for existing super, s or m parameters, returns error if not found. - __getattr__ and __setattr__ check for existing super, s or m parameters, returns error if not found.
Usage: Usage:
from bootstraparse.modules.environment import Environment - from bootstraparse.modules.environment import Environment
env = Environment() - env = Environment()
env.integrity_check() -> Checks if all mandatory parameters are set. - env.integrity_check() -> Checks if all mandatory parameters are set.
env["config"] -> returns config object - env["config"] -> returns config object
env["template"] -> returns template object - env["template"] -> returns template object
env["export_mngr"] -> returns export manager object - env["export_mngr"] -> returns export manager object
env["global_path"] -> returns global path ??? - env["global_path"] -> returns global path ???
env["user_path"] -> returns user path ??? - env["user_path"] -> returns user path ???
env["site_path"] -> returns site path - env["site_path"] -> returns site path
env["export"] -> returns export object ??? - env["export"] -> returns export object ???
env["site_crawler"] -> returns site crawler object""" - env["site_crawler"] -> returns site crawler object
"""
from bootstraparse.modules import error_mngr from bootstraparse.modules import error_mngr

View File

@ -1,13 +1,13 @@
""" """
Dedicated module for defining and interpreting errors as well as generating error messages Dedicated module for defining and interpreting errors as well as generating error messages
You're probably here for log_message or log_exception. You're probably here for log_message or log_exception.
They take: message, level=("ERROR, "INFO", "WARNING", "DEBUG", "CRITICAL") - They take: message, level=("ERROR, "INFO", "WARNING", "DEBUG", "CRITICAL")
There's also a dict_check(dic, *args) that returns true if all args are keys in the dict. There's also a dict_check(dic, *args) that returns true if all args are keys in the dict.
Usage: Usage:
from bootstraparse.modules.error_mngr import log_message, log_exception - from bootstraparse.modules.error_mngr import log_message, log_exception
log_message("This is a message", level="INFO") level=("ERROR, "INFO", "WARNING", "DEBUG", "CRITICAL") - log_message("This is a message", level="INFO") level=("ERROR, "INFO", "WARNING", "DEBUG", "CRITICAL")
log_exception(Exception("This is an exception"), level="ERROR") - log_exception(Exception("This is an exception"), level="ERROR")
dict_check({"a": 1, "b": 2}, "a", "b") # returns [True, True] - dict_check({"a": 1, "b": 2}, "a", "b") # returns [True, True]
""" """
import logging import logging

View File

@ -1,11 +1,11 @@
""" """
Module for final generation of the translated website Module for final generation of the translated website
Usage: Usage:
from bootstraparse.modules.export import ExportManager, ExportRequest, ExportResponse - from bootstraparse.modules.export import ExportManager, ExportRequest, ExportResponse
rqs = ExportRequest("strucural_elements", "div", "optionals", {"id": "my_id", "class": "my_class"}) - rqs = ExportRequest("strucural_elements", "div", "optionals", {"id": "my_id", "class": "my_class"})
rsp = ExportResponse("start_string", "end_string") - rsp = ExportResponse("start_string", "end_string")
em = ExportManager(config_file, template_file) - em = ExportManager(config_file, template_file)
em(ExportRequest()) -> ExportResponse() - em(ExportRequest()) -> ExportResponse()
""" """
from io import StringIO from io import StringIO

View File

@ -2,8 +2,8 @@
Main parser, gets config files and parses them for the context manager. Main parser, gets config files and parses them for the context manager.
parse_line takes a io and outputs it all as a list of parsed elements parse_line takes a io and outputs it all as a list of parsed elements
Usage: Usage:
from bootstraparse.modules.parser import parse_line - from bootstraparse.modules.parser import parse_line
parse_line(io) -> [element, element, element] - parse_line(io) -> [element, element, element]
""" """
from io import StringIO from io import StringIO

View File

@ -3,9 +3,9 @@ Module for resolving relative path problems
PathResolver takes a relative path in the module and outputs the absolute path, PathResolver takes a relative path in the module and outputs the absolute path,
BoostraPath can deal with relative paths in the installation folder. BoostraPath can deal with relative paths in the installation folder.
Usage: Usage:
from bootstraparse.modules.pathresolver import PathResolver, b_path - from bootstraparse.modules.pathresolver import PathResolver, b_path
b_path("../relative/path/to/file") # returns absolute path to file from the bootstraparse folder - b_path("../relative/path/to/file") # returns absolute path to file from the bootstraparse folder
path= PathResolver("../relative/path/to/file") # Make a PathResolver object pointing at the first path given - path= PathResolver("../relative/path/to/file") # Make a PathResolver object pointing at the first path given
""" """
import os import os

View File

@ -1,12 +1,12 @@
"""Module for pre-parsing user files in preparation for the parser """Module for pre-parsing user files in preparation for the parser
Usage: Usage:
from bootstraparse.modules.preparser import preparser - from bootstraparse.modules.preparser import preparser
pp = preparser(file, enviroment) - pp = preparser(file, enviroment)
pp.do_import() # imports all the modules and adds them to the file, do the same for all the files that are to be imported # noqa - pp.do_import() # imports all the modules and adds them to the file, do the same for all the files that are to be imported - # noqa
pp.do_replacements() # replaces all images and shortcuts in the file - pp.do_replacements() # replaces all images and shortcuts in the file
pp.readlines() # returns the lines of ORIGINAL file - pp.readlines() # returns the lines of ORIGINAL file
pp.get_all_lines() # returns the lines of the file after replacements and imports - pp.get_all_lines() # returns the lines of the file after replacements and imports
""" """
import os import os

View File

@ -1,12 +1,12 @@
""" """
Module for file and directories repartition Module for file and directories repartition
Usage: Usage:
from bootstraparse.modules import SiteCrawler - from bootstraparse.modules import SiteCrawler
crawler = SiteCrawler(origin_path, dest_path, _env) - crawler = SiteCrawler(origin_path, dest_path, _env)
crawler.set_all_preparsers() - crawler.set_all_preparsers()
crawler.copy_unparsable_files() - crawler.copy_unparsable_files()
for element, destination in crawler: - for element, destination in crawler:
save(preparse_parse(element), destination, _env) - - save(preparse_parse(element), destination, _env)
""" """
import os import os

View File

@ -1,7 +1,7 @@
""" """
Module sequencing the successive actions necessary for website building Module sequencing the successive actions necessary for website building
Usage: Usage:
create_website(origin, destination) - create_website(origin, destination)
""" """
import os import os

View File

@ -1,11 +1,12 @@
""" """
List of tools for testing List of tools for testing
------------------------- =========================
Usage: Usage:
from bootstraparse.modules.tools import __GLk, __GL, find_*_in_file - from bootstraparse.modules.tools import __GLk, __GL, find_*_in_file
__GLk(n) # Returns a file link n traceback objects back - __GLk(n) # Returns a file link n traceback objects back
__GL() # Returns a line number at current position - __GL() # Returns a line number at current position
find_*_in_file(file) # Try to find (class, function or variable) in file and return its line number - find_*_in_file(file) # Try to find (class, function or variable) in file and return its line number
""" """
import inspect import inspect