MCPcopy Create free account
hub / github.com/Qinbf/groundmap / _split_scope_top_level

Function _split_scope_top_level

scripts/k.py:1013–1035  ·  view source on GitHub ↗

按逗号 split scope,但忽略 `{}` 内的逗号。 例:'wiki/concepts/*, wiki/entities/{a,b}' → ['wiki/concepts/*', 'wiki/entities/{a,b}']

(scope: str)

Source from the content-addressed store, hash-verified

1011
1012
1013def _split_scope_top_level(scope: str) -> list[str]:
1014 """按逗号 split scope,但忽略 `{}` 内的逗号。
1015 例:'wiki/concepts/*, wiki/entities/{a,b}'
1016 ['wiki/concepts/*', 'wiki/entities/{a,b}']
1017 """
1018 parts: list[str] = []
1019 depth = 0
1020 cur: list[str] = []
1021 for ch in scope:
1022 if ch == "{":
1023 depth += 1
1024 cur.append(ch)
1025 elif ch == "}":
1026 depth = max(0, depth - 1)
1027 cur.append(ch)
1028 elif ch == "," and depth == 0:
1029 parts.append("".join(cur).strip())
1030 cur = []
1031 else:
1032 cur.append(ch)
1033 if cur:
1034 parts.append("".join(cur).strip())
1035 return [p for p in parts if p]
1036
1037
1038def _glob_scope_to_paths(scope: str) -> set[str]:

Callers 1

_glob_scope_to_pathsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected