diff --git a/lib/galaxy/tool_source_store/populator.py b/lib/galaxy/tool_source_store/populator.py index 3e3580b1443..36ba134d33b 100644 --- a/lib/galaxy/tool_source_store/populator.py +++ b/lib/galaxy/tool_source_store/populator.py @@ -291,6 +291,110 @@ class ToolFileWatcher: DEFAULT_STORE_NAME = "__default__" +def build_index_entry_from_source( + discovered, + stored, + tool_source, +): + """Assemble a :class:`ToolIndexEntry` from a populator triple. + + ``discovered`` carries conf-level metadata that isn't visible to the tool + source parser (section membership, ``labels="a,b"`` on the ```` + element, conf-level ``hidden="true"``). ``stored`` carries the + content-addressed hash and source class. ``tool_source`` is the parsed + body — we read identity (id, version, name, description), EDAM + operations / topics, ``require_login``, and ``tool_type`` off it. + + Returns ``None`` if the tool source does not yield a usable id; callers + log + skip in that case. + """ + # Avoid importing ToolIndexEntry at module load time — only the populator's + # post-walk index-build step needs it, and tests that exercise the + # CLI plumbing alone shouldn't pull the whole index machinery in. + from galaxy.tool_source_store.index import ToolIndexEntry + + try: + tool_id = tool_source.parse_id() or stored.tool_id + if not tool_id: + return None + + uuid_val = None + if hasattr(tool_source, "parse_uuid"): + try: + parsed_uuid = tool_source.parse_uuid() + uuid_val = str(parsed_uuid) if parsed_uuid else None + except Exception: + pass + + # XML-body ``