Added config

This commit is contained in:
alexander
2026-01-24 15:46:24 +01:00
parent d81cd88cab
commit fe20cb7bdc
7 changed files with 29 additions and 20 deletions

View File

@@ -3,34 +3,41 @@ from sources import CSSourceGitea, CSItem, CSInventoryItem
from sources.util import cache_cheatsheet, get_datestring
import httpx
from pathlib import Path
from logger import get_worker_thread_logger
def process_gitea(item: CSInventoryItem, outdir: str) -> list[CSItem] | None:
logger = get_worker_thread_logger()
logger.info(f"Processing Gitea cheatsheet: {item.source.owner}/{item.source.repo}@{item.source.tag}")
source: CSSourceGitea = item.source
commit_hash = get_release_commit_sha(source.base_url, source.owner, source.repo, source.tag)
asserts = list_release_assets(source.base_url, source.owner, source.repo, source.tag)
commit_hash = get_release_commit_sha(source.fetch_url or source.base_url, source.owner, source.repo, source.tag)
assets = list_release_assets(source.fetch_url or source.base_url, source.owner, source.repo, source.tag)
asserts = list(filter(lambda a: a[1].endswith(".pdf"), asserts))
asserts = list(map(lambda a: (a[0], f"{source.base_url}/repos/{source.owner}/{source.repo}/releases/download/{source.tag}/{a[0]}"), asserts))
assets = list(filter(lambda a: a[1].endswith(".pdf"), assets))
print(assets)
assets_urls = list(map(lambda a: (
f"{source.fetch_url or source.base_url}/{source.owner}/{source.repo}/releases/download/{source.tag}/{a[1]}",
f"{source.base_url}/{source.owner}/{source.repo}/releases/download/{source.tag}/{a[1]}"
), assets),
)
print(f"Found {len(asserts)} PDF assets in Gitea release {source.owner}/{source.repo}@{source.tag}")
logger.info(f"Found {len(assets_urls)} PDF assets in Gitea release {source.owner}/{source.repo}@{source.tag}")
res = []
for a in asserts:
res_url = a[0]
for fetch_url, real_url in assets_urls:
if item.cache:
cache_url = cache_cheatsheet(a[0], outdir)
cache_url = cache_cheatsheet(fetch_url, outdir)
if cache_url:
res_url = cache_url
real_url = cache_url
else:
continue
name = Path(a[1]).stem
name = Path(real_url).stem
res.append(CSItem(
url = res_url,
url = real_url,
date=get_datestring(),
commit=commit_hash[:10] if commit_hash else "",
author=item.author if item.author else source.owner,