From 3a78849b5f91e76aede2a1e3b712aaf292a08d38 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Tue, 14 Oct 2003 22:32:34 +0000 Subject: Backport of rev. 1.6 and 1.7 from head. 1.6 was docstring clean-up. 1.7 was a fix for bug #780461 (platform.mac_ver() failing under OS X) and was flagged as a backport candidate. --- Lib/platform.py | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/Lib/platform.py b/Lib/platform.py index 1d486db..1547e12 100755 --- a/Lib/platform.py +++ b/Lib/platform.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -""" This module tries to retrieve as much platform identifying data as +""" This module tries to retrieve as much platform-identifying data as possible. It makes this information available via function APIs. If called from the command line, it prints the platform @@ -20,7 +20,7 @@ # * support for Amiga and other still unsupported platforms running Python # * support for additional Linux distributions # -# Many thanks to all those who helped adding platform specific +# Many thanks to all those who helped adding platform-specific # checks (in no particular order): # # Charles G Waldman, David Arnold, Gordon McMillan, Ben Darnell, @@ -118,15 +118,15 @@ def libc_ver(executable=sys.executable,lib='',version='', chunksize=2048): - """ Tries to determine the libc version against which the - file executable (defaults to the Python interpreter) is linked. + """ Tries to determine the libc version that the file executable + (which defaults to the Python interpreter) is linked against. Returns a tuple of strings (lib,version) which default to the given parameters in case the lookup fails. Note that the function has intimate knowledge of how different - libc versions add symbols to the executable is probably only - useable for executables compiled using gcc. + libc versions add symbols to the executable and thus is probably + only useable for executables compiled using gcc. The file is read and scanned in chunks of chunksize bytes. @@ -219,13 +219,13 @@ def dist(distname='',version='',id='', supported_dists=('SuSE','debian','redhat','mandrake')): - """ Tries to determine the name of the OS distribution name + """ Tries to determine the name of the Linux OS distribution name. The function first looks for a distribution release file in /etc and then reverts to _dist_try_harder() in case no suitable files are found. - Returns a tuple distname,version,id which default to the + Returns a tuple (distname,version,id) which default to the args given as parameters. """ @@ -351,7 +351,7 @@ def popen(cmd, mode='r', bufsize=None): def _norm_version(version,build=''): - """ Normalize the version and build strings and return a sinlge + """ Normalize the version and build strings and return a single vesion string using the format major.minor.build (or patchlevel). """ l = string.split(version,'.') @@ -525,12 +525,13 @@ def win32_ver(release='',version='',csd='',ptype=''): def _mac_ver_lookup(selectors,default=None): from gestalt import gestalt + import MacOS l = [] append = l.append for selector in selectors: try: append(gestalt(selector)) - except RuntimeError: + except (RuntimeError, MacOS.Error): append(default) return l @@ -544,8 +545,8 @@ def mac_ver(release='',versioninfo=('','',''),machine=''): versioninfo, machine) with versioninfo being a tuple (version, dev_stage, non_release_version). - Entries which cannot be determined are set to ''. All tuple - entries are strings. + Entries which cannot be determined are set to the paramter values + which default to ''. All tuple entries are strings. Thanks to Mark R. Levinson for mailing documentation links and code examples for this function. Documentation for the @@ -557,6 +558,7 @@ def mac_ver(release='',versioninfo=('','',''),machine=''): # Check whether the version info module is available try: import gestalt + import MacOS except ImportError: return release,versioninfo,machine # Get the infos @@ -595,7 +597,7 @@ def _java_getprop(name,default): def java_ver(release='',vendor='',vminfo=('','',''),osinfo=('','','')): - """ Version interface for JPython. + """ Version interface for Jython. Returns a tuple (release,vendor,vminfo,osinfo) with vminfo being a tuple (vm_name,vm_release,vm_vendor) and osinfo being a @@ -815,9 +817,9 @@ _architecture_split = re.compile(r'[\s,]').split def architecture(executable=sys.executable,bits='',linkage=''): """ Queries the given executable (defaults to the Python interpreter - binary) for various architecture informations. + binary) for various architecture information. - Returns a tuple (bits,linkage) which contain information about + Returns a tuple (bits,linkage) which contains information about the bit architecture and the linkage format used for the executable. Both values are returned as strings. @@ -828,9 +830,9 @@ def architecture(executable=sys.executable,bits='',linkage=''): The function relies on the system's "file" command to do the actual work. This is available on most if not all Unix - platforms. On some non-Unix platforms and then only if the - executable points to the Python interpreter defaults from - _default_architecture are used. + platforms. On some non-Unix platforms where the "file" command + does not exist and the executable is set to the Python interpreter + binary defaults from _default_architecture are used. """ # Use the sizeof(pointer) as default number of bits if nothing @@ -905,7 +907,7 @@ def uname(): identifying the underlying platform. Note that unlike the os.uname function this also returns - possible processor information as additional tuple entry. + possible processor information as an additional tuple entry. Entries which cannot be determined are set to ''. @@ -1013,7 +1015,8 @@ def system(): def node(): - """ Returns the computer's network name (may not be fully qualified !) + """ Returns the computer's network name (which may not be fully + qualified) An empty string is returned if the value cannot be determined. -- cgit v0.12