lib/utils/__init__.py
79 lines · 1965 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 ios_app_id,
19 ios_days_since_update,
20 ios_rating,
21 privacy_grade,
22 tracker_count,
23 unpatched_advisories,
24 )
25 from .data import DATA_PATH, PROJECT_ROOT, iter_services, load_yaml, slugify
26 from .github import (
27 AI_BOT_AUTHORS,
28 commit_has_bot,
29 fetch_repo,
30 gh_get,
31 parse_github_field,
32 repo_age_days,
33 repo_has_license,
34 repo_is_archived,
35 repo_is_fork,
36 repo_pushed_days_ago,
37 repo_status,
38 )
39 from .http import DEFAULT_TIMEOUT, DEFAULT_USER_AGENT, check_url, make_session
40except ImportError as exc:
41 if exc.name not in ("requests", "yaml"):
42 raise
43
44__all__ = [
45 "AI_BOT_AUTHORS",
46 "DATA_PATH",
47 "DEFAULT_TIMEOUT",
48 "DEFAULT_USER_AGENT",
49 "PROJECT_ROOT",
50 "check_url",
51 "commit_has_bot",
52 "degoogled_status",
53 "enrich_get",
54 "fetch_android_app",
55 "fetch_ios",
56 "fetch_privacy",
57 "fetch_repo",
58 "fetch_security_report",
59 "gh_get",
60 "ios_app_id",
61 "ios_days_since_update",
62 "ios_rating",
63 "privacy_grade",
64 "iter_services",
65 "load_yaml",
66 "make_colors",
67 "make_session",
68 "parse_github_field",
69 "repo_age_days",
70 "repo_has_license",
71 "repo_is_archived",
72 "repo_is_fork",
73 "repo_pushed_days_ago",
74 "repo_status",
75 "setup_logging",
76 "slugify",
77 "tracker_count",
78 "unpatched_advisories",
79]