Parse /usr/lib/os-release into a dictionary.
()
| 48 | |
| 49 | |
| 50 | def parse_os_release() -> dict[str, str]: |
| 51 | """Parse /usr/lib/os-release into a dictionary.""" |
| 52 | os_release = {} |
| 53 | try: |
| 54 | with open("/usr/lib/os-release") as f: |
| 55 | for line in f: |
| 56 | line = line.strip() |
| 57 | if "=" in line and not line.startswith("#"): |
| 58 | key, _, value = line.partition("=") |
| 59 | # Remove quotes if present |
| 60 | value = value.strip('"\'') |
| 61 | os_release[key] = value |
| 62 | except FileNotFoundError: |
| 63 | pass |
| 64 | return os_release |
| 65 | |
| 66 | |
| 67 | def distro_requires_user_agent_support() -> bool: |
no outgoing calls
no test coverage detected