INNER CODE UNIT · Python
_relativize
f-droid/fdroidclient · tools/checkstyle-to-codeclimate.py:95
def _relativize(path: str, base_dir: Optional[str]) -> str:
if not base_dir:
return path
try:
p = pathlib.Path(path)
base = pathlib.Path(base_dir)
return str(p.relative_to(base))
except Exception:
return path # Fallback to original if not relative
def _stream_issues_from_file(
path: pathlib.Path, base_dir: Optional[str]
) -> Iterator[Issue]:
"""Memory-efficient streaming parser using iterparse.
We use start/end events to track the current <file> context and emit issues
when encountering <error> end events. Elements are cleared after their