Merge remote-tracking branch 'origin/main' into develop
This commit is contained in:
commit
62666e0ab4
|
|
@ -15,6 +15,9 @@ You can refer to the `example_userfiles` for an idea of what the parser expects
|
||||||
- Add documentation to remaining lone functions
|
- Add documentation to remaining lone functions
|
||||||
- Write a documentation for the application (use specs.yaml)
|
- Write a documentation for the application (use specs.yaml)
|
||||||
|
|
||||||
|
### V1.0.2
|
||||||
|
- Move the WARNING-level output to INFO for config overwrite
|
||||||
|
|
||||||
### V1.0.3
|
### V1.0.3
|
||||||
- Copy un-parsable files to destination folder without modifications
|
- Copy un-parsable files to destination folder without modifications
|
||||||
- Add copy behaviour to config file
|
- Add copy behaviour to config file
|
||||||
|
|
@ -40,4 +43,4 @@ You can refer to the `example_userfiles` for an idea of what the parser expects
|
||||||
|
|
||||||
### V2
|
### V2
|
||||||
- Add a functioning post-context enhancer able to generate menus and elements from arbitrary logic.
|
- Add a functioning post-context enhancer able to generate menus and elements from arbitrary logic.
|
||||||
- Achieve perfect markdown compatibility with appropriate config parameters
|
- Achieve perfect markdown compatibility with appropriate config parameters
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import rich
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
from bootstraparse.modules import config, pathresolver, error_mngr, context_mngr
|
from bootstraparse.modules import config, pathresolver, error_mngr, context_mngr
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
from bootstraparse.modules import tools
|
||||||
|
|
||||||
from bootstraparse.modules import syntax # noqa F401
|
from bootstraparse.modules import syntax # noqa F401
|
||||||
|
|
||||||
|
|
@ -113,7 +114,7 @@ class ExportManager:
|
||||||
start, end = self.templates["bootstrap"][export_request.type][export_request.subtype]
|
start, end = self.templates["bootstrap"][export_request.type][export_request.subtype]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
log_entries = ["bootstrap", export_request.type, export_request.subtype]
|
log_entries = ["bootstrap", export_request.type, export_request.subtype]
|
||||||
log_ = error_mngr.dict_check(self.templates, *log_entries)
|
log_ = tools.dict_check(self.templates, *log_entries)
|
||||||
print()
|
print()
|
||||||
error_mngr.log_exception(
|
error_mngr.log_exception(
|
||||||
KeyError(
|
KeyError(
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,35 @@ import os
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
###############################################################################
|
||||||
|
# Dictionary checks
|
||||||
|
########################################
|
||||||
|
def dict_check(dic, *args):
|
||||||
|
"""
|
||||||
|
Helper function to test existence within a dictionary.
|
||||||
|
:param dic: The dictionary of dictionaries to check
|
||||||
|
:param args: Any number of keys to check the dictionaries for
|
||||||
|
:return: A table of Booleans for every key checked.
|
||||||
|
"""
|
||||||
|
output = [False for _ in args]
|
||||||
|
for i in range(len(args)):
|
||||||
|
if args[i] in dic:
|
||||||
|
output[i] = True
|
||||||
|
dic = dic[args[i]]
|
||||||
|
else:
|
||||||
|
break
|
||||||
|
return output
|
||||||
|
|
||||||
|
|
||||||
|
def str_dict_check(dic, *args):
|
||||||
|
"""
|
||||||
|
Helper function to test existence within a dictionary and return a string of the values.
|
||||||
|
'arg[0]' : True or False
|
||||||
|
"""
|
||||||
|
out = dict_check(dic, *args)
|
||||||
|
return "\n".join([f"{args[i]}: {out[i]}" for i in range(len(out))])
|
||||||
|
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Paths
|
# Paths
|
||||||
########################################
|
########################################
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ from collections import namedtuple
|
||||||
from importlib import reload
|
from importlib import reload
|
||||||
from unittest import TestCase
|
from unittest import TestCase
|
||||||
import pytest
|
import pytest
|
||||||
|
import bootstraparse.modules.tools as tools
|
||||||
import bootstraparse.modules.error_mngr as error_mngr
|
import bootstraparse.modules.error_mngr as error_mngr
|
||||||
from bootstraparse.modules.error_mngr import ParsingError, MismatchedContainerError
|
from bootstraparse.modules.error_mngr import ParsingError, MismatchedContainerError
|
||||||
|
|
||||||
|
|
@ -83,23 +84,23 @@ def test_dict_check():
|
||||||
"""
|
"""
|
||||||
Test the dict_check function
|
Test the dict_check function
|
||||||
"""
|
"""
|
||||||
assert(error_mngr.dict_check({"test": "test"}, "test") == [True])
|
assert(tools.dict_check({"test": "test"}, "test") == [True])
|
||||||
assert(error_mngr.dict_check({"test": "test"}, "test2") == [False])
|
assert(tools.dict_check({"test": "test"}, "test2") == [False])
|
||||||
assert(error_mngr.dict_check({"test": {"test3": "test5"}}, "test", "test3") == [True, True])
|
assert(tools.dict_check({"test": {"test3": "test5"}}, "test", "test3") == [True, True])
|
||||||
assert(error_mngr.dict_check({"test": {"test3": "test5"}}, "test4", "test4") == [False, False])
|
assert(tools.dict_check({"test": {"test3": "test5"}}, "test4", "test4") == [False, False])
|
||||||
assert(error_mngr.dict_check({"test": {"test3": "test5"}}, "test", "test34") == [True, False])
|
assert(tools.dict_check({"test": {"test3": "test5"}}, "test", "test34") == [True, False])
|
||||||
|
|
||||||
|
|
||||||
# @pytest.mark.xfail(strict=True, reason="This test is not implemented yet")
|
# @pytest.mark.xfail(strict=True, reason="This test is not implemented yet")
|
||||||
def test_dict_check_2():
|
def test_dict_check_2():
|
||||||
assert(error_mngr.dict_check({"test": "test"}, "test", "test2") == [True, False])
|
assert(tools.dict_check({"test": "test"}, "test", "test2") == [True, False])
|
||||||
assert(error_mngr.dict_check({"test": "test"}, "test", "test2", "test3") == [True, False, False])
|
assert(tools.dict_check({"test": "test"}, "test", "test2", "test3") == [True, False, False])
|
||||||
|
|
||||||
|
|
||||||
def test_dict_str():
|
def test_dict_str():
|
||||||
assert error_mngr.str_dict_check({"test": "test"}, "test") == "test: True"
|
assert tools.str_dict_check({"test": "test"}, "test") == "test: True"
|
||||||
assert error_mngr.str_dict_check({"test": "test"}, "test2") == "test2: False"
|
assert tools.str_dict_check({"test": "test"}, "test2") == "test2: False"
|
||||||
assert error_mngr.str_dict_check({"test": {"test3": "test5"}}, "test", "test3") == "test: True\ntest3: True"
|
assert tools.str_dict_check({"test": {"test3": "test5"}}, "test", "test3") == "test: True\ntest3: True"
|
||||||
|
|
||||||
|
|
||||||
def test_weird_exception_cases():
|
def test_weird_exception_cases():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue