MCPcopy Create free account
hub / github.com/bootc-dev/bootc / parse_os_release

Function parse_os_release

tmt/tests/booted/test-user-agent.py:50–64  ·  view source on GitHub ↗

Parse /usr/lib/os-release into a dictionary.

()

Source from the content-addressed store, hash-verified

48
49
50def 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
67def distro_requires_user_agent_support() -> bool:

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected