__revision__ = "$Id$"
-import sys, os, string, re
+import sys, os, re
from types import *
from distutils.errors import *
from distutils import util, dir_util, file_util, archive_util, dep_util
print indent + header
indent = indent + " "
for (option, _, _) in self.user_options:
- option = string.translate(option, longopt_xlate)
+ option = option.translate(longopt_xlate)
if option[-1] == "=":
option = option[:-1]
value = getattr(self, option)
"""
if exec_msg is None:
exec_msg = "generating %s from %s" % \
- (outfile, string.join(infiles, ', '))
+ (outfile, ', '.join(infiles))
if skip_msg is None:
skip_msg = "skipping %s (inputs unchanged)" % outfile
if ord(code[0]) == SET_LINENO:
lineno = ord(code[1]) | ord(code[2]) << 8
line = linecache.getline(filename, lineno)
- words = string.split(line)
+ words = line.split()
if len(words) >= 2 and words[0] in ('def', 'class'):
name = words[1]
for i in range(len(name)):
import regex
from regex_syntax import *
-import string
opt_show_where = 0
opt_show_filename = 0
def showline(filename, lineno, line, prog):
if line[-1:] == '\n': line = line[:-1]
if opt_show_lineno:
- prefix = string.rjust(`lineno`, 3) + ': '
+ prefix = `lineno`.rjust(, 3) + ': '
else:
prefix = ''
if opt_show_filename:
import imp
-import string
import sys
import __builtin__
def load_dynamic(self, name, stuff):
file, filename, (suff, mode, type) = stuff
# Hack around restriction in imp.load_dynamic()
- i = string.rfind(name, '.')
+ i = name.rfind('.')
tail = name[i+1:]
if sys.modules.has_key(tail):
save = sys.modules[tail]
def set_parent(self, m):
name = m.__name__
if '.' in name:
- name = name[:string.rfind(name, '.')]
+ name = name[:name.rfind('.')]
else:
name = ''
m.__ = sys.modules[name]
name = package.__name__
package.__domain__ = domain = [name]
while '.' in name:
- name = name[:string.rfind(name, '.')]
+ name = name[:name.rfind('.')]
domain.append(name)
if name:
domain.append('')
if not name:
return self.finish(package, p, '', fromlist)
if '.' in name:
- i = string.find(name, '.')
+ i = name.find('.')
name, tail = name[:i], name[i:]
else:
tail = ''
m = self.get1(mname)
return self.finish(package, m, tail, fromlist)
if '.' in name:
- i = string.find(name, '.')
+ i = name.find('.')
name, tail = name[:i], name[i:]
else:
tail = ''
yname, tail = yname + tail, ''
m = self.get1(yname)
while tail:
- i = string.find(tail, '.', 1)
+ i = tail.find('.', 1)
if i > 0:
head, tail = tail[:i], tail[i:]
else:
if sys.modules.has_key(name):
return sys.modules[name]
if '.' in name:
- i = string.rfind(name, '.')
+ i = name.rfind('.')
head, tail = name[:i], name[i+1:]
else:
head, tail = '', name
def reload(self, module):
name = module.__name__
if '.' in name:
- i = string.rfind(name, '.')
+ i = name.rfind('.')
head, tail = name[:i], name[i+1:]
path = sys.modules[head].__path__
else:
import os
from stat import ST_MTIME
-import string
# Print help
def help():
packtree(outfp, subdirname)
def unixfix(name):
- comps = string.splitfields(name, os.sep)
+ comps = name.splitfields(os.sep)
res = ''
for comp in comps:
if comp:
import sys
import os
from stat import *
-import string
import linecache
def br(): browser(sys.last_traceback)
except EOFError:
print '\n[EOF]'
break
- cmd = string.strip(line)
+ cmd = line.strip()
if cmd:
if cmd == 'quit':
break
last = lineno
first = max(1, last-10)
for i in range(first, last+1):
- if i == lineno: prefix = '***' + string.rjust(`i`, 4) + ':'
- else: prefix = string.rjust(`i`, 7) + ':'
+ if i == lineno: prefix = '***' + `i`.rjust(4) + ':'
+ else: prefix = `i`.rjust(7) + ':'
line = linecache.getline(filename, i)
if line[-1:] == '\n': line = line[:-1]
print prefix + line
info = '"' + filename + '"(' + `lineno` + ')'
line = linecache.getline(filename, lineno)
if line:
- info = info + ': ' + string.strip(line)
+ info = info + ': ' + line.strip()
print info
def printsymbols(d):
keys = d.keys()
keys.sort()
for name in keys:
- print ' ' + string.ljust(name, 12) + ':',
+ print ' ' + name.ljust(12) + ':',
printobject(d[name], 4)
print
TclError = _tkinter.TclError
from types import *
from Tkconstants import *
-import string; _string = string; del string
try:
import MacOS; _MacOS = MacOS; del MacOS
except ImportError:
_MacOS = None
-TkVersion = _string.atof(_tkinter.TK_VERSION)
-TclVersion = _string.atof(_tkinter.TCL_VERSION)
+TkVersion = float(_tkinter.TK_VERSION)
+TclVersion = float(_tkinter.TCL_VERSION)
READABLE = _tkinter.READABLE
WRITABLE = _tkinter.WRITABLE
return t[:1] + tuple(map(self.__winfo_getint, t[1:]))
def __winfo_getint(self, x):
"""Internal function."""
- return _string.atoi(x, 0)
+ return int(x, 0)
def winfo_vrootheight(self):
"""Return the height of the virtual root window associated with this
widget in pixels. If there is no virtual root window return the
%
(add and '+' or '',
funcid,
- _string.join(self._subst_format)))
+ " ".join(self._subst_format)))
self.tk.call(what + (sequence, cmd))
return funcid
elif sequence:
if name[0] == '.':
w = w._root()
name = name[1:]
- find = _string.find
while name:
- i = find(name, '.')
+ i = name.find('.')
if i >= 0:
name, tail = name[:i], name[i+1:]
else:
__version__ = "0.9"
import Tkinter
-import string
# weight/slant
NORMAL = "normal"
def measure(self, text):
"Return text width"
- return string.atoi(self._call("font", "measure", self.name, text))
+ return int(self._call("font", "measure", self.name, text))
def metrics(self, *options):
"""Return font metrics.
using this font before calling this method."""
if options:
- return string.atoi(
+ return int(
self._call("font", "metrics", self.name, self._get(options))
)
else:
res = self._split(self._call("font", "metrics", self.name))
options = {}
for i in range(0, len(res), 2):
- options[res[i][1:]] = string.atoi(res[i+1])
+ options[res[i][1:]] = int(res[i+1])
return options
def families(root=None):
# --------------------------------------------------------------------
# convenience dialogues
-import string
-
class _QueryDialog(Dialog):
def __init__(self, title, prompt,
class _QueryInteger(_QueryDialog):
errormessage = "Not an integer."
def getresult(self):
- return string.atoi(self.entry.get())
+ return int(self.entry.get())
def askinteger(title, prompt, **kw):
'''get an integer from the user
class _QueryFloat(_QueryDialog):
errormessage = "Not a floating point value."
def getresult(self):
- return string.atof(self.entry.get())
+ return float(self.entry.get())
def askfloat(title, prompt, **kw):
'''get a float from the user
# XXX: show string offset and offending character for all errors
-import string, sys
+import sys
from sre_constants import *
"u": SRE_FLAG_UNICODE,
}
-try:
- int("10", 8)
- atoi = int
-except TypeError:
- atoi = string.atoi
-
class Pattern:
# master pattern object. keeps track of global attributes
def __init__(self):
def _group(escape, groups):
# check if the escape string represents a valid group
try:
- gid = atoi(escape[1:])
+ gid = int(escape[1:])
if gid and gid < groups:
return gid
except ValueError:
escape = escape[2:]
if len(escape) != 2:
raise error, "bogus escape: %s" % repr("\\" + escape)
- return LITERAL, atoi(escape, 16) & 0xff
+ return LITERAL, int(escape, 16) & 0xff
elif str(escape[1:2]) in OCTDIGITS:
# octal escape (up to three digits)
while source.next in OCTDIGITS and len(escape) < 5:
escape = escape + source.get()
escape = escape[1:]
- return LITERAL, atoi(escape, 8) & 0xff
+ return LITERAL, int(escape, 8) & 0xff
if len(escape) == 2:
return LITERAL, ord(escape[1])
except ValueError:
escape = escape + source.get()
if len(escape) != 4:
raise ValueError
- return LITERAL, atoi(escape[2:], 16) & 0xff
+ return LITERAL, int(escape[2:], 16) & 0xff
elif escape[1:2] == "0":
# octal escape
while source.next in OCTDIGITS and len(escape) < 4:
escape = escape + source.get()
- return LITERAL, atoi(escape[1:], 8) & 0xff
+ return LITERAL, int(escape[1:], 8) & 0xff
elif escape[1:2] in DIGITS:
# octal escape *or* decimal group reference (sigh)
here = source.tell()
source.next in OCTDIGITS):
# got three octal digits; this is an octal escape
escape = escape + source.get()
- return LITERAL, atoi(escape[1:], 8) & 0xff
+ return LITERAL, int(escape[1:], 8) & 0xff
# got at least one decimal digit; this is a group reference
group = _group(escape, state.groups)
if group:
source.seek(here)
continue
if lo:
- min = atoi(lo)
+ min = int(lo)
if hi:
- max = atoi(hi)
+ max = int(hi)
if max < min:
raise error, "bad repeat interval"
else:
if not name:
raise error, "bad group name"
try:
- index = atoi(name)
+ index = int(name)
except ValueError:
if not isname(name):
raise error, "bad character in group name"
break
if not code:
this = this[1:]
- code = LITERAL, atoi(this[-6:], 8) & 0xff
+ code = LITERAL, int(this[-6:], 8) & 0xff
a(code)
else:
try:
if s is None:
raise error, "empty group"
a(s)
- return string.join(p, sep)
+ return sep.join(p)
"""
import sys
-import string
import os
import getopt
import traceback
filename = os.path.join(gettempdir(), 'pynexttest')
try:
fp = open(filename, 'r')
- next = string.strip(fp.read())
+ next = fp.read().strip()
tests = [next]
fp.close()
except IOError:
print "that passes in verbose mode may fail without it."
if bad:
print count(len(bad), "test"), "failed:",
- print string.join(bad)
+ print " ".join(bad)
if skipped and not quiet:
print count(len(skipped), "test"), "skipped:",
- print string.join(skipped)
+ print " ".join(skipped)
if single:
alltests = findtests(testdir, stdtests, nottests)
Extra arguments are used to seed the random generator.
"""
- import string
# default range (inclusive)
k1 = 15
k2 = 19
if sys.argv[1:]:
# one argument: single point
- k1 = k2 = string.atoi(sys.argv[1])
+ k1 = k2 = int(sys.argv[1])
if sys.argv[2:]:
# two arguments: specify range
- k2 = string.atoi(sys.argv[2])
+ k2 = int(sys.argv[2])
if sys.argv[3:]:
# derive random seed from remaining arguments
x, y, z = 0, 0, 0
test('join', BadSeq2(), 'a b c')
# try a few long ones
- print string.join(['x' * 100] * 100, ':')
- print string.join(('x' * 100,) * 100, ':')
+ print ":".join(['x' * 100] * 100)
+ print ":".join(('x' * 100,) * 100)
def run_method_tests(test):
import dospath
-import string
import os
errors = 0
def tester(fn, wantResult):
- fn = string.replace(fn, "\\", "\\\\")
+ fn = fn.replace("\\", "\\\\")
gotResult = eval(fn)
if wantResult != gotResult:
print "error!"
from test_support import verify, verbose, TestFailed
from UserList import UserList
-import string
def sortdict(d):
keys = d.keys()
if vararg: arglist.append('*' + vararg)
if kwarg: arglist.append('**' + kwarg)
decl = 'def %s(%s): print "ok %s", a, b, d, e, v, k' % (
- name, string.join(arglist, ', '), name)
+ name, ', '.join(arglist), name)
exec(decl)
func = eval(name)
funcs.append(func)
import sys
import os
- import string
outputfile = '/tmp/deleteme'
else: # ...or the full path of the module
ourname = sys.modules[__name__].__file__
- parts = string.splitfields(ourname, os.sep)
+ parts = ourname.split(os.sep)
parts[-1] = name
- name = string.joinfields(parts, os.sep)
+ name = os.sep.joinfields(parts)
sizes = imgfile.getsizes(name)
if verbose:
print 'Opening test image: %s, sizes: %s' % (name, str(sizes))
from test_support import verify
import mmap
-import string, os, re, sys
+import os, re, sys
PAGESIZE = mmap.PAGESIZE
# Simple sanity checks
print type(m) # SF bug 128713: segfaulted on Linux
- print ' Position of foo:', string.find(m, 'foo') / float(PAGESIZE), 'pages'
- verify(string.find(m, 'foo') == PAGESIZE)
+ print ' Position of foo:', m.find('foo') / float(PAGESIZE), 'pages'
+ verify(m.find('foo') == PAGESIZE)
print ' Length of file:', len(m) / float(PAGESIZE), 'pages'
verify(len(m) == 2*PAGESIZE)
import ntpath
-import string
import os
errors = 0
def tester(fn, wantResult):
- fn = string.replace(fn, "\\", "\\\\")
+ fn = fn.replace("\\", "\\\\")
gotResult = eval(fn)
if wantResult != gotResult:
print "error!"
# Test packages (dotted-name import)
-import sys, os, string, tempfile, traceback
+import sys, os, tempfile, traceback
from os import mkdir, rmdir # Can't test if these fail
del mkdir, rmdir
from test_support import verify, verbose, TestFailed
def mkhier(root, descr):
mkdir(root)
for name, contents in descr:
- comps = string.split(name)
+ comps = name.split()
fullname = root
for c in comps:
fullname = os.path.join(fullname, c)