STINNER Victor <[email protected]> added the comment:
> In this case, please also provide a way to provide the value of the
> VERSION_ID field.
I'm not sure what you mean. PR 23492 exposes the whole content of the
os-release file as a dict. There is no special case for any field.
VERSION_ID can be retrieved as any field with:
platform.freedesktop_os_release().get('VERSION_ID', '').
Example on Fedora 33.
$ cat /etc/os-release
NAME=Fedora
VERSION="33 (Workstation Edition)"
ID=fedora
VERSION_ID=33
VERSION_CODENAME=""
PLATFORM_ID="platform:f33"
PRETTY_NAME="Fedora 33 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:33"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f33/system-administrators-guide/"
SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=33
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=33
PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy"
VARIANT="Workstation Edition"
VARIANT_ID=workstation
$ ./python
Python 3.10.0a2+ (heads/pr/23492:6a4c92bcbe, Nov 30 2020, 22:29:23)
[GCC 10.2.1 20201016 (Red Hat 10.2.1-6)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import platform, pprint
>>> os_release=platform.freedesktop_os_release()
>>> pprint.pprint(os_release)
{'ANSI_COLOR': '0;38;2;60;110;180',
'BUG_REPORT_URL': 'https://bugzilla.redhat.com/',
'CPE_NAME': 'cpe:/o:fedoraproject:fedora:33',
'DOCUMENTATION_URL':
'https://docs.fedoraproject.org/en-US/fedora/f33/system-administrators-guide/',
'HOME_URL': 'https://fedoraproject.org/',
'ID': 'fedora',
'LOGO': 'fedora-logo-icon',
'NAME': 'Fedora',
'PLATFORM_ID': 'platform:f33',
'PRETTY_NAME': 'Fedora 33 (Workstation Edition)',
'PRIVACY_POLICY_URL': 'https://fedoraproject.org/wiki/Legal:PrivacyPolicy',
'REDHAT_BUGZILLA_PRODUCT': 'Fedora',
'REDHAT_BUGZILLA_PRODUCT_VERSION': '33',
'REDHAT_SUPPORT_PRODUCT': 'Fedora',
'REDHAT_SUPPORT_PRODUCT_VERSION': '33',
'SUPPORT_URL': 'https://fedoraproject.org/wiki/Communicating_and_getting_help',
'VARIANT': 'Workstation Edition',
'VARIANT_ID': 'workstation',
'VERSION': '33 (Workstation Edition)',
'VERSION_CODENAME': '',
'VERSION_ID': '33'}
>>> os_release['VERSION_ID']
'33'
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue28468>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com