def generate_report(reportfolderbase, time_in_secs, time_HMS, extraction_type, image_input_path):
    control = None
    side_heading = '<h6 class="sidebar-heading justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">\n        {0}\n    </h6>\n    '
    list_item = '\n    <li class="nav-item">\n        <a class="nav-link {0}" href="{1}">\n            <span data-feather="{2}"></span> {3}\n        </a>\n    </li>\n    '
    nav_list_data = (side_heading.format('Saved Reports') + list_item.format('', 'index.html', 'home', 'Report Home'))
    side_list = OrderedDict()
    for (root, dirs, files) in sorted(os.walk(reportfolderbase)):
        for file in files:
            if file.endswith('.temphtml'):
                fullpath = os.path.join(root, file)
                (head, tail) = os.path.split(fullpath)
                p = pathlib.Path(fullpath)
                SectionHeader = p.parts[(- 2)]
                if (SectionHeader == '_elements'):
                    pass
                elif (control == SectionHeader):
                    side_list[SectionHeader].append(fullpath)
                    icon = get_icon_name(SectionHeader, tail.replace('.temphtml', ''))
                    nav_list_data += list_item.format('', tail.replace('.temphtml', '.html'), icon, tail.replace('.temphtml', ''))
                else:
                    control = SectionHeader
                    side_list[SectionHeader] = []
                    side_list[SectionHeader].append(fullpath)
                    nav_list_data += side_heading.format(SectionHeader)
                    icon = get_icon_name(SectionHeader, tail.replace('.temphtml', ''))
                    nav_list_data += list_item.format('', tail.replace('.temphtml', '.html'), icon, tail.replace('.temphtml', ''))
    for (category, path_list) in side_list.items():
        for path in path_list:
            old_filename = os.path.basename(path)
            filename = old_filename.replace('.temphtml', '.html')
            active_nav_list_data = (mark_item_active(nav_list_data, filename) + nav_bar_script)
            artifact_data = get_file_content(path)
            f = open(os.path.join(reportfolderbase, filename), 'w', encoding='utf8')
            artifact_data = insert_sidebar_code(artifact_data, active_nav_list_data, path)
            f.write(artifact_data)
            f.close()
            os.remove(path)
            try:
                os.rmdir(os.path.dirname(path))
            except OSError:
                pass
    create_index_html(reportfolderbase, time_in_secs, time_HMS, extraction_type, image_input_path, nav_list_data)
    elements_folder = os.path.join(reportfolderbase, '_elements')
    os.mkdir(elements_folder)
    __location__ = os.path.dirname(os.path.abspath(__file__))

    def copy_no_perm(src, dst, *, follow_symlinks=True):
        if (not os.path.isdir(dst)):
            shutil.copyfile(src, dst)
        return dst
    try:
        shutil.copyfile(os.path.join(__location__, 'logo.jpg'), os.path.join(elements_folder, 'logo.jpg'))
        shutil.copyfile(os.path.join(__location__, 'dashboard.css'), os.path.join(elements_folder, 'dashboard.css'))
        shutil.copyfile(os.path.join(__location__, 'feather.min.js'), os.path.join(elements_folder, 'feather.min.js'))
        shutil.copyfile(os.path.join(__location__, 'dark-mode.css'), os.path.join(elements_folder, 'dark-mode.css'))
        shutil.copyfile(os.path.join(__location__, 'dark-mode-switch.js'), os.path.join(elements_folder, 'dark-mode-switch.js'))
        shutil.copyfile(os.path.join(__location__, 'chats.css'), os.path.join(elements_folder, 'chats.css'))
        shutil.copytree(os.path.join(__location__, 'MDB-Free_4.13.0'), os.path.join(elements_folder, 'MDB-Free_4.13.0'), copy_function=copy_no_perm)
    except shutil.Error:
        print('shutil reported an error. Maybe due to recursive directory copying.')
        if os.path.exists(os.path.join(elements_folder, 'MDB-Free_4.13.0')):
            print('_elements folder seems fine. Probably nothing to worry about')
def generate_report(reportfolderbase, time_in_secs, time_HMS, extraction_type, image_input_path):
    control = None
    side_heading = '<h6 class="sidebar-heading justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">\n        {0}\n    </h6>\n    '
    list_item = '\n    <li class="nav-item">\n        <a class="nav-link {0}" href="{1}">\n            <span data-feather="{2}"></span> {3}\n        </a>\n    </li>\n    '
    nav_list_data = (side_heading.format('Saved Reports') + list_item.format(, 'index.html', 'home', 'Report Home'))
    side_list = OrderedDict()
    for (root, dirs, files) in sorted(os.walk(reportfolderbase)):
        for file in files:
            if file.endswith('.temphtml'):
                fullpath = os.path.join(root, file)
                (head, tail) = os.path.split(fullpath)
                p = pathlib.Path(fullpath)
                SectionHeader = p.parts[(- 2)]
                if (SectionHeader == '_elements'):
                    pass
                elif (control == SectionHeader):
                    side_list[SectionHeader].append(fullpath)
                    icon = get_icon_name(SectionHeader, tail.replace('.temphtml', ))
                    nav_list_data += list_item.format(, tail.replace('.temphtml', '.html'), icon, tail.replace('.temphtml', ))
                else:
                    control = SectionHeader
                    side_list[SectionHeader] = []
                    side_list[SectionHeader].append(fullpath)
                    nav_list_data += side_heading.format(SectionHeader)
                    icon = get_icon_name(SectionHeader, tail.replace('.temphtml', ))
                    nav_list_data += list_item.format(, tail.replace('.temphtml', '.html'), icon, tail.replace('.temphtml', ))
    for (category, path_list) in side_list.items():
        for path in path_list:
            old_filename = os.path.basename(path)
            filename = old_filename.replace('.temphtml', '.html')
            active_nav_list_data = (mark_item_active(nav_list_data, filename) + nav_bar_script)
            artifact_data = get_file_content(path)
            f = open(os.path.join(reportfolderbase, filename), 'w', encoding='utf8')
            artifact_data = insert_sidebar_code(artifact_data, active_nav_list_data, path)
            f.write(artifact_data)
            f.close()
            os.remove(path)
            try:
                os.rmdir(os.path.dirname(path))
            except OSError:
                pass
    create_index_html(reportfolderbase, time_in_secs, time_HMS, extraction_type, image_input_path, nav_list_data)
    elements_folder = os.path.join(reportfolderbase, '_elements')
    os.mkdir(elements_folder)
    __location__ = os.path.dirname(os.path.abspath(__file__))

    def copy_no_perm(src, dst, *, follow_symlinks=True):
        if (not os.path.isdir(dst)):
            shutil.copyfile(src, dst)
        return dst
    try:
        shutil.copyfile(os.path.join(__location__, 'logo.jpg'), os.path.join(elements_folder, 'logo.jpg'))
        shutil.copyfile(os.path.join(__location__, 'dashboard.css'), os.path.join(elements_folder, 'dashboard.css'))
        shutil.copyfile(os.path.join(__location__, 'feather.min.js'), os.path.join(elements_folder, 'feather.min.js'))
        shutil.copyfile(os.path.join(__location__, 'dark-mode.css'), os.path.join(elements_folder, 'dark-mode.css'))
        shutil.copyfile(os.path.join(__location__, 'dark-mode-switch.js'), os.path.join(elements_folder, 'dark-mode-switch.js'))
        shutil.copyfile(os.path.join(__location__, 'chats.css'), os.path.join(elements_folder, 'chats.css'))
        shutil.copytree(os.path.join(__location__, 'MDB-Free_4.13.0'), os.path.join(elements_folder, 'MDB-Free_4.13.0'), copy_function=copy_no_perm)
    except shutil.Error:
        print('shutil reported an error. Maybe due to recursive directory copying.')
        if os.path.exists(os.path.join(elements_folder, 'MDB-Free_4.13.0')):
            print('_elements folder seems fine. Probably nothing to worry about')