diff --git a/src/caoscrawler/crawl.py b/src/caoscrawler/crawl.py index e0d243979faee8f44cdcee3b0e49c15af640c378..f0986367dc70f1f22fdb91acc289f9f461044d6c 100644 --- a/src/caoscrawler/crawl.py +++ b/src/caoscrawler/crawl.py @@ -66,7 +66,8 @@ from .identifiable_adapters import (CaosDBIdentifiableAdapter, from .logging import configure_server_side_logging from .macros import defmacro_constructor, macro_constructor from .scanner import (create_converter_registry, initialize_converters, - load_definition, scan_directory, scan_structure_elements) + load_definition, save_debug_tree, scan_directory, + scan_structure_elements) from .stores import GeneralStore from .structure_elements import StructureElement from .sync_graph import SyncGraph diff --git a/src/caoscrawler/scanner.py b/src/caoscrawler/scanner.py index 7f2dd64d07ed5a2e13b9835e1b97bbadc308ae22..57b540d1ba100cd96dca5dd77eebde2a021bc98b 100644 --- a/src/caoscrawler/scanner.py +++ b/src/caoscrawler/scanner.py @@ -37,16 +37,17 @@ from __future__ import annotations import importlib import logging import os +import pathlib import warnings from collections.abc import Callable from typing import Any, Optional, Union import jinja2 - import linkahead as db import yaml from importlib_resources import files from jsonschema import validate +from linkahead.high_level_api import convert_to_python_object from .converters import Converter from .debug_tree import DebugTree @@ -54,9 +55,6 @@ from .stores import GeneralStore, RecordStore from .structure_elements import Directory, StructureElement from .version import check_cfood_version -from linkahead.high_level_api import convert_to_python_object -import pathlib - logger = logging.getLogger(__name__) @@ -459,6 +457,9 @@ def scanner(items: list[StructureElement], converter_dictionary["subtree"] = sub_debug_tree matching_converters.append(converter_dictionary) + # Clean up converter: + converter.cleanup() + if new_debug_tree is not None: element_dictionary = element.get_dict() if not at_least_one_matched: @@ -468,9 +469,6 @@ def scanner(items: list[StructureElement], element_dictionary["matching_converters"] = matching_converters new_debug_tree.append(element_dictionary) - # Clean up converter: - converter.cleanup() - if restricted_path and not path_found: raise RuntimeError("A 'restricted_path' argument was given that is not contained in " "the data tree")