Bugsquashing & Typos
This commit is contained in:
parent
dd92cb44d9
commit
d5c127f957
|
|
@ -61,7 +61,8 @@ def log_exception(exception, level="ERROR"):
|
|||
"""
|
||||
level = level.lower()
|
||||
logging.__getattribute__(level)(traceback.format_exc())
|
||||
logging.__getattribute__(level)(exception.__str__()) # TODO: make it so it doesn't delete line breaks
|
||||
for line in exception.__str__():
|
||||
logging.__getattribute__(level)(line)
|
||||
if level in ["critical", "error"]:
|
||||
print("An unrecoverable error occurred, please check the log file for more information.")
|
||||
sys.exit() # could also re-raise the exception
|
||||
|
|
|
|||
|
|
@ -95,9 +95,17 @@ class ExportManager:
|
|||
Specific template for headers.
|
||||
"""
|
||||
start, end, optionals = self._get_template(export_request)
|
||||
start = start.format(optionals=optionals, header_level=export_request.others["header_level"])
|
||||
# TODO: add helpful message if KeyError
|
||||
end = end.format(header_level=export_request.others["header_level"])
|
||||
try:
|
||||
start = start.format(optionals=optionals, header_level=export_request.others["header_level"])
|
||||
end = end.format(header_level=export_request.others["header_level"])
|
||||
except KeyError:
|
||||
error_mngr.log_exception(
|
||||
KeyError(
|
||||
f'Header level could not be found.\n'
|
||||
f'{export_request.others["header_level"]} was not found in the templates.'
|
||||
),
|
||||
level='CRITICAL'
|
||||
)
|
||||
return ExportResponse(start, end)
|
||||
|
||||
def display_transform(self, export_request):
|
||||
|
|
@ -125,6 +133,6 @@ class ExportManager:
|
|||
return ExportResponse(start, end)
|
||||
|
||||
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
if __name__ == '__main__': # pragma: no cover
|
||||
herbert = ExportManager(cnoifg=None, templates=None)
|
||||
herbert._get_template(ExportRequest('b', 'c', 'class="hugues"')) # noqa
|
||||
|
|
|
|||
|
|
@ -214,7 +214,7 @@ def reparse(parse_element):
|
|||
:return: returns a function parsing given match with specified parsing element
|
||||
"""
|
||||
def _reparse(__, _, tokens):
|
||||
return parse_element.parseString(tokens[0]) # TODO: fix this with a proper solution
|
||||
return parse_element.parseString(tokens[0]) # Future: fix this with a proper solution
|
||||
|
||||
return _reparse
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
import os
|
||||
|
||||
import yaml
|
||||
|
||||
import bootstraparse.modules.config as config
|
||||
import pytest
|
||||
import tempfile
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ def test_context_mngr():
|
|||
assert base.map == {'test': "test3"}
|
||||
assert base >> "test" == 'test3'
|
||||
|
||||
|
||||
def test_base_container_with_optionals():
|
||||
base = context_mngr.BaseContainerWithOptionals()
|
||||
assert base is not None
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class TestLogging(TestCase):
|
|||
with self.assertLogs() as captured:
|
||||
with pytest.raises(SystemExit):
|
||||
error_mngr.log_exception(Exception(''), level="CRITICAL")
|
||||
self.assertEqual(2, len(captured.records))
|
||||
self.assertEqual(len(captured.records), 1)
|
||||
|
||||
def test_log_exception_with_message(self):
|
||||
for exception in all_non_blocking_exception_tests:
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ def test_transform(export_type, export_subtype):
|
|||
"row_span": "1",
|
||||
"url": "1"
|
||||
}))
|
||||
re2 = em(export.ExportRequest(export_type, export_subtype, "", {
|
||||
re = em(export.ExportRequest(export_type, export_subtype, "", {
|
||||
"header_level": "1",
|
||||
"display_level": "1",
|
||||
"col_span": "1",
|
||||
|
|
|
|||
Loading…
Reference in New Issue