feat: switch to full gitea source and generate 600+ category outputs

This commit is contained in:
袁震
2026-04-06 12:35:00 +08:00
parent 846a05da0a
commit 92c644b5c6
1337 changed files with 430381 additions and 50 deletions
+27 -8
View File
@@ -286,15 +286,34 @@ def find_categories(client: GiteaClient, cfg: Config, cli_names: set[str]) -> li
def build_one_category(client: GiteaClient, cfg: Config, name: str, base_out: Path) -> tuple[int, int]:
nested_path = f"{cfg.source_root}/{name}/{cfg.source_filename_pattern.format(name=name)}"
flat_path = f"{cfg.source_root}/{cfg.source_filename_pattern.format(name=name)}"
filename_base = cfg.source_filename_pattern.format(name=name)
candidate_filenames = [
filename_base,
f"{name}_All.list",
f"{name}_Domain.list",
f"{name}_Resolve.list",
]
source_rel_path = nested_path
try:
source_content = client.read_file(cfg.owner, cfg.repo, nested_path, cfg.ref)
except Exception:
source_rel_path = flat_path
source_content = client.read_file(cfg.owner, cfg.repo, flat_path, cfg.ref)
candidate_paths: list[str] = []
for fn in candidate_filenames:
candidate_paths.append(f"{cfg.source_root}/{name}/{fn}") # nested
candidate_paths.append(f"{cfg.source_root}/{fn}") # flat
source_rel_path = ""
source_content = ""
last_error: Exception | None = None
for path in candidate_paths:
try:
source_content = client.read_file(cfg.owner, cfg.repo, path, cfg.ref)
source_rel_path = path
break
except Exception as exc:
last_error = exc
if not source_rel_path:
if last_error is not None:
raise last_error
raise RuntimeError(f"unable to locate source list for category: {name}")
rules = parse_rules(source_content)