lib/utils/__init__.py

85 lines · 2129 bytes

 1"""Shared helpers for lib/ scripts. Re-exports the public API of each submodule.
 2
 3`.term` (logging/colors) is stdlib-only and always importable. The other
 4submodules need `requests`/`yaml`; some CI jobs install no extra deps, so those
 5imports are skipped there, letting `setup_logging()` work without them.
 6"""
 7
 8from .term import make_colors, setup_logging
 9
10try:
11    from .api import (
12        degoogled_status,
13        enrich_get,
14        fetch_android_app,
15        fetch_ios,
16        fetch_privacy,
17        fetch_security_report,
18        fetch_trackers,
19        ios_app_id,
20        ios_days_since_update,
21        ios_rating,
22        privacy_grade,
23        tracker_count,
24        unpatched_advisories,
25    )
26    from .data import DATA_PATH, PROJECT_ROOT, iter_services, load_yaml, slugify
27    from .github import (
28        AI_BOT_AUTHORS,
29        commit_has_bot,
30        fetch_repo,
31        gh_get,
32        has_security_contact,
33        parse_github_field,
34        repo_age_days,
35        repo_has_license,
36        repo_is_archived,
37        repo_is_fork,
38        repo_pushed_days_ago,
39        repo_status,
40        top_contributor_share,
41    )
42    from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session
43except ImportError as exc:
44    if exc.name not in ("requests", "yaml"):
45        raise
46
47__all__ = [
48    "AI_BOT_AUTHORS",
49    "DATA_PATH",
50    "DEFAULT_TIMEOUT",
51    "DEFAULT_USER_AGENT",
52    "PROJECT_ROOT",
53    "check_url",
54    "commit_has_bot",
55    "degoogled_status",
56    "enrich_get",
57    "fetch_android_app",
58    "fetch_ios",
59    "fetch_privacy",
60    "fetch_repo",
61    "fetch_security_report",
62    "fetch_trackers",
63    "gh_get",
64    "has_security_contact",
65    "ios_app_id",
66    "ios_days_since_update",
67    "ios_rating",
68    "privacy_grade",
69    "iter_services",
70    "load_yaml",
71    "make_colors",
72    "make_session",
73    "parse_github_field",
74    "repo_age_days",
75    "repo_has_license",
76    "repo_is_archived",
77    "repo_is_fork",
78    "repo_pushed_days_ago",
79    "repo_status",
80    "setup_logging",
81    "slugify",
82    "top_contributor_share",
83    "tracker_count",
84    "unpatched_advisories",
85]