d
This commit is contained in:
@@ -2,7 +2,7 @@ import json
|
||||
import os
|
||||
import sys
|
||||
from typing import List, Dict, Any, Sequence
|
||||
from cmdlet._shared import Cmdlet, CmdletArg
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg
|
||||
from SYS.logger import log
|
||||
from SYS.result_table import Table
|
||||
from SYS import pipeline as ctx
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import List, Dict, Any, Optional, Sequence
|
||||
|
||||
from cmdlet._shared import Cmdlet, CmdletArg
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg
|
||||
from SYS.config import load_config, save_config, save_config_and_verify
|
||||
from SYS import pipeline as ctx
|
||||
from SYS.result_table import Table
|
||||
|
||||
@@ -4,7 +4,7 @@ from typing import Any, Dict, Sequence, List, Optional, Tuple
|
||||
import shlex
|
||||
import sys
|
||||
|
||||
from cmdlet._shared import Cmdlet, CmdletArg, parse_cmdlet_args
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg, parse_cmdlet_args
|
||||
from cmdlet import REGISTRY as CMDLET_REGISTRY, ensure_cmdlet_modules_loaded
|
||||
from SYS.logger import log
|
||||
from SYS.result_table import Table
|
||||
@@ -16,6 +16,8 @@ def _normalize_choice_list(arg_names: Optional[List[str]]) -> List[str]:
|
||||
|
||||
|
||||
_HELP_EXAMPLE_SOURCE_COMMAND = ".help-example"
|
||||
_METADATA_CACHE_KEY: Optional[Tuple[int, int]] = None
|
||||
_METADATA_CACHE_VALUE: Optional[Tuple[Dict[str, Dict[str, Any]], Dict[str, str]]] = None
|
||||
|
||||
|
||||
def _example_for_cmd(name: str) -> List[str]:
|
||||
@@ -104,6 +106,13 @@ def _build_alias_map_from_metadata(metadata: Dict[str, Dict[str, Any]]) -> Dict[
|
||||
|
||||
|
||||
def _gather_metadata_from_cmdlet_classes() -> Tuple[Dict[str, Dict[str, Any]], Dict[str, str]]:
|
||||
global _METADATA_CACHE_KEY, _METADATA_CACHE_VALUE
|
||||
|
||||
cache_key = (len(sys.modules), len(CMDLET_REGISTRY))
|
||||
if _METADATA_CACHE_KEY == cache_key and _METADATA_CACHE_VALUE is not None:
|
||||
cached_metadata, cached_alias = _METADATA_CACHE_VALUE
|
||||
return dict(cached_metadata), dict(cached_alias)
|
||||
|
||||
metadata: Dict[str, Dict[str, Any]] = {}
|
||||
alias_map: Dict[str, str] = {}
|
||||
try:
|
||||
@@ -116,7 +125,7 @@ def _gather_metadata_from_cmdlet_classes() -> Tuple[Dict[str, Dict[str, Any]], D
|
||||
if not (mod_name.startswith("cmdlet.") or mod_name == "cmdlet" or mod_name.startswith("cmdnat.")):
|
||||
continue
|
||||
cmdlet_obj = getattr(module, "CMDLET", None)
|
||||
if not isinstance(cmdlet_obj, Cmdlet):
|
||||
if cmdlet_obj is None or not hasattr(cmdlet_obj, "name") or not hasattr(cmdlet_obj, "arg"):
|
||||
continue
|
||||
canonical_key = _normalize_cmdlet_key(getattr(cmdlet_obj, "name", None) or "")
|
||||
if not canonical_key:
|
||||
@@ -166,6 +175,9 @@ def _gather_metadata_from_cmdlet_classes() -> Tuple[Dict[str, Dict[str, Any]], D
|
||||
},
|
||||
)
|
||||
|
||||
_METADATA_CACHE_KEY = cache_key
|
||||
_METADATA_CACHE_VALUE = (dict(metadata), dict(alias_map))
|
||||
|
||||
return metadata, alias_map
|
||||
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import re
|
||||
import uuid
|
||||
from urllib.parse import parse_qs, urlparse
|
||||
|
||||
from cmdlet._shared import Cmdlet, CmdletArg
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg
|
||||
from SYS.config import load_config, save_config
|
||||
from SYS.logger import log, debug
|
||||
from SYS.result_table import Table
|
||||
|
||||
@@ -6,7 +6,7 @@ import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, Sequence, Optional
|
||||
|
||||
from cmdlet._shared import Cmdlet, CmdletArg
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg
|
||||
from SYS.logger import log
|
||||
from SYS import pipeline as ctx
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import re
|
||||
from datetime import datetime
|
||||
from urllib.parse import urlparse, parse_qs
|
||||
from pathlib import Path
|
||||
from cmdlet._shared import Cmdlet, CmdletArg, parse_cmdlet_args
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg, parse_cmdlet_args
|
||||
from Provider.tidal_manifest import resolve_tidal_manifest_path
|
||||
from SYS.logger import debug, get_thread_stream, is_debug_enabled, set_debug, set_thread_stream
|
||||
from SYS.result_table import Table
|
||||
|
||||
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
import shutil
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from cmdlet._shared import Cmdlet
|
||||
from SYS.cmdlet_spec import Cmdlet
|
||||
from SYS import pipeline as ctx
|
||||
from SYS.result_table import Table
|
||||
from SYS.logger import set_debug, debug
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from typing import Any, Dict, Sequence
|
||||
|
||||
from cmdlet._shared import Cmdlet, CmdletArg
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg
|
||||
from SYS.logger import log
|
||||
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import sys
|
||||
from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Sequence
|
||||
|
||||
from cmdlet._shared import Cmdlet, CmdletArg
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg
|
||||
from SYS.logger import log
|
||||
from SYS.result_table import Table
|
||||
from SYS import pipeline as ctx
|
||||
|
||||
@@ -9,7 +9,7 @@ from datetime import datetime, timezone
|
||||
from typing import Any, Dict, Sequence, List
|
||||
|
||||
from cmdlet import register
|
||||
from cmdlet._shared import Cmdlet, CmdletArg
|
||||
from SYS.cmdlet_spec import Cmdlet, CmdletArg
|
||||
from SYS import pipeline as ctx
|
||||
from SYS.logger import log
|
||||
from SYS.database import db as _db, get_worker_stdout
|
||||
|
||||
Reference in New Issue
Block a user