按逗号 split scope,但忽略 `{}` 内的逗号。 例:'wiki/concepts/*, wiki/entities/{a,b}' → ['wiki/concepts/*', 'wiki/entities/{a,b}']
(scope: str)
| 1011 | |
| 1012 | |
| 1013 | def _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 | |
| 1038 | def _glob_scope_to_paths(scope: str) -> set[str]: |
no outgoing calls
no test coverage detected