summaryrefslogtreecommitdiffstats
path: root/Lib/platform.py
diff options
context:
space:
mode:
authorNeal Norwitz <nnorwitz@gmail.com>2007-04-17 08:48:32 (GMT)
committerNeal Norwitz <nnorwitz@gmail.com>2007-04-17 08:48:32 (GMT)
commit9d72bb452bced3a100f07f8a9e30c4495a9ec41a (patch)
treec39762a764fcc16f2cfc42e2504e58ff31e159e6 /Lib/platform.py
parentff11334927ee616d765b54a3851016b76a20bcec (diff)
downloadcpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.zip
cpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.tar.gz
cpython-9d72bb452bced3a100f07f8a9e30c4495a9ec41a.tar.bz2
Remove functions in string module that are also string methods. Also remove:
* all calls to functions in the string module (except maketrans) * everything from stropmodule except for maketrans() which is still used
Diffstat (limited to 'Lib/platform.py')
-rwxr-xr-xLib/platform.py60
1 files changed, 28 insertions, 32 deletions
diff --git a/Lib/platform.py b/Lib/platform.py
index 720da04..ed5d22d 100755
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -112,7 +112,7 @@ __copyright__ = """
__version__ = '1.0.6'
-import sys,string,os,re
+import sys, os, re
### Platform specific APIs
@@ -189,15 +189,15 @@ def _dist_try_harder(distname,version,id):
info = open('/var/adm/inst-log/info').readlines()
distname = 'SuSE'
for line in info:
- tv = string.split(line)
+ tv = line.split()
if len(tv) == 2:
tag,value = tv
else:
continue
if tag == 'MIN_DIST_VERSION':
- version = string.strip(value)
+ version = value.strip()
elif tag == 'DIST_IDENT':
- values = string.split(value,'-')
+ values = value.split('-')
id = values[2]
return distname,version,id
@@ -205,7 +205,7 @@ def _dist_try_harder(distname,version,id):
# Caldera OpenLinux has some infos in that file (thanks to Colin Kong)
info = open('/etc/.installed').readlines()
for line in info:
- pkg = string.split(line,'-')
+ pkg = line.split('-')
if len(pkg) >= 2 and pkg[0] == 'OpenLinux':
# XXX does Caldera support non Intel platforms ? If yes,
# where can we find the needed id ?
@@ -258,7 +258,7 @@ def _parse_release_file(firstline):
return tuple(m.groups())
# Unkown format... take the first two words
- l = string.split(string.strip(firstline))
+ l = firstline.strip().split()
if l:
version = l[0]
if len(l) > 1:
@@ -451,7 +451,7 @@ def _norm_version(version, build=''):
""" Normalize the version and build strings and return a single
version string using the format major.minor.build (or patchlevel).
"""
- l = string.split(version,'.')
+ l = version.split('.')
if build:
l.append(build)
try:
@@ -460,7 +460,7 @@ def _norm_version(version, build=''):
strings = l
else:
strings = map(str,ints)
- version = string.join(strings[:3],'.')
+ version = '.'.join(strings[:3])
return version
_ver_output = re.compile(r'(?:([\w ]+) ([\w.]+) '
@@ -505,7 +505,7 @@ def _syscmd_ver(system='', release='', version='',
return system,release,version
# Parse the output
- info = string.strip(info)
+ info = info.strip()
m = _ver_output.match(info)
if m is not None:
system,release,version = m.groups()
@@ -766,7 +766,7 @@ def system_alias(system,release,version):
# These releases use the old name SunOS
return system,release,version
# Modify release (marketing release = SunOS release - 3)
- l = string.split(release,'.')
+ l = release.split('.')
if l:
try:
major = int(l[0])
@@ -775,7 +775,7 @@ def system_alias(system,release,version):
else:
major = major - 3
l[0] = str(major)
- release = string.join(l,'.')
+ release = '.'.join(l)
if release < '6':
system = 'Solaris'
else:
@@ -806,28 +806,24 @@ def _platform(*args):
compatible format e.g. "system-version-machine".
"""
# Format the platform string
- platform = string.join(
- map(string.strip,
- filter(len, args)),
- '-')
+ platform = '-'.join(x.strip() for x in filter(len, args))
# Cleanup some possible filename obstacles...
- replace = string.replace
- platform = replace(platform,' ','_')
- platform = replace(platform,'/','-')
- platform = replace(platform,'\\','-')
- platform = replace(platform,':','-')
- platform = replace(platform,';','-')
- platform = replace(platform,'"','-')
- platform = replace(platform,'(','-')
- platform = replace(platform,')','-')
+ platform = platform.replace(' ','_')
+ platform = platform.replace('/','-')
+ platform = platform.replace('\\','-')
+ platform = platform.replace(':','-')
+ platform = platform.replace(';','-')
+ platform = platform.replace('"','-')
+ platform = platform.replace('(','-')
+ platform = platform.replace(')','-')
# No need to report 'unknown' information...
- platform = replace(platform,'unknown','')
+ platform = platform.replace('unknown','')
# Fold '--'s and remove trailing '-'
while 1:
- cleaned = replace(platform,'--','-')
+ cleaned = platform.replace('--','-')
if cleaned == platform:
break
platform = cleaned
@@ -889,7 +885,7 @@ def _syscmd_uname(option,default=''):
f = os.popen('uname %s 2> /dev/null' % option)
except (AttributeError,os.error):
return default
- output = string.strip(f.read())
+ output = f.read().strip()
rc = f.close()
if not output or rc:
return default
@@ -911,7 +907,7 @@ def _syscmd_file(target,default=''):
f = os.popen('file %s 2> /dev/null' % target)
except (AttributeError,os.error):
return default
- output = string.strip(f.read())
+ output = f.read().strip()
rc = f.close()
if not output or rc:
return default
@@ -1082,7 +1078,7 @@ def uname():
elif system[:4] == 'java':
release,vendor,vminfo,osinfo = java_ver()
system = 'Java'
- version = string.join(vminfo,', ')
+ version = ', '.join(vminfo)
if not version:
version = vendor
@@ -1285,10 +1281,10 @@ def _sys_version(sys_version=None):
builddate = builddate + ' ' + buildtime
# Add the patchlevel version if missing
- l = string.split(version, '.')
+ l = version.split('.')
if len(l) == 2:
l.append('0')
- version = string.join(l, '.')
+ version = '.'.join(l)
# Build and cache the result
result = (name, version, branch, revision, buildno, builddate, compiler)
@@ -1345,7 +1341,7 @@ def python_version_tuple():
"""
if hasattr(sys, 'version_info'):
return sys.version_info[:3]
- return tuple(string.split(_sys_version()[1], '.'))
+ return tuple(_sys_version()[1].split('.'))
def python_branch():