Exemple #1
0
def insert_by_type(type: str, cell_object: CellObject, section: Section):
    """ Call a elements elemnt's insert method """
    try:
        func = importlib.import_module(f'sane_doc_reports.elements.{type}')
        func.invoke(cell_object, section)
    except ModuleNotFoundError:
        import sane_doc_reports.elements.unimplemented as unimplemented
        unimplemented.invoke(cell_object, section)
Exemple #2
0
def insert_by_type(type: str, cell_object: CellObject,
                   section: Section, trace=False):
    """ Call a elements elemnt's insert method """
    try:
        func = importlib.import_module(f'sane_doc_reports.elements.{type}')
        func.invoke(cell_object, section)
    except ModuleNotFoundError:
        import sane_doc_reports.elements.unimplemented as unimplemented
        unimplemented.invoke(cell_object, section)
    except Exception as e:
        # We want to have a graceful failure instead of early quitting.
        # Maybe we can "salvage" other elements that were generated
        # without any exceptions. Here we will display the faulty
        # elements in the doc.
        trace_str = f'\n({traceback.format_exc()})' if trace else ''
        error_msg = f'{section.type} had an error: `{repr(e)}`{trace_str}'
        insert_error(cell_object, error_msg)