INNER CODE UNIT · Python
_fetch_eu
lawve-ai/awesome-legal-skills · skills/ktzr-polskie-umowy-gospodarcze-adam-piotrowski/tools/legal-cite/legal_cite/core.py:151
async def _fetch_eu(info: dict) -> str | None:
key = f"EU:{info['celex']}"
if key in _cache:
return _cache[key]
url = (f"https://eur-lex.europa.eu/legal-content/PL/TXT/HTML/"
f"?uri=CELEX:{info['celex']}")
async with httpx.AsyncClient(follow_redirects=True, timeout=30, headers=_HEADERS) as c:
resp = await c.get(url)
if resp.status_code != 200:
return None
_cache[key] = _strip_html(resp.text)
return _cache[key]
def _cut_ustep(art_text: str, ustep: str) -> str | None:
# ustęp „N." LUB paragraf „§ N." (KC); granica = następna jednostka tej samej rangi
m = re.search(rf'(?:§\s*)?(?<!\d){re.escape(ustep)}\.\s', art_text)
if not m: