hotfix2:deploy

This commit is contained in:
Maximilien Rigaut 2022-06-15 21:27:41 +02:00
parent 5c104b155f
commit 6e4babfa14
No known key found for this signature in database
GPG Key ID: 4F14B23709ADA5B1
7 changed files with 64 additions and 108 deletions

View File

@ -5,9 +5,9 @@ name: Python Deployment
on: on:
push: push:
branches: [ main ] branches: [ main, test*]
pull_request: pull_request:
branches: [ main ] branches: [ main, test* ]
jobs: jobs:

View File

@ -5,9 +5,9 @@ name: Python Tests and Lint
on: on:
push: push:
branches: [ main, release, releases/*] branches: [ main, release, releases/*, test*]
pull_request: pull_request:
branches: [ main, release, releases/* ] branches: [ main, release, releases/*, test* ]
jobs: jobs:

2
.gitignore vendored
View File

@ -157,4 +157,4 @@ example_userfiles/output/
example_userfiles/output/* example_userfiles/output/*
dev_outputs/* dev_outputs/*
example_output/* example_output/*
dics/* docs/

View File

@ -436,14 +436,12 @@ class ContextManager:
def __init__(self, parsed_list, name=None, ident=0): def __init__(self, parsed_list, name=None, ident=0):
""" """
Takes a list of parsed tokens. Takes a list of parsed tokens.
Parameters :type parsed_list : list[syntax.SemanticType]
---------- :param parsed_list: List of parsed tokens output by our parser.
parsed_list : list[syntax.SemanticType] :type name: str
List of parsed tokens output by our parser. :param name: Name of the file being parsed.
name : str :type ident: int
Name of the file being parsed. :param ident: Number of spaces to indent the output.
ident : int
Number of spaces to indent the output.
""" """
self.output = [] self.output = []
self.parsed_list = parsed_list self.parsed_list = parsed_list
@ -464,15 +462,12 @@ class ContextManager:
""" """
Method to encapsulate a number of tokens together as a final container object Method to encapsulate a number of tokens together as a final container object
and replace all elements in the pile with None, except the first one which becomes the container. and replace all elements in the pile with None, except the first one which becomes the container.
Parameters :type start : int
---------- :param start: Index of the pile where the encapsulation must begin.
start : int :type end: int
Index of the pile where the encapsulation must begin. :param end: Index of the pile where the encapsulation must end.
end : int :rtype: list[(BaseContainer|None)]
Index of the pile where the encapsulation must end. :return: List of containers and None objects.
Returns
-------
list[(BaseContainer|None)]
""" """
# Enabling this will allow us to debug the pile # Enabling this will allow us to debug the pile
# print(f"Step : [{end}] - encapsulation:") # print(f"Step : [{end}] - encapsulation:")
@ -514,18 +509,16 @@ class ContextManager:
container.add(self.pile[end]) container.add(self.pile[end])
self.pile[end] = None self.pile[end] = None
self.pile[start] = container self.pile[start] = container
return self.pile # ? I think this is the right way to return the pile
# print(" <<< Pile:", self.pile) # print(" <<< Pile:", self.pile)
def _add_matched(self, label, index): def _add_matched(self, label, index):
""" """
Method to add a matched element to the dictionary of matched elements. Method to add a matched element to the dictionary of matched elements.
Parameters :type label : str
---------- :param label: Label of the matched element.
label : str :type index: int
Label of the matched element. :param index: Index of the matched element in the pile.
index : int
Index of the matched element in the pile.
""" """
if label not in self.matched_elements: if label not in self.matched_elements:
self.matched_elements[label] = [] self.matched_elements[label] = []
@ -534,13 +527,10 @@ class ContextManager:
def _get_matched(self, label): def _get_matched(self, label):
""" """
Method to get the index of the last matched element of a given label. Method to get the index of the last matched element of a given label.
Parameters :type label: str
---------- :param label: Label of the matched element.
label : str :rtype: int
Label of the matched element. :return: Index of the last matched element
Returns
-------
int : Index of the last matched element of the given label.
""" """
return self.matched_elements[label].pop() return self.matched_elements[label].pop()
@ -548,14 +538,9 @@ class ContextManager:
""" """
Interprets the list of tokens provided and deduces context, encapsulating them to their closest neighbour and Interprets the list of tokens provided and deduces context, encapsulating them to their closest neighbour and
containing all tokens inbetween. containing all tokens inbetween.
Returns :rtype: list[BaseContainer]
------- :return: Returns the pile entirely processed as a list of containers.
list[BaseContainer] :raises: MismatchedContainerError if a container is not matched to its corresponding token.
Returns the pile entirely processed as a list of containers.
Raise
-----
MismatchedContainerError
Raised when a container is not matched to its corresponding token.
""" """
# self.pile = self.parsed_list.copy() # self.pile = self.parsed_list.copy()
if self.contextualised: if self.contextualised:
@ -655,15 +640,12 @@ class ContextManager:
def lookahead(self, token, index): def lookahead(self, token, index):
""" """
Iterates the pile beginning from index and looks for all tokens matching labels with token. Iterates the pile beginning from index and looks for all tokens matching labels with token.
Parameters :type token : syntax.BaseContainer
---------- :param token: Token to look for.
token : syntax.BaseContainer :type index : int
Token to look for. :param index: Index of the token in the pile.
index : int :return: (number of tokens matched, number of linebreaks)
Index of the token in the pile. :rtype: (int, int)
Returns
-------
(int, int) : (number of tokens matched, number of linebreaks)
""" """
range_to_encapsulate = 0 range_to_encapsulate = 0
line_skipped = 0 line_skipped = 0
@ -691,29 +673,21 @@ class ContextManager:
def recontext(self, token): def recontext(self, token):
""" """
Function to recontextualise the content of a token. Function to recontextualise the content of a token.
Parameters :param token: Token to recontextualise.
---------- :type token: syntax.SemanticType
token : syntax.SemanticType :return: Token to recontextualise.
Token to recontextualise. :rtype: syntax.SemanticType
""" """
token.content = ContextManager(token.content, name=self.name)() token.content = ContextManager(token.content, name=self.name)()
def get_last_container_in_pile(self, index): def get_last_container_in_pile(self, index):
""" """
Returns the last element in the pile if it is a Container, raises an error otherwise. Returns the last element in the pile if it is a Container, raises an error otherwise.
Parameters :type index : int
---------- :param index: Index of the element to check.
index : int :return: Last element in the pile if it is a Container, raises an error otherwise.
Index of the element to check. :rtype: BaseContainer
:raise: error_mngr.LonelyOptionalError when an element is found in the pile that is not encapsulated in a container.
Returns
-------
BaseContainer
Raises
------
error_mngr.LonelyOptionalError
Raised when an element is found in the pile that is not encapsulated in a container.
""" """
i = index-1 # skip last token as it is self i = index-1 # skip last token as it is self
while i >= 0: while i >= 0:

View File

@ -94,18 +94,10 @@ class ExportManager:
""" """
Function for initializing other transform functions. Function for initializing other transform functions.
Parameters: :param export_request: ExportRequest tuples
---------- :type export_request: ExportRequest
export_request: ExportRequest tuples :return: start, end, optionals
:rtype: str, str, str
Returns:
-------
start: str
Start string of the markup element
end: str
End string of the markup element
optionals: syntax.Optionals
Optionals object containing html_insert and class_insert
""" """
start, end = None, None start, end = None, None
@ -206,14 +198,12 @@ class ContextConverter:
def __init__(self, pile, exporter, destination): def __init__(self, pile, exporter, destination):
""" """
Takes a pile and the exporter object Takes a pile and the exporter object
Parameters :type pile : list[context_mngr.BaseContainer]
---------- :param pile: output from the context manager.
pile : list[context_mngr.BaseContainer] :type exporter : ExportManager
pile output from the context manager. :param exporter: Our ExportManager
exporter : ExportManager :type destination : str
Our ExportManager :param destination: Destination of the output file.
destination : str
Destination of the output file.
""" """
self.io_output = StringIO() self.io_output = StringIO()
self.pile = pile self.pile = pile

View File

@ -12,10 +12,10 @@ import bootstraparse.modules.syntax as syntax
def parse_line(io): def parse_line(io):
""" """
Takes an io string and returns the parsed output. Takes an io string and returns the parsed output.
Parameters: :param io: The io string to parse.
io (StringIO): The io string to parse. :type io: StringIO
Returns: :return: The parsed output.
list[syntax.SemanticType]: The parsed output. :rtype: list[syntax.SemanticType]
""" """
output = [] output = []
for line in io.readlines(): for line in io.readlines():

View File

@ -98,21 +98,13 @@ class SemanticType:
def to_container(self, filter_func=None): def to_container(self, filter_func=None):
""" """
Function called by the context manager to know how to deal with the encapsulation of the token. Function called by the context manager to know how to deal with the encapsulation of the token.
:param filter_func: A function that will be used to filter the content of the token.
Parameters :type filter_func: (callable| None)
---------- :return: Self if containable, the expected replacement token if it can, raises an error otherwise.
filter_func: (function | None) :rtype: SemanticType | context_mngr.BaseContainer
A function that takes a token and returns a boolean. If the token is not valid, it should return False. :raises CannotBeContainedError: Raises error if the token we were trying to encapsulate cannot be (probably mismatched).
Returns
-------
SemanticType | context_mngr.BaseContainer
Self if containable, the expected replacement token if it can, raises an error otherwise.
Raises
------
CannotBeContainedError
Raises error if the token we were trying to encapsulate cannot be (probably mismatched).
""" """
raise MismatchedContainerError(self) raise MismatchedContainerError(self)