STINNER Victor <vstin...@python.org> added the comment:

The distro module has been mentioned multiple times. I looked at its code base 
and I suggest to not add it to  the Python stdlib. It contains code specific to 
some Linux distributions. Examples.

elif 'ubuntu_codename' in props:
    # Same as above but a non-standard field name used on older Ubuntus
    props['codename'] = props['ubuntu_codename']

NORMALIZED_LSB_ID = {
    'enterpriseenterpriseas': 'oracle',  # Oracle Enterprise Linux 4
    'enterpriseenterpriseserver': 'oracle',  # Oracle Linux 5
    'redhatenterpriseworkstation': 'rhel',  # RHEL 6, 7 Workstation
    'redhatenterpriseserver': 'rhel',  # RHEL 6, 7 Server
    'redhatenterprisecomputenode': 'rhel',  # RHEL 6 ComputeNode
}

basenames = ['SuSE-release',
             'arch-release',
             'base-release',
             'centos-release',
             'fedora-release',
             'gentoo-release',
             'mageia-release',
             'mandrake-release',
             'mandriva-release',
             'mandrivalinux-release',
             'manjaro-release',
             'oracle-release',
             'redhat-release',
             'sl-release',
             'slackware-version']

platform.linux_distribution() has been removed because it was difficult to keep 
the implementation up to date, whereas Python are rarely or not updated during 
the lifecycle of a Linux distribution version.

--

The os-release file is different: the filename is standardized and the file 
format is standardized. I expect really minor maintenance on a function parsing 
it.

Note: distro doesn't specify an encoding when opening os-release, but use the 
locale encoding. I suggest to use UTF-8.

The distro module remains useful since it tries to better API. For example, 
variable names are converted to lowercase and it extracts the codebase from the 
version variable:

        elif 'version' in props:
            # If there is no version_codename, parse it from the version
            codename = re.search(r'(\(\D+\))|,(\s+)?\D+', props['version'])
            if codename:
                codename = codename.group()
                codename = codename.strip('()')
                codename = codename.strip(',')
                codename = codename.strip()
                # codename appears within paranthese.
                props['codename'] = codename

But again, I don't think that we should implement such heuristics (code 
specific to some Linux distributions) in the stdlib, to minimize the 
maintenance burden.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue28468>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to