added comments at the top of everymodule to hopefully help with imports
This commit is contained in:
parent
6f4cc857d0
commit
070fc4da26
|
|
@ -1,4 +1,7 @@
|
||||||
# Interprets config files
|
# Interprets config files
|
||||||
|
# You probably want to go to environment to get the loaded config
|
||||||
|
# The ConfigLoader class has load_from_file and load_from_folder methods and __getitem__ for accessing loaded elements
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
from bootstraparse.modules import error_mngr
|
from bootstraparse.modules import error_mngr
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,12 @@
|
||||||
# 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.
|
||||||
|
# Containers have class_name, debug_map and validate methods for debug,
|
||||||
|
# self.content: accessible via __getitem__, __setitem__, add, __len__, __iter__ and __getslice__.
|
||||||
|
# self.optionals: accessible via __rshift__ (remapped to return self.map[other]())
|
||||||
|
# and self.map: accessible via __invert__ (remapped to return self.optionals)
|
||||||
|
import rich
|
||||||
|
|
||||||
|
|
||||||
class BaseContainer:
|
class BaseContainer:
|
||||||
"""
|
"""
|
||||||
Creates container holding all the elements from the start of a parsed element to its end.
|
Creates container holding all the elements from the start of a parsed element to its end.
|
||||||
|
|
@ -117,7 +125,87 @@ class EtEmContainer(BaseContainer):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class EtStrongContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class EtUnderlineContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class EtStrikethroughContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IlLinkContainer(BaseContainer):
|
||||||
|
def __init__(self):
|
||||||
|
self.map += {'url': ""}
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class IlImageContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SeDivContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SeArticleContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SeAsideContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SeSectionContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SeHeaderContainer(BaseContainer):
|
||||||
|
def __init__(self):
|
||||||
|
self.map += {'header_level': ""}
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class SeDisplayContainer(BaseContainer):
|
||||||
|
def __init__(self):
|
||||||
|
self.map += {'display_level': ""}
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TableMainContainer(BaseContainer):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TableHeadContainer(BaseContainer):
|
||||||
|
def __init__(self):
|
||||||
|
self.map += {'colspan': ""}
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TableRowContainer(BaseContainer):
|
||||||
|
def __init__(self):
|
||||||
|
self.map += {'colspan': ""}
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
class TableCellContainer(BaseContainer):
|
||||||
|
def __init__(self):
|
||||||
|
self.map += {'colspan': ""}
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class ContextManager:
|
class ContextManager:
|
||||||
pass
|
pass
|
||||||
# Defines all methods to manage the context of the parser as a file is being parsed
|
# Defines all methods to manage the context of the parser as a file is being parsed
|
||||||
# Builds all containers as the parser is parsing the file
|
# Builds all containers as the parser is parsing the file
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
from bootstraparse.modules import parser
|
||||||
|
from io import StringIO
|
||||||
|
io_string = StringIO('test')
|
||||||
|
test = parser.parse_line(io_string)
|
||||||
|
# rich.print(test)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
# 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
|
||||||
|
# self.wasInitialised and integrity_check for debug.
|
||||||
|
# __getattr__ and __setattr__ check for existing super, s or m parameters, returns error if not found.
|
||||||
from bootstraparse.modules import error_mngr
|
from bootstraparse.modules import error_mngr
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
# 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.
|
||||||
|
# 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.
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
import traceback
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# Module for final generation of the translated website
|
# Module for final generation of the translated website
|
||||||
|
# Everything seems important :(
|
||||||
|
|
||||||
from bootstraparse.modules import config, pathresolver, error_mngr
|
from bootstraparse.modules import config, pathresolver, error_mngr
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
|
||||||
|
|
@ -1 +1,35 @@
|
||||||
# Main parser, interprets userfiles and translates into html
|
# 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
|
||||||
|
# TODO: decide the parser scope
|
||||||
|
from io import StringIO
|
||||||
|
|
||||||
|
import rich
|
||||||
|
|
||||||
|
import bootstraparse.modules.syntax as syntax
|
||||||
|
|
||||||
|
|
||||||
|
def parse_line(io):
|
||||||
|
"""
|
||||||
|
Takes an io string and returns the parsed output.
|
||||||
|
:param io: io.StringIO
|
||||||
|
:params
|
||||||
|
:io: io string input
|
||||||
|
:rtype: list
|
||||||
|
:return: a list of parsed objects
|
||||||
|
"""
|
||||||
|
output = []
|
||||||
|
for line in io.readlines():
|
||||||
|
output += syntax.line.parseString(line).asList() + [syntax.Linebreak('')]
|
||||||
|
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
hello = StringIO(
|
||||||
|
"""
|
||||||
|
*hellooooooooooooooooooooooooooooooooooooooooooooooooo*
|
||||||
|
my name is **bernard**
|
||||||
|
# hello #
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
print(parse_line(hello))
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
# Module for resolving relative path problems
|
# Module for resolving relative path problems
|
||||||
|
# PathResolver takes a relative path in the module and outputs the absolute path,
|
||||||
|
# BoostraPath can deal with relative paths in the installation folder.
|
||||||
|
|
||||||
# import pathlib
|
# import pathlib
|
||||||
import os
|
import os
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
# Module for pre-parsing user files in preparation for the parser
|
# Module for pre-parsing user files in preparation for the parser
|
||||||
|
# the PreParser has all the methods you want and probably a lot more pls help
|
||||||
import os
|
import os
|
||||||
import regex # future: remove regex
|
import regex # future: remove regex
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,7 @@
|
||||||
# Dedicated module for the syntax of all the parsing
|
# Dedicated module for the syntax of all the parsing
|
||||||
|
# All tokens inherit a SemanticType among SemanticType, ExplicitSemanticType and EmptySemanticType
|
||||||
|
# All tokens have a label, and __eq__ and __ne__ methods.
|
||||||
|
# Note: there is an UnimplementedToken
|
||||||
import os
|
import os
|
||||||
from itertools import zip_longest
|
from itertools import zip_longest
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
@ -194,6 +197,10 @@ class BlockQuoteAuthorToken(SemanticType):
|
||||||
label = "bq:author"
|
label = "bq:author"
|
||||||
|
|
||||||
|
|
||||||
|
class Linebreak(ExplicitSemanticType):
|
||||||
|
label = "linebreak"
|
||||||
|
|
||||||
|
|
||||||
def of_type(token_class):
|
def of_type(token_class):
|
||||||
"""
|
"""
|
||||||
Function creating a custom function for generating the given Token type.
|
Function creating a custom function for generating the given Token type.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue