New == syntax

This commit is contained in:
Guido van Rossum 1992-01-01 19:35:13 +00:00
parent 4d8e859e8f
commit bdfcfccbe5
73 changed files with 419 additions and 391 deletions

View file

@ -12,17 +12,17 @@ error = 'fact.error' # exception
def fact(n): def fact(n):
if n < 1: raise error # fact() argument should be >= 1 if n < 1: raise error # fact() argument should be >= 1
if n = 1: return [] # special case if n == 1: return [] # special case
res = [] res = []
# Treat even factors special, so we can use i = i+2 later # Treat even factors special, so we can use i = i+2 later
while n%2 = 0: while n%2 == 0:
res.append(2) res.append(2)
n = n/2 n = n/2
# Try odd numbers up to sqrt(n) # Try odd numbers up to sqrt(n)
limit = sqrt(n+1) limit = sqrt(n+1)
i = 3 i = 3
while i <= limit: while i <= limit:
if n%i = 0: if n%i == 0:
res.append(i) res.append(i)
n = n/i n = n/i
limit = sqrt(n+1) limit = sqrt(n+1)

View file

@ -24,13 +24,13 @@ except RuntimeError:
while 1: while 1:
line = mail.readline() line = mail.readline()
if not line: break # EOF if not line: break # EOF
if line[:5] = 'From ': if line[:5] == 'From ':
# Start of message found # Start of message found
print line[:-1], print line[:-1],
while 1: while 1:
line = mail.readline() line = mail.readline()
if not line: break # EOF if not line: break # EOF
if line = '\n': break # Blank line ends headers if line == '\n': break # Blank line ends headers
if line[:8] = 'Subject:': if line[:8] == 'Subject:':
print `line[9:-1]`, print `line[9:-1]`,
print print

View file

@ -23,7 +23,7 @@ def main():
# Strip '-P' from printer names just in case # Strip '-P' from printer names just in case
# the user specified it... # the user specified it...
for i in range(len(printers)): for i in range(len(printers)):
if printers[i][:2] = '-P': if printers[i][:2] == '-P':
printers[i] = printers[i][2:] printers[i] = printers[i][2:]
else: else:
if posix.environ.has_key('PRINTER'): if posix.environ.has_key('PRINTER'):
@ -54,13 +54,13 @@ def makestatus(name, thisuser):
if not line: break if not line: break
fields = string.split(line) fields = string.split(line)
n = len(fields) n = len(fields)
if len(fields) >= 6 and fields[n-1] = 'bytes': if len(fields) >= 6 and fields[n-1] == 'bytes':
rank = fields[0] rank = fields[0]
user = fields[1] user = fields[1]
job = fields[2] job = fields[2]
files = fields[3:-2] files = fields[3:-2]
bytes = eval(fields[n-2]) bytes = eval(fields[n-2])
if user = thisuser: if user == thisuser:
userseen = 1 userseen = 1
elif not userseen: elif not userseen:
aheadbytes = aheadbytes + bytes aheadbytes = aheadbytes + bytes
@ -77,9 +77,9 @@ def makestatus(name, thisuser):
else: else:
if fields and fields[0] <> 'Rank': if fields and fields[0] <> 'Rank':
line = string.strip(line) line = string.strip(line)
if line = 'no entries': if line == 'no entries':
line = name + ': idle' line = name + ': idle'
elif line[-22:] = ' is ready and printing': elif line[-22:] == ' is ready and printing':
line = name line = name
lines.append(line) lines.append(line)
# #
@ -87,12 +87,12 @@ def makestatus(name, thisuser):
line = `(totalbytes+1023)/1024` + ' K' line = `(totalbytes+1023)/1024` + ' K'
if totaljobs <> len(users): if totaljobs <> len(users):
line = line + ' (' + `totaljobs` + ' jobs)' line = line + ' (' + `totaljobs` + ' jobs)'
if len(users) = 1: if len(users) == 1:
line = line + ' for ' + users.keys()[0] line = line + ' for ' + users.keys()[0]
else: else:
line = line + ' for ' + `len(users)` + ' users' line = line + ' for ' + `len(users)` + ' users'
if userseen: if userseen:
if aheadjobs = 0: if aheadjobs == 0:
line = line + ' (' + thisuser + ' first)' line = line + ' (' + thisuser + ' first)'
else: else:
line = line + ' (' + `(aheadbytes+1023)/1024` line = line + ' (' + `(aheadbytes+1023)/1024`

View file

@ -19,7 +19,7 @@ def main():
# Print common digits # Print common digits
d, d1 = a/b, a1/b1 d, d1 = a/b, a1/b1
#print a, b, a1, b1 #print a, b, a1, b1
while d = d1: while d == d1:
# Use write() to avoid spaces between the digits # Use write() to avoid spaces between the digits
sys.stdout.write(`int(d)`) sys.stdout.write(`int(d)`)
# Flush so the output is seen immediately # Flush so the output is seen immediately

View file

@ -17,7 +17,7 @@ def primes(min, max):
i = 3 i = 3
while i <= max: while i <= max:
for p in primes: for p in primes:
if i%p = 0 or p*p > i: break if i%p == 0 or p*p > i: break
if i%p <> 0: if i%p <> 0:
primes.append(i) primes.append(i)
if i >= min: print i if i >= min: print i

View file

@ -16,7 +16,7 @@ day_0 = 3 # The epoch begins on a Thursday (Monday = 0)
# Return 1 for leap years, 0 for non-leap years # Return 1 for leap years, 0 for non-leap years
def isleap(year): def isleap(year):
return year % 4 = 0 and (year % 100 <> 0 or year % 400 = 0) return year % 4 == 0 and (year % 100 <> 0 or year % 400 == 0)
# Constants for months referenced later # Constants for months referenced later
January = 1 January = 1
@ -45,7 +45,7 @@ def gmtime(secs):
yday = days yday = days
month = January month = January
while 1: while 1:
md = mdays[month] + (month = February and isleap(year)) md = mdays[month] + (month == February and isleap(year))
if days < md: break if days < md: break
days = days - md days = days - md
month = month + 1 month = month + 1
@ -122,7 +122,7 @@ def weekday(year, month, day):
# Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month # Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for year, month
def monthrange(year, month): def monthrange(year, month):
day1 = weekday(year, month, 1) day1 = weekday(year, month, 1)
ndays = mdays[month] + (month = February and isleap(year)) ndays = mdays[month] + (month == February and isleap(year))
return day1, ndays return day1, ndays
# Return a matrix representing a month's calendar # Return a matrix representing a month's calendar
@ -161,7 +161,7 @@ def center(str, width):
# Print a single week (no newline) # Print a single week (no newline)
def prweek(week, width): def prweek(week, width):
for day in week: for day in week:
if day = 0: print ' '*width, if day == 0: print ' '*width,
else: else:
if width > 2: print ' '*(width-3), if width > 2: print ' '*(width-3),
if day < 10: print '', if day < 10: print '',

View file

@ -19,7 +19,7 @@ def cmp(f1, f2): # Compare two files, use the cache if possible.
if s1[0] <> 8 or s2[0] <> 8: if s1[0] <> 8 or s2[0] <> 8:
# Either is a not a plain file -- always report as different # Either is a not a plain file -- always report as different
return 0 return 0
if s1 = s2: if s1 == s2:
# type, size & mtime match -- report same # type, size & mtime match -- report same
return 1 return 1
if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
@ -30,7 +30,7 @@ def cmp(f1, f2): # Compare two files, use the cache if possible.
try: try:
cs1, cs2, outcome = cache[key] cs1, cs2, outcome = cache[key]
# cache hit # cache hit
if s1 = cs1 and s2 = cs2: if s1 == cs1 and s2 == cs2:
# cached signatures match # cached signatures match
return outcome return outcome
# stale cached signature(s) # stale cached signature(s)

View file

@ -29,7 +29,7 @@ def cmp(f1, f2):
if not S_ISREG(s1[0]) or not S_ISREG(s2[0]): if not S_ISREG(s1[0]) or not S_ISREG(s2[0]):
# Either is a not a plain file -- always report as different # Either is a not a plain file -- always report as different
return 0 return 0
if s1 = s2: if s1 == s2:
# type, size & mtime match -- report same # type, size & mtime match -- report same
return 1 return 1
if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother if s1[:2] <> s2[:2]: # Types or sizes differ, don't bother
@ -40,7 +40,7 @@ def cmp(f1, f2):
if cache.has_key(key): if cache.has_key(key):
cs1, cs2, outcome = cache[key] cs1, cs2, outcome = cache[key]
# cache hit # cache hit
if s1 = cs1 and s2 = cs2: if s1 == cs1 and s2 == cs2:
# cached signatures match # cached signatures match
return outcome return outcome
# stale cached signature(s) # stale cached signature(s)

View file

@ -25,8 +25,8 @@ def getstatusoutput(cmd):
pipe = posix.popen('{ ' + cmd + '; } 2>&1', 'r') pipe = posix.popen('{ ' + cmd + '; } 2>&1', 'r')
text = pipe.read() text = pipe.read()
sts = pipe.close() sts = pipe.close()
if sts = None: sts = 0 if sts == None: sts = 0
if text[-1:] = '\n': text = text[:-1] if text[-1:] == '\n': text = text[:-1]
return sts, text return sts, text

View file

@ -174,7 +174,7 @@ def cmp(a, b):
# #
def remove(list, item): def remove(list, item):
for i in range(len(list)): for i in range(len(list)):
if list[i] = item: if list[i] == item:
del list[i] del list[i]
break break

View file

@ -22,8 +22,8 @@ def disassemble(co, lasti):
while i < n: while i < n:
c = code[i] c = code[i]
op = ord(c) op = ord(c)
if op = SET_LINENO and i > 0: print # Extra blank line if op == SET_LINENO and i > 0: print # Extra blank line
if i = lasti: print '-->', if i == lasti: print '-->',
else: print ' ', else: print ' ',
if i in labels: print '>>', if i in labels: print '>>',
else: print ' ', else: print ' ',

View file

@ -31,7 +31,7 @@ def dumpsymtab(dict):
def dumpvar(name, x): def dumpvar(name, x):
import sys import sys
t = type(x) t = type(x)
if t = type({}): if t == type({}):
print name, '= {}' print name, '= {}'
for key in x.keys(): for key in x.keys():
item = x[key] item = x[key]
@ -42,7 +42,7 @@ def dumpvar(name, x):
if not printable(x): if not printable(x):
print '#', print '#',
print name, '=', `x` print name, '=', `x`
elif t = type(sys): elif t == type(sys):
print 'import', name, '#', x print 'import', name, '#', x
else: else:
print '#', name, '=', x print '#', name, '=', x
@ -58,6 +58,6 @@ def printable(x):
if not printable(item): if not printable(item):
return 0 return 0
return 1 return 1
if x = {}: if x == {}:
return 1 return 1
return 0 return 0

View file

@ -5,64 +5,70 @@ def fnmatch(name, pat):
# Check for simple case: no special characters # Check for simple case: no special characters
# #
if not ('*' in pat or '?' in pat or '[' in pat): if not ('*' in pat or '?' in pat or '[' in pat):
return name = pat return name == pat
# #
# Check for common cases: *suffix and prefix* # Check for common cases: *suffix and prefix*
# #
if pat[0] = '*': if pat[0] == '*':
p1 = pat[1:] p1 = pat[1:]
if not ('*' in p1 or '?' in p1 or '[' in p1): if not ('*' in p1 or '?' in p1 or '[' in p1):
start = len(name) - len(p1) start = len(name) - len(p1)
return start >= 0 and name[start:] = p1 return start >= 0 and name[start:] == p1
elif pat[-1:] = '*': elif pat[-1:] == '*':
p1 = pat[:-1] p1 = pat[:-1]
if not ('*' in p1 or '?' in p1 or '[' in p1): if not ('*' in p1 or '?' in p1 or '[' in p1):
return name[:len(p1)] = p1 return name[:len(p1)] == p1
# #
# General case # General case
# #
return fnmatch1(name, pat) return fnmatch1(name, pat)
def fnmatch1(name, pat): def fnmatch1(name, pat):
for i in range(len(pat)): i, n = 0, len(pat)
while i < n:
c = pat[i] c = pat[i]
if c = '*': if c == '*':
p1 = pat[i+1:] p1 = pat[i+1:]
if not ('*' in p1 or '?' in p1 or '[' in p1): if not ('*' in p1 or '?' in p1 or '[' in p1):
start = len(name) - len(p1) start = len(name) - len(p1)
return start >= 0 and name[start:] = p1 return start >= 0 and name[start:] == p1
for i in range(i, len(name) + 1): for i in range(i, len(name) + 1):
if fnmatch1(name[i:], p1): if fnmatch1(name[i:], p1):
return 1 return 1
return 0 return 0
elif c = '?': elif c == '?':
if len(name) <= i : return 0 if len(name) <= i : return 0
elif c = '[': elif c == '[':
c, rest = name[i], name[i+1:] c, rest = name[i], name[i+1:]
i, n = i+1, len(pat) - 1 i, n = i+1, len(pat) - 1
match = 0 match = 0
exclude = 0 exclude = 0
if i < n and pat[i] = '!': if i < n and pat[i] == '!':
exclude = 1 exclude = 1
i = i+1 i = i+1
while i < n: while i < n:
if pat[i] = c: match = 1 if pat[i] == c: match = 1
i = i+1 i = i+1
if i >= n or pat[i] = ']': if i >= n or pat[i] == ']':
break break
if pat[i] = '-': if pat[i] == '-':
i = i+1 i = i+1
if i >= n or pat[i] = ']': if i >= n or pat[i] == ']':
break break
match = (pat[i-2] <= c <= pat[i]) if pat[i-2] <= c <= pat[i]:
match = 1
i = i+1 i = i+1
if match = exclude: if i >= n or pat[i] == ']':
break
if match == exclude:
return 0 return 0
return fnmatch1(rest, pat[i+1:]) return fnmatch1(rest, pat[i+1:])
else: else:
if name[i:i+1] <> c: if name[i:i+1] <> c:
return 0 return 0
return 1 i = i+1
# We don't get here if the pattern contained * or [...]
return i >= len(name)
def fnmatchlist(names, pat): def fnmatchlist(names, pat):
res = [] res = []

View file

@ -22,15 +22,15 @@ error = 'getopt error'
def getopt(args, options): def getopt(args, options):
list = [] list = []
while args and args[0][0] = '-' and args[0] <> '-': while args and args[0][0] == '-' and args[0] <> '-':
if args[0] = '--': if args[0] == '--':
args = args[1:] args = args[1:]
break break
optstring, args = args[0][1:], args[1:] optstring, args = args[0][1:], args[1:]
while optstring <> '': while optstring <> '':
opt, optstring = optstring[0], optstring[1:] opt, optstring = optstring[0], optstring[1:]
if classify(opt, options): # May raise exception as well if classify(opt, options): # May raise exception as well
if optstring = '': if optstring == '':
if not args: if not args:
raise error, 'option -' + opt + ' requires argument' raise error, 'option -' + opt + ' requires argument'
optstring, args = args[0], args[1:] optstring, args = args[0], args[1:]
@ -42,6 +42,6 @@ def getopt(args, options):
def classify(opt, options): # Helper to check type of option def classify(opt, options): # Helper to check type of option
for i in range(len(options)): for i in range(len(options)):
if opt = options[i] <> ':': if opt == options[i] <> ':':
return options[i+1:i+2] = ':' return options[i+1:i+2] == ':'
raise error, 'option -' + opt + ' not recognized' raise error, 'option -' + opt + ' not recognized'

View file

@ -7,7 +7,7 @@ import fnmatch
def glob(pathname): def glob(pathname):
if not has_magic(pathname): return [pathname] if not has_magic(pathname): return [pathname]
dirname, basename = path.split(pathname) dirname, basename = path.split(pathname)
if dirname[-1:] = '/' and dirname <> '/': if dirname[-1:] == '/' and dirname <> '/':
dirname = dirname[:-1] dirname = dirname[:-1]
if has_magic(dirname): if has_magic(dirname):
list = glob(dirname) list = glob(dirname)
@ -34,9 +34,10 @@ def glob1(dirname, pattern):
names = posix.listdir(dirname) names = posix.listdir(dirname)
except posix.error: except posix.error:
return [] return []
names.sort()
result = [] result = []
for name in names: for name in names:
if name[0] <> '.' or pattern[0] = '.': if name[0] <> '.' or pattern[0] == '.':
if fnmatch.fnmatch(name, pattern): result.append(name) if fnmatch.fnmatch(name, pattern): result.append(name)
return result return result

View file

@ -30,7 +30,7 @@ def ggrep(syntax, pat, filename):
prefix = string.rjust(`lineno`, 3) + ': ' prefix = string.rjust(`lineno`, 3) + ': '
print prefix + line print prefix + line
if 0: # XXX if 0: # XXX
start, end = prog.regs()[0] start, end = prog.regs[0]
line = line[:start] line = line[:start]
if '\t' not in line: if '\t' not in line:
prefix = ' ' * (len(prefix) + start) prefix = ' ' * (len(prefix) + start)

View file

@ -69,7 +69,7 @@ def stretch(s, a, b):
ib = ib+b ib = ib+b
if i >= m: if i >= m:
break break
if ib = ja: if ib == ja:
out.append(y[i]) out.append(y[i])
else: else:
out.append((y[i]*(ja-(ib-b)) + y[i-1]*(ib-ja)) / b) out.append((y[i]*(ja-(ib-b)) + y[i-1]*(ib-ja)) / b)

View file

@ -49,7 +49,7 @@ def parse_forms(filename):
def _open_formfile(filename): def _open_formfile(filename):
if filename[-3:] <> '.fd': if filename[-3:] <> '.fd':
filename = filename + '.fd' filename = filename + '.fd'
if filename[0] = '/': if filename[0] == '/':
try: try:
fp = open(filename,'r') fp = open(filename,'r')
except IOError: except IOError:
@ -62,7 +62,7 @@ def _open_formfile(filename):
break break
except IOError: except IOError:
fp = None fp = None
if fp = None: if fp == None:
raise error, 'Cannot find forms file ' + filename raise error, 'Cannot find forms file ' + filename
return fp return fp
@ -77,7 +77,7 @@ def _parse_fd_header(file):
# Now skip until we know number of forms # Now skip until we know number of forms
while 1: while 1:
datum = _parse_1_line(file) datum = _parse_1_line(file)
if type(datum) = type(()) and datum[0] = 'Numberofforms': if type(datum) == type(()) and datum[0] == 'Numberofforms':
break break
return datum[1] return datum[1]
# #
@ -89,7 +89,7 @@ def _parse_fd_form(file, name):
if datum <> FORMLINE: if datum <> FORMLINE:
raise error, 'Missing === FORM === line' raise error, 'Missing === FORM === line'
form = _parse_object(file) form = _parse_object(file)
if form.Name = name or name = None: if form.Name == name or name == None:
objs = [] objs = []
for j in range(form.Numberofobjects): for j in range(form.Numberofobjects):
obj = _parse_object(file) obj = _parse_object(file)
@ -147,7 +147,7 @@ def _parse_line(line):
if not a: if not a:
return line return line
name = line[:a[1][1]] name = line[:a[1][1]]
if name[0] = 'N': if name[0] == 'N':
name = string.joinfields(string.split(name),'') name = string.joinfields(string.split(name),'')
name = string.lower(name) name = string.lower(name)
name = string.upper(name[0]) + name[1:] name = string.upper(name[0]) + name[1:]
@ -167,7 +167,7 @@ def _readline(file):
def _parse_1_line(file): def _parse_1_line(file):
line = _readline(file) line = _readline(file)
while line = '': while line == '':
line = _readline(file) line = _readline(file)
return _parse_line(line) return _parse_line(line)
@ -176,7 +176,7 @@ def _skip_object(file):
while not line in (SPLITLINE, FORMLINE, ENDLINE): while not line in (SPLITLINE, FORMLINE, ENDLINE):
pos = file.tell() pos = file.tell()
line = _readline(file) line = _readline(file)
if line = FORMLINE: if line == FORMLINE:
file.seek(pos) file.seek(pos)
def _parse_object(file): def _parse_object(file):
@ -185,7 +185,7 @@ def _parse_object(file):
pos = file.tell() pos = file.tell()
datum = _parse_1_line(file) datum = _parse_1_line(file)
if datum in (SPLITLINE, FORMLINE, ENDLINE): if datum in (SPLITLINE, FORMLINE, ENDLINE):
if datum = FORMLINE: if datum == FORMLINE:
file.seek(pos) file.seek(pos)
return obj return obj
if type(datum) <> type(()): if type(datum) <> type(()):
@ -266,27 +266,27 @@ def _create_object(form, odata):
# Internal crfunc: helper function that returns correct create function # Internal crfunc: helper function that returns correct create function
# #
def _select_crfunc(fm, cl): def _select_crfunc(fm, cl):
if cl = FL.BEGIN_GROUP: return fm.bgn_group if cl == FL.BEGIN_GROUP: return fm.bgn_group
elif cl = FL.END_GROUP: return fm.end_group elif cl == FL.END_GROUP: return fm.end_group
elif cl = FL.BITMAP: return fm.add_bitmap elif cl == FL.BITMAP: return fm.add_bitmap
elif cl = FL.BOX: return fm.add_box elif cl == FL.BOX: return fm.add_box
elif cl = FL.BROWSER: return fm.add_browser elif cl == FL.BROWSER: return fm.add_browser
elif cl = FL.BUTTON: return fm.add_button elif cl == FL.BUTTON: return fm.add_button
elif cl = FL.CHART: return fm.add_chart elif cl == FL.CHART: return fm.add_chart
elif cl = FL.CHOICE: return fm.add_choice elif cl == FL.CHOICE: return fm.add_choice
elif cl = FL.CLOCK: return fm.add_clock elif cl == FL.CLOCK: return fm.add_clock
elif cl = FL.COUNTER: return fm.add_counter elif cl == FL.COUNTER: return fm.add_counter
elif cl = FL.DIAL: return fm.add_dial elif cl == FL.DIAL: return fm.add_dial
elif cl = FL.FREE: return fm.add_free elif cl == FL.FREE: return fm.add_free
elif cl = FL.INPUT: return fm.add_input elif cl == FL.INPUT: return fm.add_input
elif cl = FL.LIGHTBUTTON: return fm.add_lightbutton elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton
elif cl = FL.MENU: return fm.add_menu elif cl == FL.MENU: return fm.add_menu
elif cl = FL.POSITIONER: return fm.add_positioner elif cl == FL.POSITIONER: return fm.add_positioner
elif cl = FL.ROUNDBUTTON: return fm.add_roundbutton elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton
elif cl = FL.SLIDER: return fm.add_slider elif cl == FL.SLIDER: return fm.add_slider
elif cl = FL.VALSLIDER: return fm.add_valslider elif cl == FL.VALSLIDER: return fm.add_valslider
elif cl = FL.TEXT: return fm.add_text elif cl == FL.TEXT: return fm.add_text
elif cl = FL.TIMER: return fm.add_timer elif cl == FL.TIMER: return fm.add_timer
else: else:
raise error, 'Unknown object type: ' + `cl` raise error, 'Unknown object type: ' + `cl`

View file

@ -17,7 +17,7 @@ debug = 0
# Test if an object is a list. # Test if an object is a list.
# #
def is_list(x): def is_list(x):
return type(x) = type([]) return type(x) == type([])
# Reverse a list. # Reverse a list.
@ -34,7 +34,7 @@ def reverse(list):
# #
def getattrlist(list, name): def getattrlist(list, name):
for item in list: for item in list:
if item and is_list(item) and item[0] = name: if item and is_list(item) and item[0] == name:
return item[1:] return item[1:]
return [] return []
@ -43,8 +43,8 @@ def getattrlist(list, name):
# #
def getproplist(list, name): def getproplist(list, name):
for item in list: for item in list:
if item and is_list(item) and item[0] = 'prop': if item and is_list(item) and item[0] == 'prop':
if len(item) > 1 and item[1] = name: if len(item) > 1 and item[1] == name:
return item[2:] return item[2:]
return [] return []
@ -53,7 +53,7 @@ def getproplist(list, name):
# #
def is_endgroup(list): def is_endgroup(list):
x = getproplist(list, 'end-of-group') x = getproplist(list, 'end-of-group')
return (x and x[0] = '#t') return (x and x[0] == '#t')
# Neatly display an actuator definition given as S-expression # Neatly display an actuator definition given as S-expression
@ -63,13 +63,13 @@ def show_actuator(prefix, a):
for item in a: for item in a:
if not is_list(item): if not is_list(item):
print prefix, item print prefix, item
elif item and item[0] = 'al': elif item and item[0] == 'al':
print prefix, 'Subactuator list:' print prefix, 'Subactuator list:'
for a in item[1:]: for a in item[1:]:
show_actuator(prefix + ' ', a) show_actuator(prefix + ' ', a)
elif len(item) = 2: elif len(item) == 2:
print prefix, item[0], '=>', item[1] print prefix, item[0], '=>', item[1]
elif len(item) = 3 and item[0] = 'prop': elif len(item) == 3 and item[0] == 'prop':
print prefix, 'Prop', item[1], '=>', print prefix, 'Prop', item[1], '=>',
print item[2] print item[2]
else: else:
@ -82,13 +82,13 @@ def show_panel(prefix, p):
for item in p: for item in p:
if not is_list(item): if not is_list(item):
print prefix, item print prefix, item
elif item and item[0] = 'al': elif item and item[0] == 'al':
print prefix, 'Actuator list:' print prefix, 'Actuator list:'
for a in item[1:]: for a in item[1:]:
show_actuator(prefix + ' ', a) show_actuator(prefix + ' ', a)
elif len(item) = 2: elif len(item) == 2:
print prefix, item[0], '=>', item[1] print prefix, item[0], '=>', item[1]
elif len(item) = 3 and item[0] = 'prop': elif len(item) == 3 and item[0] == 'prop':
print prefix, 'Prop', item[1], '=>', print prefix, 'Prop', item[1], '=>',
print item[2] print item[2]
else: else:
@ -112,14 +112,14 @@ def dummy_callback(arg):
# #
def assign_members(target, attrlist, exclist, prefix): def assign_members(target, attrlist, exclist, prefix):
for item in attrlist: for item in attrlist:
if is_list(item) and len(item) = 2 and item[0] not in exclist: if is_list(item) and len(item) == 2 and item[0] not in exclist:
name, value = item[0], item[1] name, value = item[0], item[1]
ok = 1 ok = 1
if value[0] in '-0123456789': if value[0] in '-0123456789':
value = eval(value) value = eval(value)
elif value[0] = '"': elif value[0] == '"':
value = value[1:-1] value = value[1:-1]
elif value = 'move-then-resize': elif value == 'move-then-resize':
# Strange default set by Panel Editor... # Strange default set by Panel Editor...
ok = 0 ok = 0
else: else:
@ -148,7 +148,7 @@ def build_actuator(descr):
else: else:
actuatorname = '' actuatorname = ''
type = descr[0] type = descr[0]
if type[:4] = 'pnl_': type = type[4:] if type[:4] == 'pnl_': type = type[4:]
act = pnl.mkact(type) act = pnl.mkact(type)
act.downfunc = act.activefunc = act.upfunc = dummy_callback act.downfunc = act.activefunc = act.upfunc = dummy_callback
# #
@ -158,9 +158,9 @@ def build_actuator(descr):
# #
datalist = getattrlist(descr, 'data') datalist = getattrlist(descr, 'data')
prefix = '' prefix = ''
if type[-4:] = 'puck': if type[-4:] == 'puck':
prefix = 'puck_' prefix = 'puck_'
elif type = 'mouse': elif type == 'mouse':
prefix = 'mouse_' prefix = 'mouse_'
assign_members(act, datalist, [], prefix) assign_members(act, datalist, [], prefix)
# #

View file

@ -20,16 +20,16 @@ def tokenize_string(s):
c = s[:1] c = s[:1]
if c in whitespace: if c in whitespace:
s = s[1:] s = s[1:]
elif c = ';': elif c == ';':
s = '' s = ''
elif c = '"': elif c == '"':
n = len(s) n = len(s)
i = 1 i = 1
while i < n: while i < n:
c = s[i] c = s[i]
i = i+1 i = i+1
if c = '"': break if c == '"': break
if c = '\\': i = i+1 if c == '\\': i = i+1
tokens.append(s[:i]) tokens.append(s[:i])
s = s[i:] s = s[i:]
elif c in operators: elif c in operators:
@ -78,9 +78,9 @@ def parse_expr(tokens):
while 1: while 1:
if not tokens: if not tokens:
raise syntax_error, 'missing ")"' raise syntax_error, 'missing ")"'
if tokens[0] = ')': if tokens[0] == ')':
return expr, tokens[1:] return expr, tokens[1:]
elif tokens[0] = '(': elif tokens[0] == '(':
subexpr, tokens = parse_expr(tokens) subexpr, tokens = parse_expr(tokens)
expr.append(subexpr) expr.append(subexpr)
else: else:

View file

@ -31,7 +31,7 @@ def dumpsymtab(dict):
def dumpvar(name, x): def dumpvar(name, x):
import sys import sys
t = type(x) t = type(x)
if t = type({}): if t == type({}):
print name, '= {}' print name, '= {}'
for key in x.keys(): for key in x.keys():
item = x[key] item = x[key]
@ -42,7 +42,7 @@ def dumpvar(name, x):
if not printable(x): if not printable(x):
print '#', print '#',
print name, '=', `x` print name, '=', `x`
elif t = type(sys): elif t == type(sys):
print 'import', name, '#', x print 'import', name, '#', x
else: else:
print '#', name, '=', x print '#', name, '=', x
@ -58,6 +58,6 @@ def printable(x):
if not printable(item): if not printable(item):
return 0 return 0
return 1 return 1
if x = {}: if x == {}:
return 1 return 1
return 0 return 0

View file

@ -30,7 +30,7 @@ def ggrep(syntax, pat, filename):
prefix = string.rjust(`lineno`, 3) + ': ' prefix = string.rjust(`lineno`, 3) + ': '
print prefix + line print prefix + line
if 0: # XXX if 0: # XXX
start, end = prog.regs()[0] start, end = prog.regs[0]
line = line[:start] line = line[:start]
if '\t' not in line: if '\t' not in line:
prefix = ' ' * (len(prefix) + start) prefix = ' ' * (len(prefix) + start)

View file

@ -53,7 +53,7 @@ def listattrs(x):
return total return total
i = 0 i = 0
while i+1 < len(total): while i+1 < len(total):
if total[i] = total[i+1]: if total[i] == total[i+1]:
del total[i+1] del total[i+1]
else: else:
i = i+1 i = i+1
@ -62,7 +62,7 @@ def listattrs(x):
# Helper to recognize functions # Helper to recognize functions
# #
def is_function(x): def is_function(x):
return type(x) = type(is_function) return type(x) == type(is_function)
# Approximation of builtin dir(); this lists the user's # Approximation of builtin dir(); this lists the user's
# variables by default, not the current local name space. # variables by default, not the current local name space.
@ -71,7 +71,7 @@ def is_function(x):
# #
class _dirclass: class _dirclass:
def dir(args): def dir(args):
if type(args) = type(()): if type(args) == type(()):
return listattrs(args[1]) return listattrs(args[1])
else: else:
import __main__ import __main__

View file

@ -40,19 +40,19 @@ def browser(tb):
break break
cmd = string.strip(line) cmd = string.strip(line)
if cmd: if cmd:
if cmd = 'quit': if cmd == 'quit':
break break
elif cmd = 'list': elif cmd == 'list':
browserlist(tb) browserlist(tb)
elif cmd = 'up': elif cmd == 'up':
if ptr-1 >= 0: ptr = ptr-1 if ptr-1 >= 0: ptr = ptr-1
else: print 'Bottom of stack.' else: print 'Bottom of stack.'
elif cmd = 'down': elif cmd == 'down':
if ptr+1 < len(tblist): ptr = ptr+1 if ptr+1 < len(tblist): ptr = ptr+1
else: print 'Top of stack.' else: print 'Top of stack.'
elif cmd = 'locals': elif cmd == 'locals':
printsymbols(tb.tb_frame.f_locals) printsymbols(tb.tb_frame.f_locals)
elif cmd = 'globals': elif cmd == 'globals':
printsymbols(tb.tb_frame.f_globals) printsymbols(tb.tb_frame.f_globals)
elif cmd in ('?', 'help'): elif cmd in ('?', 'help'):
browserhelp() browserhelp()
@ -65,10 +65,10 @@ def browserlist(tb):
last = lineno last = lineno
first = max(1, last-10) first = max(1, last-10)
for i in range(first, last+1): for i in range(first, last+1):
if i = lineno: prefix = '***' + string.rjust(`i`, 4) + ':' if i == lineno: prefix = '***' + string.rjust(`i`, 4) + ':'
else: prefix = string.rjust(`i`, 7) + ':' else: prefix = string.rjust(`i`, 7) + ':'
line = readfileline(filename, i) line = readfileline(filename, i)
if line[-1:] = '\n': line = line[:-1] if line[-1:] == '\n': line = line[:-1]
print prefix + line print prefix + line
def browserexec(tb, cmd): def browserexec(tb, cmd):
@ -126,24 +126,24 @@ def printsymbols(d):
print print
def printobject(v, maxlevel): def printobject(v, maxlevel):
if v = None: if v == None:
print 'None', print 'None',
elif type(v) in (type(0), type(0.0)): elif type(v) in (type(0), type(0.0)):
print v, print v,
elif type(v) = type(''): elif type(v) == type(''):
if len(v) > 20: if len(v) > 20:
print `v[:17] + '...'`, print `v[:17] + '...'`,
else: else:
print `v`, print `v`,
elif type(v) = type(()): elif type(v) == type(()):
print '(', print '(',
printlist(v, maxlevel) printlist(v, maxlevel)
print ')', print ')',
elif type(v) = type([]): elif type(v) == type([]):
print '[', print '[',
printlist(v, maxlevel) printlist(v, maxlevel)
print ']', print ']',
elif type(v) = type({}): elif type(v) == type({}):
print '{', print '{',
printdict(v, maxlevel) printdict(v, maxlevel)
print '}', print '}',
@ -152,7 +152,7 @@ def printobject(v, maxlevel):
def printlist(v, maxlevel): def printlist(v, maxlevel):
n = len(v) n = len(v)
if n = 0: return if n == 0: return
if maxlevel <= 0: if maxlevel <= 0:
print '...', print '...',
return return
@ -164,7 +164,7 @@ def printlist(v, maxlevel):
def printdict(v, maxlevel): def printdict(v, maxlevel):
keys = v.keys() keys = v.keys()
n = len(keys) n = len(keys)
if n = 0: return if n == 0: return
if maxlevel <= 0: if maxlevel <= 0:
print '...', print '...',
return return
@ -187,8 +187,8 @@ def readfileline(filename, lineno):
cache_ok = 0 cache_ok = 0
if _filecache.has_key(filename): if _filecache.has_key(filename):
cached_stat, lines = _filecache[filename] cached_stat, lines = _filecache[filename]
if stat[ST_SIZE] = cached_stat[ST_SIZE] and \ if stat[ST_SIZE] == cached_stat[ST_SIZE] and \
stat[ST_MTIME] = cached_stat[ST_MTIME]: stat[ST_MTIME] == cached_stat[ST_MTIME]:
cache_ok = 1 cache_ok = 1
else: else:
print 'Stale cache entry for', filename print 'Stale cache entry for', filename

View file

@ -110,7 +110,7 @@ class LabelAppearance:
# #
def draw(self, (d, area)): def draw(self, (d, area)):
area = _rect.intersect(area, self.bounds) area = _rect.intersect(area, self.bounds)
if area = _rect.empty: if area == _rect.empty:
return return
d.cliprect(area) d.cliprect(area)
self.drawit(d) self.drawit(d)

View file

@ -43,7 +43,7 @@ class CSplit(Split):
# XXX One day Python will have automatic conversions... # XXX One day Python will have automatic conversions...
n = len(self.children) n = len(self.children)
fn = float(n) fn = float(n)
if n = 0: return if n == 0: return
(left, top), (right, bottom) = bounds (left, top), (right, bottom) = bounds
width, height = right-left, bottom-top width, height = right-left, bottom-top
child_width, child_height = width*3/(n+4), height*3/(n+4) child_width, child_height = width*3/(n+4), height*3/(n+4)

View file

@ -25,7 +25,7 @@ class DirList(VSplit):
if path.isdir(path.join(dirname, name)): if path.isdir(path.join(dirname, name)):
fullname = path.join(dirname, name) fullname = path.join(dirname, name)
btn = SubdirButton().definetext(self, fullname) btn = SubdirButton().definetext(self, fullname)
elif name[-3:] = '.py': elif name[-3:] == '.py':
btn = ModuleButton().definetext(self, name) btn = ModuleButton().definetext(self, name)
else: else:
btn = FileButton().definetext(self, name) btn = FileButton().definetext(self, name)

View file

@ -116,7 +116,7 @@ class Split:
if not self.keybd_focus: if not self.keybd_focus:
self.set_keybd_focus(self.keybd_interest[0]) self.set_keybd_focus(self.keybd_interest[0])
type, detail = type_detail type, detail = type_detail
if type = WE_COMMAND and detail = WC_TAB and \ if type == WE_COMMAND and detail == WC_TAB and \
len(self.keybd_interest) > 1: len(self.keybd_interest) > 1:
self.next_keybd_focus() self.next_keybd_focus()
return return
@ -144,9 +144,9 @@ class Split:
self.timer_interest.remove(child) self.timer_interest.remove(child)
if child in self.altdraw_interest: if child in self.altdraw_interest:
self.altdraw_interest.remove(child) self.altdraw_interest.remove(child)
if child = self.mouse_focus: if child == self.mouse_focus:
self.mouse_focus = None self.mouse_focus = None
if child = self.keybd_focus: if child == self.keybd_focus:
self.keybd_focus = None self.keybd_focus = None
# #
def need_mouse(self, child): def need_mouse(self, child):
@ -154,7 +154,7 @@ class Split:
self.mouse_interest.append(child) self.mouse_interest.append(child)
self.parent.need_mouse(self) self.parent.need_mouse(self)
def no_mouse(self, child): def no_mouse(self, child):
if child = self.mouse_focus: if child == self.mouse_focus:
self.mouse_focus = None self.mouse_focus = None
if child in self.mouse_interest: if child in self.mouse_interest:
self.mouse_interest.remove(child) self.mouse_interest.remove(child)
@ -168,7 +168,7 @@ class Split:
if not self.keybd_focus: if not self.keybd_focus:
self.set_keybd_focus(child) self.set_keybd_focus(child)
def no_keybd(self, child): def no_keybd(self, child):
if child = self.keybd_focus: if child == self.keybd_focus:
self.keybd_focus = None # Don't call child.deactivate() self.keybd_focus = None # Don't call child.deactivate()
if child in self.keybd_interest: if child in self.keybd_interest:
self.keybd_interest.remove(child) self.keybd_interest.remove(child)

View file

@ -51,7 +51,7 @@ class StripChart(LabelAppearance, NoReactivity):
# #
def draw(self, (d, area)): def draw(self, (d, area)):
area = rect.intersect(area, self.bounds) area = rect.intersect(area, self.bounds)
if area = rect.empty: if area == rect.empty:
return return
d.cliprect(area) d.cliprect(area)
d.erase(self.bounds) d.erase(self.bounds)

View file

@ -149,26 +149,26 @@ class WindowParent(ManageOneChild):
# Only call dispatch once we are realized # Only call dispatch once we are realized
# #
def dispatch(self, (type, win, detail)): def dispatch(self, (type, win, detail)):
if type = WE_DRAW: if type == WE_DRAW:
d = self.win.begindrawing() d = self.win.begindrawing()
self.child.draw(d, detail) self.child.draw(d, detail)
del d del d
if self.do_altdraw: self.child.altdraw(detail) if self.do_altdraw: self.child.altdraw(detail)
elif type = WE_MOUSE_DOWN: elif type == WE_MOUSE_DOWN:
if self.do_mouse: self.child.mouse_down(detail) if self.do_mouse: self.child.mouse_down(detail)
elif type = WE_MOUSE_MOVE: elif type == WE_MOUSE_MOVE:
if self.do_mouse: self.child.mouse_move(detail) if self.do_mouse: self.child.mouse_move(detail)
elif type = WE_MOUSE_UP: elif type == WE_MOUSE_UP:
if self.do_mouse: self.child.mouse_up(detail) if self.do_mouse: self.child.mouse_up(detail)
elif type in (WE_CHAR, WE_COMMAND): elif type in (WE_CHAR, WE_COMMAND):
if self.do_keybd: self.child.keybd(type, detail) if self.do_keybd: self.child.keybd(type, detail)
elif type = WE_TIMER: elif type == WE_TIMER:
if self.do_timer: self.child.timer() if self.do_timer: self.child.timer()
elif type = WE_SIZE: elif type == WE_SIZE:
self.fixup() self.fixup()
elif type = WE_CLOSE: elif type == WE_CLOSE:
self.close_trigger() self.close_trigger()
elif type = WE_MENU: elif type == WE_MENU:
self.menu_trigger(detail) self.menu_trigger(detail)
if self.pending_destroy: if self.pending_destroy:
self.destroy() self.destroy()

View file

@ -21,7 +21,7 @@ def delayfunc(msecs):
# #
# Use millisleep for very short delays or if there are no windows # Use millisleep for very short delays or if there are no windows
# #
if msecs < 100 or mainloop.countwindows() = 0: if msecs < 100 or mainloop.countwindows() == 0:
if msecs > 0: if msecs > 0:
time.millisleep(msecs) time.millisleep(msecs)
return return
@ -46,7 +46,7 @@ cancel = q.cancel
# Emptiness check must check both queues # Emptiness check must check both queues
# #
def empty(): def empty():
return q.empty() and mainloop.countwindows() = 0 return q.empty() and mainloop.countwindows() == 0
# Run until there is nothing left to do # Run until there is nothing left to do
# #

View file

@ -10,7 +10,7 @@ import dircache
def action(w, string, i, detail): def action(w, string, i, detail):
(h, v), clicks, button, mask = detail (h, v), clicks, button, mask = detail
if clicks = 2: if clicks == 2:
name = path.join(w.name, string) name = path.join(w.name, string)
try: try:
w2 = anywin.open(name) w2 = anywin.open(name)

View file

@ -175,20 +175,20 @@ def test():
winsize = w.getwinsize() winsize = w.getwinsize()
while 1: while 1:
type, window, detail = stdwinq.getevent() type, window, detail = stdwinq.getevent()
if type = WE_CLOSE: if type == WE_CLOSE:
break break
elif type = WE_SIZE: elif type == WE_SIZE:
newsize = w.getwinsize() newsize = w.getwinsize()
if newsize <> winsize: if newsize <> winsize:
w.change((0,0), winsize) w.change((0,0), winsize)
winsize = newsize winsize = newsize
w.change((0,0), winsize) w.change((0,0), winsize)
elif type = WE_MOUSE_DOWN: elif type == WE_MOUSE_DOWN:
stage = (stage + 1) % len(stages) stage = (stage + 1) % len(stages)
justify, center, title = stages[stage] justify, center, title = stages[stage]
w.settitle(title) w.settitle(title)
w.change((0, 0), (1000, 1000)) w.change((0, 0), (1000, 1000))
elif type = WE_DRAW: elif type == WE_DRAW:
width, height = winsize width, height = winsize
f = formatter().init(w.begindrawing(), 0, 0, width) f = formatter().init(w.begindrawing(), 0, 0, width)
f.center = center f.center = center
@ -198,7 +198,7 @@ def test():
for font in font1, font2, font1: for font in font1, font2, font1:
f.setfont(font) f.setfont(font)
for word in words: for word in words:
space = 1 + (word[-1:] = '.') space = 1 + (word[-1:] == '.')
f.addword(word, space) f.addword(word, space)
if center and space > 1: if center and space > 1:
f.flush() f.flush()

View file

@ -49,44 +49,44 @@ def mainloop(): # Handle events until no windows left
def treatevent(e): # Handle a stdwin event def treatevent(e): # Handle a stdwin event
type, w, detail = e type, w, detail = e
if type = WE_DRAW: if type == WE_DRAW:
w.draw(w, detail) w.draw(w, detail)
elif type = WE_MENU: elif type == WE_MENU:
m, item = detail m, item = detail
m.action[item](w, m, item) m.action[item](w, m, item)
elif type = WE_COMMAND: elif type == WE_COMMAND:
treatcommand(w, detail) treatcommand(w, detail)
elif type = WE_CHAR: elif type == WE_CHAR:
w.char(w, detail) w.char(w, detail)
elif type = WE_MOUSE_DOWN: elif type == WE_MOUSE_DOWN:
if detail[1] > 1: w.m2down(w, detail) if detail[1] > 1: w.m2down(w, detail)
else: w.mdown(w, detail) else: w.mdown(w, detail)
elif type = WE_MOUSE_MOVE: elif type == WE_MOUSE_MOVE:
w.mmove(w, detail) w.mmove(w, detail)
elif type = WE_MOUSE_UP: elif type == WE_MOUSE_UP:
if detail[1] > 1: w.m2up(w, detail) if detail[1] > 1: w.m2up(w, detail)
else: w.mup(w, detail) else: w.mup(w, detail)
elif type = WE_SIZE: elif type == WE_SIZE:
w.size(w, w.getwinsize()) w.size(w, w.getwinsize())
elif type = WE_ACTIVATE: elif type == WE_ACTIVATE:
w.activate(w) w.activate(w)
elif type = WE_DEACTIVATE: elif type == WE_DEACTIVATE:
w.deactivate(w) w.deactivate(w)
elif type = WE_MOVE: elif type == WE_MOVE:
w.move(w) w.move(w)
elif type = WE_TIMER: elif type == WE_TIMER:
w.timer(w) w.timer(w)
elif type = WE_CLOSE: elif type == WE_CLOSE:
w.close(w) w.close(w)
def treatcommand(w, type): # Handle a we_command event def treatcommand(w, type): # Handle a we_command event
if type = WC_CLOSE: if type == WC_CLOSE:
w.close(w) w.close(w)
elif type = WC_RETURN: elif type == WC_RETURN:
w.enter(w) w.enter(w)
elif type = WC_TAB: elif type == WC_TAB:
w.tab(w) w.tab(w)
elif type = WC_BACKSPACE: elif type == WC_BACKSPACE:
w.backspace(w) w.backspace(w)
elif type in (WC_LEFT, WC_UP, WC_RIGHT, WC_DOWN): elif type in (WC_LEFT, WC_UP, WC_RIGHT, WC_DOWN):
w.arrow(w, type) w.arrow(w, type)
@ -101,13 +101,13 @@ def close(w): # Close method
break break
def arrow(w, detail): # Arrow key method def arrow(w, detail): # Arrow key method
if detail = WC_LEFT: if detail == WC_LEFT:
w.kleft(w) w.kleft(w)
elif detail = WC_UP: elif detail == WC_UP:
w.kup(w) w.kup(w)
elif detail = WC_RIGHT: elif detail == WC_RIGHT:
w.kright(w) w.kright(w)
elif detail = WC_DOWN: elif detail == WC_DOWN:
w.kdown(w) w.kdown(w)

View file

@ -164,13 +164,13 @@ def whichcol(w, h): # Return column number (may be >= len(w.data))
return len(w.data) return len(w.data)
def arrow(w, type): def arrow(w, type):
if type = WC_LEFT: if type == WC_LEFT:
incr = -1, 0 incr = -1, 0
elif type = WC_UP: elif type == WC_UP:
incr = 0, -1 incr = 0, -1
elif type = WC_RIGHT: elif type == WC_RIGHT:
incr = 1, 0 incr = 1, 0
elif type = WC_DOWN: elif type == WC_DOWN:
incr = 0, 1 incr = 0, 1
else: else:
return return

View file

@ -21,7 +21,7 @@ def isabs(s):
def join(s, t): def join(s, t):
if (not s) or isabs(t): return t if (not s) or isabs(t): return t
if t[:1] = ':': t = t[1:] if t[:1] == ':': t = t[1:]
if ':' not in s: if ':' not in s:
s = ':' + s s = ':' + s
if s[-1:] <> ':': if s[-1:] <> ':':
@ -40,7 +40,7 @@ def split(s):
if ':' not in s: return '', s if ':' not in s: return '', s
colon = 0 colon = 0
for i in range(len(s)): for i in range(len(s)):
if s[i] = ':': colon = i+1 if s[i] == ':': colon = i+1
return s[:colon], s[colon:] return s[:colon], s[colon:]

View file

@ -53,7 +53,7 @@ def listattrs(x):
return total return total
i = 0 i = 0
while i+1 < len(total): while i+1 < len(total):
if total[i] = total[i+1]: if total[i] == total[i+1]:
del total[i+1] del total[i+1]
else: else:
i = i+1 i = i+1
@ -62,7 +62,7 @@ def listattrs(x):
# Helper to recognize functions # Helper to recognize functions
# #
def is_function(x): def is_function(x):
return type(x) = type(is_function) return type(x) == type(is_function)
# Approximation of builtin dir(); this lists the user's # Approximation of builtin dir(); this lists the user's
# variables by default, not the current local name space. # variables by default, not the current local name space.
@ -71,7 +71,7 @@ def is_function(x):
# #
class _dirclass: class _dirclass:
def dir(args): def dir(args):
if type(args) = type(()): if type(args) == type(()):
return listattrs(args[1]) return listattrs(args[1])
else: else:
import __main__ import __main__

View file

@ -160,23 +160,23 @@ def dumptype(x, typedict, types, stack):
typedict[xrepr] = uid typedict[xrepr] = uid
if typeswitch.has_key(xrepr): if typeswitch.has_key(xrepr):
print FN, '[', `uid`, '] =', typeswitch[xrepr] print FN, '[', `uid`, '] =', typeswitch[xrepr]
elif x = type(sys): elif x == type(sys):
print 'import sys' print 'import sys'
print FN, '[', `uid`, '] = type(sys)' print FN, '[', `uid`, '] = type(sys)'
elif x = type(sys.stderr): elif x == type(sys.stderr):
print 'import sys' print 'import sys'
print FN, '[', `uid`, '] = type(sys.stderr)' print FN, '[', `uid`, '] = type(sys.stderr)'
elif x = type(dumptype): elif x == type(dumptype):
print 'def some_function(): pass' print 'def some_function(): pass'
print FN, '[', `uid`, '] = type(some_function)' print FN, '[', `uid`, '] = type(some_function)'
elif x = type(some_class): elif x == type(some_class):
print 'class some_class(): pass' print 'class some_class(): pass'
print FN, '[', `uid`, '] = type(some_class)' print FN, '[', `uid`, '] = type(some_class)'
elif x = type(some_instance): elif x == type(some_instance):
print 'class another_class(): pass' print 'class another_class(): pass'
print 'some_instance = another_class()' print 'some_instance = another_class()'
print FN, '[', `uid`, '] = type(some_instance)' print FN, '[', `uid`, '] = type(some_instance)'
elif x = type(some_instance.method): elif x == type(some_instance.method):
print 'class yet_another_class():' print 'class yet_another_class():'
print ' def method(): pass' print ' def method(): pass'
print 'another_instance = yet_another_class()' print 'another_instance = yet_another_class()'

View file

@ -49,7 +49,7 @@ def parse_forms(filename):
def _open_formfile(filename): def _open_formfile(filename):
if filename[-3:] <> '.fd': if filename[-3:] <> '.fd':
filename = filename + '.fd' filename = filename + '.fd'
if filename[0] = '/': if filename[0] == '/':
try: try:
fp = open(filename,'r') fp = open(filename,'r')
except IOError: except IOError:
@ -62,7 +62,7 @@ def _open_formfile(filename):
break break
except IOError: except IOError:
fp = None fp = None
if fp = None: if fp == None:
raise error, 'Cannot find forms file ' + filename raise error, 'Cannot find forms file ' + filename
return fp return fp
@ -77,7 +77,7 @@ def _parse_fd_header(file):
# Now skip until we know number of forms # Now skip until we know number of forms
while 1: while 1:
datum = _parse_1_line(file) datum = _parse_1_line(file)
if type(datum) = type(()) and datum[0] = 'Numberofforms': if type(datum) == type(()) and datum[0] == 'Numberofforms':
break break
return datum[1] return datum[1]
# #
@ -89,7 +89,7 @@ def _parse_fd_form(file, name):
if datum <> FORMLINE: if datum <> FORMLINE:
raise error, 'Missing === FORM === line' raise error, 'Missing === FORM === line'
form = _parse_object(file) form = _parse_object(file)
if form.Name = name or name = None: if form.Name == name or name == None:
objs = [] objs = []
for j in range(form.Numberofobjects): for j in range(form.Numberofobjects):
obj = _parse_object(file) obj = _parse_object(file)
@ -147,7 +147,7 @@ def _parse_line(line):
if not a: if not a:
return line return line
name = line[:a[1][1]] name = line[:a[1][1]]
if name[0] = 'N': if name[0] == 'N':
name = string.joinfields(string.split(name),'') name = string.joinfields(string.split(name),'')
name = string.lower(name) name = string.lower(name)
name = string.upper(name[0]) + name[1:] name = string.upper(name[0]) + name[1:]
@ -167,7 +167,7 @@ def _readline(file):
def _parse_1_line(file): def _parse_1_line(file):
line = _readline(file) line = _readline(file)
while line = '': while line == '':
line = _readline(file) line = _readline(file)
return _parse_line(line) return _parse_line(line)
@ -176,7 +176,7 @@ def _skip_object(file):
while not line in (SPLITLINE, FORMLINE, ENDLINE): while not line in (SPLITLINE, FORMLINE, ENDLINE):
pos = file.tell() pos = file.tell()
line = _readline(file) line = _readline(file)
if line = FORMLINE: if line == FORMLINE:
file.seek(pos) file.seek(pos)
def _parse_object(file): def _parse_object(file):
@ -185,7 +185,7 @@ def _parse_object(file):
pos = file.tell() pos = file.tell()
datum = _parse_1_line(file) datum = _parse_1_line(file)
if datum in (SPLITLINE, FORMLINE, ENDLINE): if datum in (SPLITLINE, FORMLINE, ENDLINE):
if datum = FORMLINE: if datum == FORMLINE:
file.seek(pos) file.seek(pos)
return obj return obj
if type(datum) <> type(()): if type(datum) <> type(()):
@ -266,27 +266,27 @@ def _create_object(form, odata):
# Internal crfunc: helper function that returns correct create function # Internal crfunc: helper function that returns correct create function
# #
def _select_crfunc(fm, cl): def _select_crfunc(fm, cl):
if cl = FL.BEGIN_GROUP: return fm.bgn_group if cl == FL.BEGIN_GROUP: return fm.bgn_group
elif cl = FL.END_GROUP: return fm.end_group elif cl == FL.END_GROUP: return fm.end_group
elif cl = FL.BITMAP: return fm.add_bitmap elif cl == FL.BITMAP: return fm.add_bitmap
elif cl = FL.BOX: return fm.add_box elif cl == FL.BOX: return fm.add_box
elif cl = FL.BROWSER: return fm.add_browser elif cl == FL.BROWSER: return fm.add_browser
elif cl = FL.BUTTON: return fm.add_button elif cl == FL.BUTTON: return fm.add_button
elif cl = FL.CHART: return fm.add_chart elif cl == FL.CHART: return fm.add_chart
elif cl = FL.CHOICE: return fm.add_choice elif cl == FL.CHOICE: return fm.add_choice
elif cl = FL.CLOCK: return fm.add_clock elif cl == FL.CLOCK: return fm.add_clock
elif cl = FL.COUNTER: return fm.add_counter elif cl == FL.COUNTER: return fm.add_counter
elif cl = FL.DIAL: return fm.add_dial elif cl == FL.DIAL: return fm.add_dial
elif cl = FL.FREE: return fm.add_free elif cl == FL.FREE: return fm.add_free
elif cl = FL.INPUT: return fm.add_input elif cl == FL.INPUT: return fm.add_input
elif cl = FL.LIGHTBUTTON: return fm.add_lightbutton elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton
elif cl = FL.MENU: return fm.add_menu elif cl == FL.MENU: return fm.add_menu
elif cl = FL.POSITIONER: return fm.add_positioner elif cl == FL.POSITIONER: return fm.add_positioner
elif cl = FL.ROUNDBUTTON: return fm.add_roundbutton elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton
elif cl = FL.SLIDER: return fm.add_slider elif cl == FL.SLIDER: return fm.add_slider
elif cl = FL.VALSLIDER: return fm.add_valslider elif cl == FL.VALSLIDER: return fm.add_valslider
elif cl = FL.TEXT: return fm.add_text elif cl == FL.TEXT: return fm.add_text
elif cl = FL.TIMER: return fm.add_timer elif cl == FL.TIMER: return fm.add_timer
else: else:
raise error, 'Unknown object type: ' + `cl` raise error, 'Unknown object type: ' + `cl`

View file

@ -17,7 +17,7 @@ debug = 0
# Test if an object is a list. # Test if an object is a list.
# #
def is_list(x): def is_list(x):
return type(x) = type([]) return type(x) == type([])
# Reverse a list. # Reverse a list.
@ -34,7 +34,7 @@ def reverse(list):
# #
def getattrlist(list, name): def getattrlist(list, name):
for item in list: for item in list:
if item and is_list(item) and item[0] = name: if item and is_list(item) and item[0] == name:
return item[1:] return item[1:]
return [] return []
@ -43,8 +43,8 @@ def getattrlist(list, name):
# #
def getproplist(list, name): def getproplist(list, name):
for item in list: for item in list:
if item and is_list(item) and item[0] = 'prop': if item and is_list(item) and item[0] == 'prop':
if len(item) > 1 and item[1] = name: if len(item) > 1 and item[1] == name:
return item[2:] return item[2:]
return [] return []
@ -53,7 +53,7 @@ def getproplist(list, name):
# #
def is_endgroup(list): def is_endgroup(list):
x = getproplist(list, 'end-of-group') x = getproplist(list, 'end-of-group')
return (x and x[0] = '#t') return (x and x[0] == '#t')
# Neatly display an actuator definition given as S-expression # Neatly display an actuator definition given as S-expression
@ -63,13 +63,13 @@ def show_actuator(prefix, a):
for item in a: for item in a:
if not is_list(item): if not is_list(item):
print prefix, item print prefix, item
elif item and item[0] = 'al': elif item and item[0] == 'al':
print prefix, 'Subactuator list:' print prefix, 'Subactuator list:'
for a in item[1:]: for a in item[1:]:
show_actuator(prefix + ' ', a) show_actuator(prefix + ' ', a)
elif len(item) = 2: elif len(item) == 2:
print prefix, item[0], '=>', item[1] print prefix, item[0], '=>', item[1]
elif len(item) = 3 and item[0] = 'prop': elif len(item) == 3 and item[0] == 'prop':
print prefix, 'Prop', item[1], '=>', print prefix, 'Prop', item[1], '=>',
print item[2] print item[2]
else: else:
@ -82,13 +82,13 @@ def show_panel(prefix, p):
for item in p: for item in p:
if not is_list(item): if not is_list(item):
print prefix, item print prefix, item
elif item and item[0] = 'al': elif item and item[0] == 'al':
print prefix, 'Actuator list:' print prefix, 'Actuator list:'
for a in item[1:]: for a in item[1:]:
show_actuator(prefix + ' ', a) show_actuator(prefix + ' ', a)
elif len(item) = 2: elif len(item) == 2:
print prefix, item[0], '=>', item[1] print prefix, item[0], '=>', item[1]
elif len(item) = 3 and item[0] = 'prop': elif len(item) == 3 and item[0] == 'prop':
print prefix, 'Prop', item[1], '=>', print prefix, 'Prop', item[1], '=>',
print item[2] print item[2]
else: else:
@ -112,14 +112,14 @@ def dummy_callback(arg):
# #
def assign_members(target, attrlist, exclist, prefix): def assign_members(target, attrlist, exclist, prefix):
for item in attrlist: for item in attrlist:
if is_list(item) and len(item) = 2 and item[0] not in exclist: if is_list(item) and len(item) == 2 and item[0] not in exclist:
name, value = item[0], item[1] name, value = item[0], item[1]
ok = 1 ok = 1
if value[0] in '-0123456789': if value[0] in '-0123456789':
value = eval(value) value = eval(value)
elif value[0] = '"': elif value[0] == '"':
value = value[1:-1] value = value[1:-1]
elif value = 'move-then-resize': elif value == 'move-then-resize':
# Strange default set by Panel Editor... # Strange default set by Panel Editor...
ok = 0 ok = 0
else: else:
@ -148,7 +148,7 @@ def build_actuator(descr):
else: else:
actuatorname = '' actuatorname = ''
type = descr[0] type = descr[0]
if type[:4] = 'pnl_': type = type[4:] if type[:4] == 'pnl_': type = type[4:]
act = pnl.mkact(type) act = pnl.mkact(type)
act.downfunc = act.activefunc = act.upfunc = dummy_callback act.downfunc = act.activefunc = act.upfunc = dummy_callback
# #
@ -158,9 +158,9 @@ def build_actuator(descr):
# #
datalist = getattrlist(descr, 'data') datalist = getattrlist(descr, 'data')
prefix = '' prefix = ''
if type[-4:] = 'puck': if type[-4:] == 'puck':
prefix = 'puck_' prefix = 'puck_'
elif type = 'mouse': elif type == 'mouse':
prefix = 'mouse_' prefix = 'mouse_'
assign_members(act, datalist, [], prefix) assign_members(act, datalist, [], prefix)
# #

View file

@ -20,16 +20,16 @@ def tokenize_string(s):
c = s[:1] c = s[:1]
if c in whitespace: if c in whitespace:
s = s[1:] s = s[1:]
elif c = ';': elif c == ';':
s = '' s = ''
elif c = '"': elif c == '"':
n = len(s) n = len(s)
i = 1 i = 1
while i < n: while i < n:
c = s[i] c = s[i]
i = i+1 i = i+1
if c = '"': break if c == '"': break
if c = '\\': i = i+1 if c == '\\': i = i+1
tokens.append(s[:i]) tokens.append(s[:i])
s = s[i:] s = s[i:]
elif c in operators: elif c in operators:
@ -78,9 +78,9 @@ def parse_expr(tokens):
while 1: while 1:
if not tokens: if not tokens:
raise syntax_error, 'missing ")"' raise syntax_error, 'missing ")"'
if tokens[0] = ')': if tokens[0] == ')':
return expr, tokens[1:] return expr, tokens[1:]
elif tokens[0] = '(': elif tokens[0] == '(':
subexpr, tokens = parse_expr(tokens) subexpr, tokens = parse_expr(tokens)
expr.append(subexpr) expr.append(subexpr)
else: else:

View file

@ -39,9 +39,9 @@ def times(a, b):
return res return res
def power(a, n): # Raise polynomial a to the positive integral power n def power(a, n): # Raise polynomial a to the positive integral power n
if n = 0: return [1] if n == 0: return [1]
if n = 1: return a if n == 1: return a
if n/2*2 = n: if n/2*2 == n:
b = power(a, n/2) b = power(a, n/2)
return times(b, b) return times(b, b)
return times(power(a, n-1), a) return times(power(a, n-1), a)

View file

@ -10,8 +10,8 @@ import stat
# (begins with '/'). # (begins with '/').
# #
def join(a, b): def join(a, b):
if b[:1] = '/': return b if b[:1] == '/': return b
if a = '' or a[-1:] = '/': return a + b if a == '' or a[-1:] == '/': return a + b
# Note: join('x', '') returns 'x/'; is this what we want? # Note: join('x', '') returns 'x/'; is this what we want?
return a + '/' + b return a + '/' + b
@ -27,7 +27,7 @@ def split(p):
head, tail = '', '' head, tail = '', ''
for c in p: for c in p:
tail = tail + c tail = tail + c
if c = '/': if c == '/':
head, tail = head + tail, '' head, tail = head + tail, ''
return head, tail return head, tail
@ -40,9 +40,9 @@ def split(p):
def splitext(p): def splitext(p):
root, ext = '', '' root, ext = '', ''
for c in p: for c in p:
if c = '/': if c == '/':
root, ext = root + ext + c, '' root, ext = root + ext + c, ''
elif c = '.' or ext: elif c == '.' or ext:
ext = ext + c ext = ext + c
else: else:
root = root + c root = root + c
@ -64,7 +64,7 @@ def commonprefix(m):
for i in range(len(prefix)): for i in range(len(prefix)):
if prefix[:i+1] <> item[:i+1]: if prefix[:i+1] <> item[:i+1]:
prefix = prefix[:i] prefix = prefix[:i]
if i = 0: return '' if i == 0: return ''
break break
return prefix return prefix
@ -122,8 +122,8 @@ def sameopenfile(fp1, fp2):
# describing the same file? # describing the same file?
# #
def samestat(s1, s2): def samestat(s1, s2):
return s1[stat.ST_INO] = s2[stat.ST_INO] and \ return s1[stat.ST_INO] == s2[stat.ST_INO] and \
s1[stat.ST_DEV] = s2[stat.STD_DEV] s1[stat.ST_DEV] == s2[stat.STD_DEV]
# Subroutine and global data used by ismount(). # Subroutine and global data used by ismount().
@ -137,7 +137,7 @@ def _getmounts():
lines = string.splitfields(data, '\n') lines = string.splitfields(data, '\n')
for line in lines: for line in lines:
words = string.split(line) words = string.split(line)
if len(words) >= 3 and words[1] = 'on': if len(words) >= 3 and words[1] == 'on':
mounts.append(words[2]) mounts.append(words[2])
return mounts return mounts

View file

@ -49,7 +49,7 @@ class scheduler:
for i in range(len(q)): for i in range(len(q)):
qtime, qpri, qact, qarg = q[i] qtime, qpri, qact, qarg = q[i]
if time < qtime: break if time < qtime: break
if time = qtime and priority < qpri: break if time == qtime and priority < qpri: break
else: else:
i = len(q) i = len(q)
q.insert(i, event) q.insert(i, event)
@ -72,7 +72,7 @@ class scheduler:
# Check whether the queue is empty. # Check whether the queue is empty.
# #
def empty(self): def empty(self):
return len(self.queue) = 0 return len(self.queue) == 0
# #
# Run: execute events until the queue is empty. # Run: execute events until the queue is empty.
# #

View file

@ -36,22 +36,22 @@ S_IFLNK = 0120000
S_IFSOCK = 0140000 S_IFSOCK = 0140000
def S_ISDIR(mode): def S_ISDIR(mode):
return S_IFMT(mode) = S_IFDIR return S_IFMT(mode) == S_IFDIR
def S_ISCHR(mode): def S_ISCHR(mode):
return S_IFMT(mode) = S_IFCHR return S_IFMT(mode) == S_IFCHR
def S_ISBLK(mode): def S_ISBLK(mode):
return S_IFMT(mode) = S_IFBLK return S_IFMT(mode) == S_IFBLK
def S_ISREG(mode): def S_ISREG(mode):
return S_IFMT(mode) = S_IFREG return S_IFMT(mode) == S_IFREG
def S_ISFIFO(mode): def S_ISFIFO(mode):
return S_IFMT(mode) = S_IFIFO return S_IFMT(mode) == S_IFIFO
def S_ISLNK(mode): def S_ISLNK(mode):
return S_IFMT(mode) = S_IFLNK return S_IFMT(mode) == S_IFLNK
def S_ISSOCK(mode): def S_ISSOCK(mode):
return S_IFMT(mode) = S_IFSOCK return S_IFMT(mode) == S_IFSOCK

View file

@ -44,7 +44,7 @@ def forget(path):
def forget_prefix(prefix): def forget_prefix(prefix):
n = len(prefix) n = len(prefix)
for path in cache.keys(): for path in cache.keys():
if path[:n] = prefix: if path[:n] == prefix:
del cache[path] del cache[path]
@ -52,16 +52,16 @@ def forget_prefix(prefix):
# entries in subdirectories. # entries in subdirectories.
# #
def forget_dir(prefix): def forget_dir(prefix):
if prefix[-1:] = '/' and prefix <> '/': if prefix[-1:] == '/' and prefix <> '/':
prefix = prefix[:-1] prefix = prefix[:-1]
forget(prefix) forget(prefix)
if prefix[-1:] <> '/': if prefix[-1:] <> '/':
prefix = prefix + '/' prefix = prefix + '/'
n = len(prefix) n = len(prefix)
for path in cache.keys(): for path in cache.keys():
if path[:n] = prefix: if path[:n] == prefix:
rest = path[n:] rest = path[n:]
if rest[-1:] = '/': rest = rest[:-1] if rest[-1:] == '/': rest = rest[:-1]
if '/' not in rest: if '/' not in rest:
del cache[path] del cache[path]

View file

@ -110,7 +110,7 @@ class LabelAppearance:
# #
def draw(self, (d, area)): def draw(self, (d, area)):
area = _rect.intersect(area, self.bounds) area = _rect.intersect(area, self.bounds)
if area = _rect.empty: if area == _rect.empty:
return return
d.cliprect(area) d.cliprect(area)
self.drawit(d) self.drawit(d)

View file

@ -43,7 +43,7 @@ class CSplit(Split):
# XXX One day Python will have automatic conversions... # XXX One day Python will have automatic conversions...
n = len(self.children) n = len(self.children)
fn = float(n) fn = float(n)
if n = 0: return if n == 0: return
(left, top), (right, bottom) = bounds (left, top), (right, bottom) = bounds
width, height = right-left, bottom-top width, height = right-left, bottom-top
child_width, child_height = width*3/(n+4), height*3/(n+4) child_width, child_height = width*3/(n+4), height*3/(n+4)

View file

@ -25,7 +25,7 @@ class DirList(VSplit):
if path.isdir(path.join(dirname, name)): if path.isdir(path.join(dirname, name)):
fullname = path.join(dirname, name) fullname = path.join(dirname, name)
btn = SubdirButton().definetext(self, fullname) btn = SubdirButton().definetext(self, fullname)
elif name[-3:] = '.py': elif name[-3:] == '.py':
btn = ModuleButton().definetext(self, name) btn = ModuleButton().definetext(self, name)
else: else:
btn = FileButton().definetext(self, name) btn = FileButton().definetext(self, name)

View file

@ -116,7 +116,7 @@ class Split:
if not self.keybd_focus: if not self.keybd_focus:
self.set_keybd_focus(self.keybd_interest[0]) self.set_keybd_focus(self.keybd_interest[0])
type, detail = type_detail type, detail = type_detail
if type = WE_COMMAND and detail = WC_TAB and \ if type == WE_COMMAND and detail == WC_TAB and \
len(self.keybd_interest) > 1: len(self.keybd_interest) > 1:
self.next_keybd_focus() self.next_keybd_focus()
return return
@ -144,9 +144,9 @@ class Split:
self.timer_interest.remove(child) self.timer_interest.remove(child)
if child in self.altdraw_interest: if child in self.altdraw_interest:
self.altdraw_interest.remove(child) self.altdraw_interest.remove(child)
if child = self.mouse_focus: if child == self.mouse_focus:
self.mouse_focus = None self.mouse_focus = None
if child = self.keybd_focus: if child == self.keybd_focus:
self.keybd_focus = None self.keybd_focus = None
# #
def need_mouse(self, child): def need_mouse(self, child):
@ -154,7 +154,7 @@ class Split:
self.mouse_interest.append(child) self.mouse_interest.append(child)
self.parent.need_mouse(self) self.parent.need_mouse(self)
def no_mouse(self, child): def no_mouse(self, child):
if child = self.mouse_focus: if child == self.mouse_focus:
self.mouse_focus = None self.mouse_focus = None
if child in self.mouse_interest: if child in self.mouse_interest:
self.mouse_interest.remove(child) self.mouse_interest.remove(child)
@ -168,7 +168,7 @@ class Split:
if not self.keybd_focus: if not self.keybd_focus:
self.set_keybd_focus(child) self.set_keybd_focus(child)
def no_keybd(self, child): def no_keybd(self, child):
if child = self.keybd_focus: if child == self.keybd_focus:
self.keybd_focus = None # Don't call child.deactivate() self.keybd_focus = None # Don't call child.deactivate()
if child in self.keybd_interest: if child in self.keybd_interest:
self.keybd_interest.remove(child) self.keybd_interest.remove(child)

View file

@ -51,7 +51,7 @@ class StripChart(LabelAppearance, NoReactivity):
# #
def draw(self, (d, area)): def draw(self, (d, area)):
area = rect.intersect(area, self.bounds) area = rect.intersect(area, self.bounds)
if area = rect.empty: if area == rect.empty:
return return
d.cliprect(area) d.cliprect(area)
d.erase(self.bounds) d.erase(self.bounds)

View file

@ -149,26 +149,26 @@ class WindowParent(ManageOneChild):
# Only call dispatch once we are realized # Only call dispatch once we are realized
# #
def dispatch(self, (type, win, detail)): def dispatch(self, (type, win, detail)):
if type = WE_DRAW: if type == WE_DRAW:
d = self.win.begindrawing() d = self.win.begindrawing()
self.child.draw(d, detail) self.child.draw(d, detail)
del d del d
if self.do_altdraw: self.child.altdraw(detail) if self.do_altdraw: self.child.altdraw(detail)
elif type = WE_MOUSE_DOWN: elif type == WE_MOUSE_DOWN:
if self.do_mouse: self.child.mouse_down(detail) if self.do_mouse: self.child.mouse_down(detail)
elif type = WE_MOUSE_MOVE: elif type == WE_MOUSE_MOVE:
if self.do_mouse: self.child.mouse_move(detail) if self.do_mouse: self.child.mouse_move(detail)
elif type = WE_MOUSE_UP: elif type == WE_MOUSE_UP:
if self.do_mouse: self.child.mouse_up(detail) if self.do_mouse: self.child.mouse_up(detail)
elif type in (WE_CHAR, WE_COMMAND): elif type in (WE_CHAR, WE_COMMAND):
if self.do_keybd: self.child.keybd(type, detail) if self.do_keybd: self.child.keybd(type, detail)
elif type = WE_TIMER: elif type == WE_TIMER:
if self.do_timer: self.child.timer() if self.do_timer: self.child.timer()
elif type = WE_SIZE: elif type == WE_SIZE:
self.fixup() self.fixup()
elif type = WE_CLOSE: elif type == WE_CLOSE:
self.close_trigger() self.close_trigger()
elif type = WE_MENU: elif type == WE_MENU:
self.menu_trigger(detail) self.menu_trigger(detail)
if self.pending_destroy: if self.pending_destroy:
self.destroy() self.destroy()

View file

@ -21,7 +21,7 @@ def delayfunc(msecs):
# #
# Use millisleep for very short delays or if there are no windows # Use millisleep for very short delays or if there are no windows
# #
if msecs < 100 or mainloop.countwindows() = 0: if msecs < 100 or mainloop.countwindows() == 0:
if msecs > 0: if msecs > 0:
time.millisleep(msecs) time.millisleep(msecs)
return return
@ -46,7 +46,7 @@ cancel = q.cancel
# Emptiness check must check both queues # Emptiness check must check both queues
# #
def empty(): def empty():
return q.empty() and mainloop.countwindows() = 0 return q.empty() and mainloop.countwindows() == 0
# Run until there is nothing left to do # Run until there is nothing left to do
# #

View file

@ -10,7 +10,7 @@ import dircache
def action(w, string, i, detail): def action(w, string, i, detail):
(h, v), clicks, button, mask = detail (h, v), clicks, button, mask = detail
if clicks = 2: if clicks == 2:
name = path.join(w.name, string) name = path.join(w.name, string)
try: try:
w2 = anywin.open(name) w2 = anywin.open(name)

View file

@ -175,20 +175,20 @@ def test():
winsize = w.getwinsize() winsize = w.getwinsize()
while 1: while 1:
type, window, detail = stdwinq.getevent() type, window, detail = stdwinq.getevent()
if type = WE_CLOSE: if type == WE_CLOSE:
break break
elif type = WE_SIZE: elif type == WE_SIZE:
newsize = w.getwinsize() newsize = w.getwinsize()
if newsize <> winsize: if newsize <> winsize:
w.change((0,0), winsize) w.change((0,0), winsize)
winsize = newsize winsize = newsize
w.change((0,0), winsize) w.change((0,0), winsize)
elif type = WE_MOUSE_DOWN: elif type == WE_MOUSE_DOWN:
stage = (stage + 1) % len(stages) stage = (stage + 1) % len(stages)
justify, center, title = stages[stage] justify, center, title = stages[stage]
w.settitle(title) w.settitle(title)
w.change((0, 0), (1000, 1000)) w.change((0, 0), (1000, 1000))
elif type = WE_DRAW: elif type == WE_DRAW:
width, height = winsize width, height = winsize
f = formatter().init(w.begindrawing(), 0, 0, width) f = formatter().init(w.begindrawing(), 0, 0, width)
f.center = center f.center = center
@ -198,7 +198,7 @@ def test():
for font in font1, font2, font1: for font in font1, font2, font1:
f.setfont(font) f.setfont(font)
for word in words: for word in words:
space = 1 + (word[-1:] = '.') space = 1 + (word[-1:] == '.')
f.addword(word, space) f.addword(word, space)
if center and space > 1: if center and space > 1:
f.flush() f.flush()

View file

@ -49,44 +49,44 @@ def mainloop(): # Handle events until no windows left
def treatevent(e): # Handle a stdwin event def treatevent(e): # Handle a stdwin event
type, w, detail = e type, w, detail = e
if type = WE_DRAW: if type == WE_DRAW:
w.draw(w, detail) w.draw(w, detail)
elif type = WE_MENU: elif type == WE_MENU:
m, item = detail m, item = detail
m.action[item](w, m, item) m.action[item](w, m, item)
elif type = WE_COMMAND: elif type == WE_COMMAND:
treatcommand(w, detail) treatcommand(w, detail)
elif type = WE_CHAR: elif type == WE_CHAR:
w.char(w, detail) w.char(w, detail)
elif type = WE_MOUSE_DOWN: elif type == WE_MOUSE_DOWN:
if detail[1] > 1: w.m2down(w, detail) if detail[1] > 1: w.m2down(w, detail)
else: w.mdown(w, detail) else: w.mdown(w, detail)
elif type = WE_MOUSE_MOVE: elif type == WE_MOUSE_MOVE:
w.mmove(w, detail) w.mmove(w, detail)
elif type = WE_MOUSE_UP: elif type == WE_MOUSE_UP:
if detail[1] > 1: w.m2up(w, detail) if detail[1] > 1: w.m2up(w, detail)
else: w.mup(w, detail) else: w.mup(w, detail)
elif type = WE_SIZE: elif type == WE_SIZE:
w.size(w, w.getwinsize()) w.size(w, w.getwinsize())
elif type = WE_ACTIVATE: elif type == WE_ACTIVATE:
w.activate(w) w.activate(w)
elif type = WE_DEACTIVATE: elif type == WE_DEACTIVATE:
w.deactivate(w) w.deactivate(w)
elif type = WE_MOVE: elif type == WE_MOVE:
w.move(w) w.move(w)
elif type = WE_TIMER: elif type == WE_TIMER:
w.timer(w) w.timer(w)
elif type = WE_CLOSE: elif type == WE_CLOSE:
w.close(w) w.close(w)
def treatcommand(w, type): # Handle a we_command event def treatcommand(w, type): # Handle a we_command event
if type = WC_CLOSE: if type == WC_CLOSE:
w.close(w) w.close(w)
elif type = WC_RETURN: elif type == WC_RETURN:
w.enter(w) w.enter(w)
elif type = WC_TAB: elif type == WC_TAB:
w.tab(w) w.tab(w)
elif type = WC_BACKSPACE: elif type == WC_BACKSPACE:
w.backspace(w) w.backspace(w)
elif type in (WC_LEFT, WC_UP, WC_RIGHT, WC_DOWN): elif type in (WC_LEFT, WC_UP, WC_RIGHT, WC_DOWN):
w.arrow(w, type) w.arrow(w, type)
@ -101,13 +101,13 @@ def close(w): # Close method
break break
def arrow(w, detail): # Arrow key method def arrow(w, detail): # Arrow key method
if detail = WC_LEFT: if detail == WC_LEFT:
w.kleft(w) w.kleft(w)
elif detail = WC_UP: elif detail == WC_UP:
w.kup(w) w.kup(w)
elif detail = WC_RIGHT: elif detail == WC_RIGHT:
w.kright(w) w.kright(w)
elif detail = WC_DOWN: elif detail == WC_DOWN:
w.kdown(w) w.kdown(w)

View file

@ -164,13 +164,13 @@ def whichcol(w, h): # Return column number (may be >= len(w.data))
return len(w.data) return len(w.data)
def arrow(w, type): def arrow(w, type):
if type = WC_LEFT: if type == WC_LEFT:
incr = -1, 0 incr = -1, 0
elif type = WC_UP: elif type == WC_UP:
incr = 0, -1 incr = 0, -1
elif type = WC_RIGHT: elif type == WC_RIGHT:
incr = 1, 0 incr = 1, 0
elif type = WC_DOWN: elif type == WC_DOWN:
incr = 0, 1 incr = 0, 1
else: else:
return return

View file

@ -56,7 +56,7 @@ def split(s):
i, n = 0, len(s) i, n = 0, len(s)
while i < n: while i < n:
while i < n and s[i] in whitespace: i = i+1 while i < n and s[i] in whitespace: i = i+1
if i = n: break if i == n: break
j = i j = i
while j < n and s[j] not in whitespace: j = j+1 while j < n and s[j] not in whitespace: j = j+1
res.append(s[i:j]) res.append(s[i:j])
@ -71,7 +71,7 @@ def splitfields(s, sep):
nsep = len(sep) nsep = len(sep)
i = j = 0 i = j = 0
while j+nsep <= ns: while j+nsep <= ns:
if s[j:j+nsep] = sep: if s[j:j+nsep] == sep:
res.append(s[i:j]) res.append(s[i:j])
i = j = j + nsep i = j = j + nsep
else: else:
@ -98,7 +98,7 @@ index_error = 'substring not found in string.index'
def index(s, sub): def index(s, sub):
n = len(sub) n = len(sub)
for i in range(len(s) + 1 - n): for i in range(len(s) + 1 - n):
if sub = s[i:i+n]: return i if sub == s[i:i+n]: return i
raise index_error, (s, sub) raise index_error, (s, sub)
# Convert string to integer # Convert string to integer
@ -137,7 +137,7 @@ def center(s, width):
# Decadent feature: the argument may be a string or a number # Decadent feature: the argument may be a string or a number
# (Use of this is deprecated; it should be a string as with ljust c.s.) # (Use of this is deprecated; it should be a string as with ljust c.s.)
def zfill(x, width): def zfill(x, width):
if type(x) = type(''): s = x if type(x) == type(''): s = x
else: s = `x` else: s = `x`
n = len(s) n = len(s)
if n >= width: return s if n >= width: return s

View file

@ -56,7 +56,7 @@ def split(s):
i, n = 0, len(s) i, n = 0, len(s)
while i < n: while i < n:
while i < n and s[i] in whitespace: i = i+1 while i < n and s[i] in whitespace: i = i+1
if i = n: break if i == n: break
j = i j = i
while j < n and s[j] not in whitespace: j = j+1 while j < n and s[j] not in whitespace: j = j+1
res.append(s[i:j]) res.append(s[i:j])
@ -71,7 +71,7 @@ def splitfields(s, sep):
nsep = len(sep) nsep = len(sep)
i = j = 0 i = j = 0
while j+nsep <= ns: while j+nsep <= ns:
if s[j:j+nsep] = sep: if s[j:j+nsep] == sep:
res.append(s[i:j]) res.append(s[i:j])
i = j = j + nsep i = j = j + nsep
else: else:
@ -98,7 +98,7 @@ index_error = 'substring not found in string.index'
def index(s, sub): def index(s, sub):
n = len(sub) n = len(sub)
for i in range(len(s) + 1 - n): for i in range(len(s) + 1 - n):
if sub = s[i:i+n]: return i if sub == s[i:i+n]: return i
raise index_error, (s, sub) raise index_error, (s, sub)
# Convert string to integer # Convert string to integer
@ -137,7 +137,7 @@ def center(s, width):
# Decadent feature: the argument may be a string or a number # Decadent feature: the argument may be a string or a number
# (Use of this is deprecated; it should be a string as with ljust c.s.) # (Use of this is deprecated; it should be a string as with ljust c.s.)
def zfill(x, width): def zfill(x, width):
if type(x) = type(''): s = x if type(x) == type(''): s = x
else: s = `x` else: s = `x`
n = len(s) n = len(s)
if n >= width: return s if n >= width: return s

View file

@ -44,7 +44,7 @@ def gethdr(fp):
def printhdr(file): def printhdr(file):
hdr = gethdr(open(file, 'r')) hdr = gethdr(open(file, 'r'))
data_size, encoding, sample_rate, channels, info = hdr data_size, encoding, sample_rate, channels, info = hdr
while info[-1:] = '\0': while info[-1:] == '\0':
info = info[:-1] info = info[:-1]
print 'File name: ', file print 'File name: ', file
print 'Data size: ', data_size print 'Data size: ', data_size

View file

@ -40,19 +40,19 @@ def browser(tb):
break break
cmd = string.strip(line) cmd = string.strip(line)
if cmd: if cmd:
if cmd = 'quit': if cmd == 'quit':
break break
elif cmd = 'list': elif cmd == 'list':
browserlist(tb) browserlist(tb)
elif cmd = 'up': elif cmd == 'up':
if ptr-1 >= 0: ptr = ptr-1 if ptr-1 >= 0: ptr = ptr-1
else: print 'Bottom of stack.' else: print 'Bottom of stack.'
elif cmd = 'down': elif cmd == 'down':
if ptr+1 < len(tblist): ptr = ptr+1 if ptr+1 < len(tblist): ptr = ptr+1
else: print 'Top of stack.' else: print 'Top of stack.'
elif cmd = 'locals': elif cmd == 'locals':
printsymbols(tb.tb_frame.f_locals) printsymbols(tb.tb_frame.f_locals)
elif cmd = 'globals': elif cmd == 'globals':
printsymbols(tb.tb_frame.f_globals) printsymbols(tb.tb_frame.f_globals)
elif cmd in ('?', 'help'): elif cmd in ('?', 'help'):
browserhelp() browserhelp()
@ -65,10 +65,10 @@ def browserlist(tb):
last = lineno last = lineno
first = max(1, last-10) first = max(1, last-10)
for i in range(first, last+1): for i in range(first, last+1):
if i = lineno: prefix = '***' + string.rjust(`i`, 4) + ':' if i == lineno: prefix = '***' + string.rjust(`i`, 4) + ':'
else: prefix = string.rjust(`i`, 7) + ':' else: prefix = string.rjust(`i`, 7) + ':'
line = readfileline(filename, i) line = readfileline(filename, i)
if line[-1:] = '\n': line = line[:-1] if line[-1:] == '\n': line = line[:-1]
print prefix + line print prefix + line
def browserexec(tb, cmd): def browserexec(tb, cmd):
@ -126,24 +126,24 @@ def printsymbols(d):
print print
def printobject(v, maxlevel): def printobject(v, maxlevel):
if v = None: if v == None:
print 'None', print 'None',
elif type(v) in (type(0), type(0.0)): elif type(v) in (type(0), type(0.0)):
print v, print v,
elif type(v) = type(''): elif type(v) == type(''):
if len(v) > 20: if len(v) > 20:
print `v[:17] + '...'`, print `v[:17] + '...'`,
else: else:
print `v`, print `v`,
elif type(v) = type(()): elif type(v) == type(()):
print '(', print '(',
printlist(v, maxlevel) printlist(v, maxlevel)
print ')', print ')',
elif type(v) = type([]): elif type(v) == type([]):
print '[', print '[',
printlist(v, maxlevel) printlist(v, maxlevel)
print ']', print ']',
elif type(v) = type({}): elif type(v) == type({}):
print '{', print '{',
printdict(v, maxlevel) printdict(v, maxlevel)
print '}', print '}',
@ -152,7 +152,7 @@ def printobject(v, maxlevel):
def printlist(v, maxlevel): def printlist(v, maxlevel):
n = len(v) n = len(v)
if n = 0: return if n == 0: return
if maxlevel <= 0: if maxlevel <= 0:
print '...', print '...',
return return
@ -164,7 +164,7 @@ def printlist(v, maxlevel):
def printdict(v, maxlevel): def printdict(v, maxlevel):
keys = v.keys() keys = v.keys()
n = len(keys) n = len(keys)
if n = 0: return if n == 0: return
if maxlevel <= 0: if maxlevel <= 0:
print '...', print '...',
return return
@ -187,8 +187,8 @@ def readfileline(filename, lineno):
cache_ok = 0 cache_ok = 0
if _filecache.has_key(filename): if _filecache.has_key(filename):
cached_stat, lines = _filecache[filename] cached_stat, lines = _filecache[filename]
if stat[ST_SIZE] = cached_stat[ST_SIZE] and \ if stat[ST_SIZE] == cached_stat[ST_SIZE] and \
stat[ST_MTIME] = cached_stat[ST_MTIME]: stat[ST_MTIME] == cached_stat[ST_MTIME]:
cache_ok = 1 cache_ok = 1
else: else:
print 'Stale cache entry for', filename print 'Stale cache entry for', filename

View file

@ -40,9 +40,13 @@ if 0xff <> 255: raise TestFailed, 'hex number'
if 0377 <> 255: raise TestFailed, 'octal number' if 0377 <> 255: raise TestFailed, 'octal number'
x = 3.14 x = 3.14
x = 0.314 x = 0.314
x = .14
x = 3.
x = 3e14 x = 3e14
x = 3E14 x = 3E14
x = 3e-14 x = 3e-14
x = 3.e14
x = .14e3
x = 0L x = 0L
x = 0l x = 0l
x = 0xffffffffffffffffL x = 0xffffffffffffffffL
@ -209,11 +213,11 @@ print 'test' # and_test ('or' and_test)*
### comparison: expr (comp_op expr)* ### comparison: expr (comp_op expr)*
### comp_op: '<'|'>'|'='|'>' '='|'<' '='|'<' '>'|'in'|'not' 'in'|'is'|'is' 'not' ### comp_op: '<'|'>'|'='|'>' '='|'<' '='|'<' '>'|'in'|'not' 'in'|'is'|'is' 'not'
if 1: pass if 1: pass
if 1 = 1: pass if 1 == 1: pass
if 1 < 1 > 1 = 1 >= 1 <= 1 <> 1 in 1 not in 1 is 1 is not 1: pass if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 in 1 not in 1 is 1 is not 1: pass
if not 1 = 1 = 1: pass if not 1 == 1 == 1: pass
if not 1 = 1 and 1 and 1: pass if not 1 == 1 and 1 and 1: pass
if 1 and 1 or 1 and 1 and 1 or not 1 = 1 = 1 and 1: pass if 1 and 1 or 1 and 1 and 1 or not 1 == 1 == 1 and 1: pass
print 'expr' # term (('+'|'-') term)* print 'expr' # term (('+'|'-') term)*
x = 1 x = 1
@ -236,17 +240,34 @@ x = 1
c = sys.path[0] c = sys.path[0]
x = time.time() x = time.time()
x = sys.modules['time'].time() x = sys.modules['time'].time()
a = '01234' for a in '01234', (0,1,2,3,4), [0,1,2,3,4]:
c = a[0] c = a[0]
c = a[0:5] c = a[-1]
c = a[:5] c = a[0:5]
c = a[0:] c = a[:5]
c = a[:] c = a[0:]
c = a[-5:] c = a[:]
c = a[:-1] c = a[-5:]
c = a[-4:-3] c = a[:-1]
c = a[-4:-3]
a = [0,1,2,3,4]
del a[0]
a = [0,1,2,3,4]
del a[-1]
a = [0,1,2,3,4]
del a[1:2]
a = [0,1,2,3,4]
del a[:1]
a = [0,1,2,3,4]
del a[-1:]
a = [0,1,2,3,4]
a[0] = 0
a[-1] = 4
a[1:2] = [1]
a[1:4] = [0]
a[1:-1] = [1,2,3]
print 'atom' # '(' [testlist] ')' | '[' [testlist] ']' | '{' '}' | '`' testlist '`' | NAME | NUMBER | STRING print 'atom' # '(' [tetslist] ')' | '[' [testlist] ']' | '{' '}' | '`' testlist '`' | NAME | NUMBER | STRING
x = (1) x = (1)
x = (1 or 2 or 3) x = (1 or 2 or 3)
x = (1 or 2 or 3, 2, 3) x = (1 or 2 or 3, 2, 3)
@ -476,7 +497,7 @@ import string
reload(string) reload(string)
print 'type' print 'type'
if type('') <> type('123') or type('') = type(()): if type('') <> type('123') or type('') == type(()):
raise TestFailed, 'type()' raise TestFailed, 'type()'

View file

@ -53,7 +53,7 @@ def make_all(mat):
return all return all
def make_elements(n, d): def make_elements(n, d):
if d = 0: return [poly.one(0, 0)] if d == 0: return [poly.one(0, 0)]
sub = make_elements(n, d-1) sub = make_elements(n, d-1)
all = [] all = []
for a in sub: for a in sub:
@ -75,7 +75,7 @@ def checkfield(n, p):
inv1 = inv[:] inv1 = inv[:]
all1.sort() all1.sort()
inv1.sort() inv1.sort()
if all1 = inv1: print 'BINGO!' if all1 == inv1: print 'BINGO!'
else: else:
print 'Sorry:', n, p print 'Sorry:', n, p
print all print all

View file

@ -37,17 +37,17 @@ def _stat(name):
cache[name] = NONE cache[name] = NONE
return NONE return NONE
cache[name] = list cache[name] = list
if name[-1:] = ':': cache[name[:-1]] = list if name[-1:] == ':': cache[name[:-1]] = list
else: cache[name+':'] = list else: cache[name+':'] = list
return list return list
def isdir(name): def isdir(name):
st = _stat(name) st = _stat(name)
return type(st) = LISTTYPE return type(st) == LISTTYPE
def isfile(name): def isfile(name):
st = _stat(name) st = _stat(name)
return st = FILE return st == FILE
def exists(name): def exists(name):
st = _stat(name) st = _stat(name)
@ -55,7 +55,7 @@ def exists(name):
def listdir(name): def listdir(name):
st = _stat(name) st = _stat(name)
if type(st) = LISTTYPE: if type(st) == LISTTYPE:
return st return st
else: else:
raise RuntimeError, 'list non-directory' raise RuntimeError, 'list non-directory'

View file

@ -17,13 +17,13 @@ except NameError:
statfunc = posix.stat statfunc = posix.stat
# Parse options # Parse options
if sys.argv[1] = '-m': if sys.argv[1] == '-m':
itime = ST_MTIME itime = ST_MTIME
del sys.argv[1] del sys.argv[1]
elif sys.argv[1] = '-c': elif sys.argv[1] == '-c':
itime = ST_CTIME itime = ST_CTIME
del sys.argv[1] del sys.argv[1]
elif sys.argv[1] = '-a': elif sys.argv[1] == '-a':
itime = ST_CTIME itime = ST_CTIME
del sys.argv[1] del sys.argv[1]
else: else:

View file

@ -10,9 +10,9 @@ def main():
silent = 0 silent = 0
verbose = 0 verbose = 0
if sys.argv[1:]: if sys.argv[1:]:
if sys.argv[1] = '-v': if sys.argv[1] == '-v':
verbose = 1 verbose = 1
elif sys.argv[1] = '-s': elif sys.argv[1] == '-s':
silent = 1 silent = 1
MAGIC = '\0\0\0\0' MAGIC = '\0\0\0\0'
try: try:
@ -32,7 +32,7 @@ def main():
print 'Checking', `dirname`, '...' print 'Checking', `dirname`, '...'
names.sort() names.sort()
for name in names: for name in names:
if name[-3:] = '.py': if name[-3:] == '.py':
name = path.join(dirname, name) name = path.join(dirname, name)
try: try:
st = posix.stat(name) st = posix.stat(name)
@ -55,7 +55,7 @@ def main():
print `name_c` print `name_c`
continue continue
mtime = get_long(mtime_str) mtime = get_long(mtime_str)
if mtime = 0 or mtime = -1: if mtime == 0 or mtime == -1:
print 'Bad ".pyc" file', `name_c` print 'Bad ".pyc" file', `name_c`
elif mtime <> st[ST_MTIME]: elif mtime <> st[ST_MTIME]:
print 'Out-of-date ".pyc" file', print 'Out-of-date ".pyc" file',

View file

@ -17,7 +17,7 @@ def visit(pattern, dirname, names):
name = path.join(dirname, name) name = path.join(dirname, name)
try: try:
linkto = posix.readlink(name) linkto = posix.readlink(name)
if linkto[:n] = pattern: if linkto[:n] == pattern:
print name, '->', linkto print name, '->', linkto
except posix.error: except posix.error:
pass pass

View file

@ -170,18 +170,18 @@ def main():
return 1 return 1
optu = optc = optd = 0 optu = optc = optd = 0
for opt, void in optlist: for opt, void in optlist:
if opt = '-u': if opt == '-u':
optu = 1 optu = 1
elif opt = '-c': elif opt == '-c':
optc = 1 optc = 1
elif opt = '-d': elif opt == '-d':
optd = 1 optd = 1
if optu = optc = optd = 0: if optu == optc == optd == 0:
optu = optc = optd = 1 optu = optc = optd = 1
if not args: if not args:
args = ['-'] args = ['-']
for file in args: for file in args:
if file = '-': if file == '-':
readinput(sys.stdin) readinput(sys.stdin)
else: else:
readinput(open(file, 'r')) readinput(open(file, 'r'))

View file

@ -67,13 +67,13 @@ m_from = regexp.compile('^[ \t]*import[ \t]+([^#]+)')
def process(filename, table): def process(filename, table):
fp = open(filename, 'r') fp = open(filename, 'r')
mod = path.basename(filename) mod = path.basename(filename)
if mod[-3:] = '.py': if mod[-3:] == '.py':
mod = mod[:-3] mod = mod[:-3]
table[mod] = list = [] table[mod] = list = []
while 1: while 1:
line = fp.readline() line = fp.readline()
if not line: break if not line: break
while line[-1:] = '\\': while line[-1:] == '\\':
nextline = fp.readline() nextline = fp.readline()
if not nextline: break if not nextline: break
line = line[:-1] + nextline line = line[:-1] + nextline

View file

@ -33,7 +33,7 @@ def treat_file(file):
print 'Cannot open', file print 'Cannot open', file
return return
base = path.basename(file) base = path.basename(file)
if base[-3:] = '.py': base = base[:-3] if base[-3:] == '.py': base = base[:-3]
s = base + '\t' + file + '\t' + '1\n' s = base + '\t' + file + '\t' + '1\n'
tags.append(s) tags.append(s)
while 1: while 1:

View file

@ -22,7 +22,7 @@ def main():
def getsuffix(file): def getsuffix(file):
suff = '' suff = ''
for i in range(len(file)): for i in range(len(file)):
if file[i] = '.': if file[i] == '.':
suff = file[i:] suff = file[i:]
return suff return suff

View file

@ -23,7 +23,7 @@ for prog in sys.argv[1:]:
mode = S_IMODE(st[ST_MODE]) mode = S_IMODE(st[ST_MODE])
if mode % 2 or mode/8 % 2 or mode/64 % 2: if mode % 2 or mode/8 % 2 or mode/64 % 2:
if ident: if ident:
if st[:3] = ident: if st[:3] == ident:
s = ': same as ' s = ': same as '
else: else:
s = ': also ' s = ': also '

View file

@ -50,19 +50,19 @@ def skipfile(file):
# Skip executables # Skip executables
try: try:
data = open(file, 'r').read(len(EXECMAGIC)) data = open(file, 'r').read(len(EXECMAGIC))
if data = EXECMAGIC: return 1 if data == EXECMAGIC: return 1
except: except:
pass pass
return 0 return 0
def badprefix(file): def badprefix(file):
for bad in badprefixes: for bad in badprefixes:
if file[:len(bad)] = bad: return 1 if file[:len(bad)] == bad: return 1
return 0 return 0
def badsuffix(file): def badsuffix(file):
for bad in badsuffixes: for bad in badsuffixes:
if file[-len(bad):] = bad: return 1 if file[-len(bad):] == bad: return 1
return 0 return 0
def go(args): def go(args):