[Python-checkins] python/dist/src/Lib platform.py,1.1,1.2
lemburg@users.sourceforge.net
lemburg@users.sourceforge.net
Thu, 24 Apr 2003 04:46:38 -0700
Update of /cvsroot/python/python/dist/src/Lib
In directory sc8-pr-cvs1:/tmp/cvs-serv32432
Modified Files:
platform.py
Log Message:
Reformatted a bit to remove the lengthy re.compile() from the function
definitions.
Index: platform.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/platform.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** platform.py 24 Apr 2003 11:36:11 -0000 1.1
--- platform.py 24 Apr 2003 11:46:35 -0000 1.2
***************
*** 32,35 ****
--- 32,36 ----
#
# History:
+ # 1.0.1 - reformatted to make doc.py happy
# 1.0.0 - reformatted a bit and checked into Python CVS
# 0.8.0 - added sys.version parser and various new access
***************
*** 102,106 ****
"""
! __version__ = '1.0.0'
import sys,string,os,re
--- 103,107 ----
"""
! __version__ = '1.0.1'
import sys,string,os,re
***************
*** 108,121 ****
### Platform specific APIs
def libc_ver(executable=sys.executable,lib='',version='',
! chunksize=2048,
! libc_search=re.compile(r'(__libc_init)'
! '|'
! '(GLIBC_([0-9.]+))'
! '|'
! '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)'
! )
! ):
""" Tries to determine the libc version against which the
--- 109,121 ----
### Platform specific APIs
+ _libc_search = re.compile(r'(__libc_init)'
+ '|'
+ '(GLIBC_([0-9.]+))'
+ '|'
+ '(libc(_\w+)?\.so(?:\.(\d[0-9.]*))?)')
+
def libc_ver(executable=sys.executable,lib='',version='',
! chunksize=2048):
""" Tries to determine the libc version against which the
***************
*** 136,140 ****
pos = 0
while 1:
! m = libc_search.search(binary,pos)
if not m:
binary = f.read(chunksize)
--- 136,140 ----
pos = 0
while 1:
! m = _libc_search.search(binary,pos)
if not m:
binary = f.read(chunksize)
***************
*** 213,221 ****
return distname,version,id
def dist(distname='',version='',id='',
! supported_dists=('SuSE','debian','redhat','mandrake'),
! release_filename=re.compile(r'(\w+)[-_](release|version)'),
! release_version=re.compile(r'([\d.]+)[^(]*(?:\((.+)\))?')):
""" Tries to determine the name of the OS distribution name
--- 213,222 ----
return distname,version,id
+ _release_filename = re.compile(r'(\w+)[-_](release|version)')
+ _release_version = re.compile(r'([\d.]+)[^(]*(?:\((.+)\))?')
+
def dist(distname='',version='',id='',
! supported_dists=('SuSE','debian','redhat','mandrake')):
""" Tries to determine the name of the OS distribution name
***************
*** 235,239 ****
return distname,version,id
for file in etc:
! m = release_filename.match(file)
if m:
_distname,dummy = m.groups()
--- 236,240 ----
return distname,version,id
for file in etc:
! m = _release_filename.match(file)
if m:
_distname,dummy = m.groups()
***************
*** 246,250 ****
firstline = f.readline()
f.close()
! m = release_version.search(firstline)
if m:
_version,_id = m.groups()
--- 247,251 ----
firstline = f.readline()
f.close()
! m = _release_version.search(firstline)
if m:
_version,_id = m.groups()
***************
*** 366,375 ****
return version
def _syscmd_ver(system='',release='',version='',
! supported_platforms=('win32','win16','dos','os2'),
! ver_output=re.compile(r'(?:([\w ]+) ([\w.]+) '
! '.*'
! 'Version ([\d.]+))')):
""" Tries to figure out the OS version used and returns
--- 367,377 ----
return version
+ _ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) '
+ '.*'
+ 'Version ([\d.]+))')
+
def _syscmd_ver(system='',release='',version='',
! supported_platforms=('win32','win16','dos','os2')):
""" Tries to figure out the OS version used and returns
***************
*** 408,412 ****
# Parse the output
info = string.strip(info)
! m = ver_output.match(info)
if m:
system,release,version = m.groups()
--- 410,414 ----
# Parse the output
info = string.strip(info)
! m = _ver_output.match(info)
if m:
system,release,version = m.groups()
***************
*** 809,815 ****
}
! def architecture(executable=sys.executable,bits='',linkage='',
! split=re.compile(r'[\s,]').split):
""" Queries the given executable (defaults to the Python interpreter
--- 811,817 ----
}
! _architecture_split = re.compile(r'[\s,]').split
! def architecture(executable=sys.executable,bits='',linkage=''):
""" Queries the given executable (defaults to the Python interpreter
***************
*** 859,863 ****
# Split the output into a list of strings omitting the filename
! fileout = split(output)[1:]
if 'executable' not in fileout:
--- 861,865 ----
# Split the output into a list of strings omitting the filename
! fileout = _architecture_split(output)[1:]
if 'executable' not in fileout: