mirror of
https://github.com/AdaCore/cpython.git
synced 2026-02-12 12:57:15 -08:00
New == syntax
This commit is contained in:
@@ -12,17 +12,17 @@ error = 'fact.error' # exception
|
||||
|
||||
def fact(n):
|
||||
if n < 1: raise error # fact() argument should be >= 1
|
||||
if n = 1: return [] # special case
|
||||
if n == 1: return [] # special case
|
||||
res = []
|
||||
# Treat even factors special, so we can use i = i+2 later
|
||||
while n%2 = 0:
|
||||
while n%2 == 0:
|
||||
res.append(2)
|
||||
n = n/2
|
||||
# Try odd numbers up to sqrt(n)
|
||||
limit = sqrt(n+1)
|
||||
i = 3
|
||||
while i <= limit:
|
||||
if n%i = 0:
|
||||
if n%i == 0:
|
||||
res.append(i)
|
||||
n = n/i
|
||||
limit = sqrt(n+1)
|
||||
|
||||
@@ -24,13 +24,13 @@ except RuntimeError:
|
||||
while 1:
|
||||
line = mail.readline()
|
||||
if not line: break # EOF
|
||||
if line[:5] = 'From ':
|
||||
if line[:5] == 'From ':
|
||||
# Start of message found
|
||||
print line[:-1],
|
||||
while 1:
|
||||
line = mail.readline()
|
||||
if not line: break # EOF
|
||||
if line = '\n': break # Blank line ends headers
|
||||
if line[:8] = 'Subject:':
|
||||
if line == '\n': break # Blank line ends headers
|
||||
if line[:8] == 'Subject:':
|
||||
print `line[9:-1]`,
|
||||
print
|
||||
|
||||
@@ -23,7 +23,7 @@ def main():
|
||||
# Strip '-P' from printer names just in case
|
||||
# the user specified it...
|
||||
for i in range(len(printers)):
|
||||
if printers[i][:2] = '-P':
|
||||
if printers[i][:2] == '-P':
|
||||
printers[i] = printers[i][2:]
|
||||
else:
|
||||
if posix.environ.has_key('PRINTER'):
|
||||
@@ -54,13 +54,13 @@ def makestatus(name, thisuser):
|
||||
if not line: break
|
||||
fields = string.split(line)
|
||||
n = len(fields)
|
||||
if len(fields) >= 6 and fields[n-1] = 'bytes':
|
||||
if len(fields) >= 6 and fields[n-1] == 'bytes':
|
||||
rank = fields[0]
|
||||
user = fields[1]
|
||||
job = fields[2]
|
||||
files = fields[3:-2]
|
||||
bytes = eval(fields[n-2])
|
||||
if user = thisuser:
|
||||
if user == thisuser:
|
||||
userseen = 1
|
||||
elif not userseen:
|
||||
aheadbytes = aheadbytes + bytes
|
||||
@@ -77,9 +77,9 @@ def makestatus(name, thisuser):
|
||||
else:
|
||||
if fields and fields[0] <> 'Rank':
|
||||
line = string.strip(line)
|
||||
if line = 'no entries':
|
||||
if line == 'no entries':
|
||||
line = name + ': idle'
|
||||
elif line[-22:] = ' is ready and printing':
|
||||
elif line[-22:] == ' is ready and printing':
|
||||
line = name
|
||||
lines.append(line)
|
||||
#
|
||||
@@ -87,12 +87,12 @@ def makestatus(name, thisuser):
|
||||
line = `(totalbytes+1023)/1024` + ' K'
|
||||
if totaljobs <> len(users):
|
||||
line = line + ' (' + `totaljobs` + ' jobs)'
|
||||
if len(users) = 1:
|
||||
if len(users) == 1:
|
||||
line = line + ' for ' + users.keys()[0]
|
||||
else:
|
||||
line = line + ' for ' + `len(users)` + ' users'
|
||||
if userseen:
|
||||
if aheadjobs = 0:
|
||||
if aheadjobs == 0:
|
||||
line = line + ' (' + thisuser + ' first)'
|
||||
else:
|
||||
line = line + ' (' + `(aheadbytes+1023)/1024`
|
||||
|
||||
@@ -19,7 +19,7 @@ def main():
|
||||
# Print common digits
|
||||
d, d1 = a/b, a1/b1
|
||||
#print a, b, a1, b1
|
||||
while d = d1:
|
||||
while d == d1:
|
||||
# Use write() to avoid spaces between the digits
|
||||
sys.stdout.write(`int(d)`)
|
||||
# Flush so the output is seen immediately
|
||||
|
||||
@@ -17,7 +17,7 @@ def primes(min, max):
|
||||
i = 3
|
||||
while i <= max:
|
||||
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:
|
||||
primes.append(i)
|
||||
if i >= min: print i
|
||||
|
||||
@@ -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
|
||||
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
|
||||
January = 1
|
||||
@@ -45,7 +45,7 @@ def gmtime(secs):
|
||||
yday = days
|
||||
month = January
|
||||
while 1:
|
||||
md = mdays[month] + (month = February and isleap(year))
|
||||
md = mdays[month] + (month == February and isleap(year))
|
||||
if days < md: break
|
||||
days = days - md
|
||||
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
|
||||
def monthrange(year, month):
|
||||
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 a matrix representing a month's calendar
|
||||
@@ -161,7 +161,7 @@ def center(str, width):
|
||||
# Print a single week (no newline)
|
||||
def prweek(week, width):
|
||||
for day in week:
|
||||
if day = 0: print ' '*width,
|
||||
if day == 0: print ' '*width,
|
||||
else:
|
||||
if width > 2: print ' '*(width-3),
|
||||
if day < 10: print '',
|
||||
|
||||
@@ -19,7 +19,7 @@ def cmp(f1, f2): # Compare two files, use the cache if possible.
|
||||
if s1[0] <> 8 or s2[0] <> 8:
|
||||
# Either is a not a plain file -- always report as different
|
||||
return 0
|
||||
if s1 = s2:
|
||||
if s1 == s2:
|
||||
# type, size & mtime match -- report same
|
||||
return 1
|
||||
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:
|
||||
cs1, cs2, outcome = cache[key]
|
||||
# cache hit
|
||||
if s1 = cs1 and s2 = cs2:
|
||||
if s1 == cs1 and s2 == cs2:
|
||||
# cached signatures match
|
||||
return outcome
|
||||
# stale cached signature(s)
|
||||
|
||||
@@ -29,7 +29,7 @@ def cmp(f1, f2):
|
||||
if not S_ISREG(s1[0]) or not S_ISREG(s2[0]):
|
||||
# Either is a not a plain file -- always report as different
|
||||
return 0
|
||||
if s1 = s2:
|
||||
if s1 == s2:
|
||||
# type, size & mtime match -- report same
|
||||
return 1
|
||||
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):
|
||||
cs1, cs2, outcome = cache[key]
|
||||
# cache hit
|
||||
if s1 = cs1 and s2 = cs2:
|
||||
if s1 == cs1 and s2 == cs2:
|
||||
# cached signatures match
|
||||
return outcome
|
||||
# stale cached signature(s)
|
||||
|
||||
@@ -25,8 +25,8 @@ def getstatusoutput(cmd):
|
||||
pipe = posix.popen('{ ' + cmd + '; } 2>&1', 'r')
|
||||
text = pipe.read()
|
||||
sts = pipe.close()
|
||||
if sts = None: sts = 0
|
||||
if text[-1:] = '\n': text = text[:-1]
|
||||
if sts == None: sts = 0
|
||||
if text[-1:] == '\n': text = text[:-1]
|
||||
return sts, text
|
||||
|
||||
|
||||
|
||||
@@ -174,7 +174,7 @@ def cmp(a, b):
|
||||
#
|
||||
def remove(list, item):
|
||||
for i in range(len(list)):
|
||||
if list[i] = item:
|
||||
if list[i] == item:
|
||||
del list[i]
|
||||
break
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ def disassemble(co, lasti):
|
||||
while i < n:
|
||||
c = code[i]
|
||||
op = ord(c)
|
||||
if op = SET_LINENO and i > 0: print # Extra blank line
|
||||
if i = lasti: print '-->',
|
||||
if op == SET_LINENO and i > 0: print # Extra blank line
|
||||
if i == lasti: print '-->',
|
||||
else: print ' ',
|
||||
if i in labels: print '>>',
|
||||
else: print ' ',
|
||||
|
||||
@@ -31,7 +31,7 @@ def dumpsymtab(dict):
|
||||
def dumpvar(name, x):
|
||||
import sys
|
||||
t = type(x)
|
||||
if t = type({}):
|
||||
if t == type({}):
|
||||
print name, '= {}'
|
||||
for key in x.keys():
|
||||
item = x[key]
|
||||
@@ -42,7 +42,7 @@ def dumpvar(name, x):
|
||||
if not printable(x):
|
||||
print '#',
|
||||
print name, '=', `x`
|
||||
elif t = type(sys):
|
||||
elif t == type(sys):
|
||||
print 'import', name, '#', x
|
||||
else:
|
||||
print '#', name, '=', x
|
||||
@@ -58,6 +58,6 @@ def printable(x):
|
||||
if not printable(item):
|
||||
return 0
|
||||
return 1
|
||||
if x = {}:
|
||||
if x == {}:
|
||||
return 1
|
||||
return 0
|
||||
|
||||
@@ -5,64 +5,70 @@ def fnmatch(name, pat):
|
||||
# Check for simple case: no special characters
|
||||
#
|
||||
if not ('*' in pat or '?' in pat or '[' in pat):
|
||||
return name = pat
|
||||
return name == pat
|
||||
#
|
||||
# Check for common cases: *suffix and prefix*
|
||||
#
|
||||
if pat[0] = '*':
|
||||
if pat[0] == '*':
|
||||
p1 = pat[1:]
|
||||
if not ('*' in p1 or '?' in p1 or '[' in p1):
|
||||
start = len(name) - len(p1)
|
||||
return start >= 0 and name[start:] = p1
|
||||
elif pat[-1:] = '*':
|
||||
return start >= 0 and name[start:] == p1
|
||||
elif pat[-1:] == '*':
|
||||
p1 = pat[:-1]
|
||||
if not ('*' in p1 or '?' in p1 or '[' in p1):
|
||||
return name[:len(p1)] = p1
|
||||
return name[:len(p1)] == p1
|
||||
#
|
||||
# General case
|
||||
#
|
||||
return fnmatch1(name, pat)
|
||||
|
||||
def fnmatch1(name, pat):
|
||||
for i in range(len(pat)):
|
||||
i, n = 0, len(pat)
|
||||
while i < n:
|
||||
c = pat[i]
|
||||
if c = '*':
|
||||
if c == '*':
|
||||
p1 = pat[i+1:]
|
||||
if not ('*' in p1 or '?' in p1 or '[' in 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):
|
||||
if fnmatch1(name[i:], p1):
|
||||
return 1
|
||||
return 0
|
||||
elif c = '?':
|
||||
elif c == '?':
|
||||
if len(name) <= i : return 0
|
||||
elif c = '[':
|
||||
elif c == '[':
|
||||
c, rest = name[i], name[i+1:]
|
||||
i, n = i+1, len(pat) - 1
|
||||
match = 0
|
||||
exclude = 0
|
||||
if i < n and pat[i] = '!':
|
||||
if i < n and pat[i] == '!':
|
||||
exclude = 1
|
||||
i = i+1
|
||||
while i < n:
|
||||
if pat[i] = c: match = 1
|
||||
if pat[i] == c: match = 1
|
||||
i = i+1
|
||||
if i >= n or pat[i] = ']':
|
||||
if i >= n or pat[i] == ']':
|
||||
break
|
||||
if pat[i] = '-':
|
||||
if pat[i] == '-':
|
||||
i = i+1
|
||||
if i >= n or pat[i] = ']':
|
||||
if i >= n or pat[i] == ']':
|
||||
break
|
||||
match = (pat[i-2] <= c <= pat[i])
|
||||
if pat[i-2] <= c <= pat[i]:
|
||||
match = 1
|
||||
i = i+1
|
||||
if match = exclude:
|
||||
if i >= n or pat[i] == ']':
|
||||
break
|
||||
if match == exclude:
|
||||
return 0
|
||||
return fnmatch1(rest, pat[i+1:])
|
||||
else:
|
||||
if name[i:i+1] <> c:
|
||||
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):
|
||||
res = []
|
||||
|
||||
@@ -22,15 +22,15 @@ error = 'getopt error'
|
||||
|
||||
def getopt(args, options):
|
||||
list = []
|
||||
while args and args[0][0] = '-' and args[0] <> '-':
|
||||
if args[0] = '--':
|
||||
while args and args[0][0] == '-' and args[0] <> '-':
|
||||
if args[0] == '--':
|
||||
args = args[1:]
|
||||
break
|
||||
optstring, args = args[0][1:], args[1:]
|
||||
while optstring <> '':
|
||||
opt, optstring = optstring[0], optstring[1:]
|
||||
if classify(opt, options): # May raise exception as well
|
||||
if optstring = '':
|
||||
if optstring == '':
|
||||
if not args:
|
||||
raise error, 'option -' + opt + ' requires argument'
|
||||
optstring, args = args[0], args[1:]
|
||||
@@ -42,6 +42,6 @@ def getopt(args, options):
|
||||
|
||||
def classify(opt, options): # Helper to check type of option
|
||||
for i in range(len(options)):
|
||||
if opt = options[i] <> ':':
|
||||
return options[i+1:i+2] = ':'
|
||||
if opt == options[i] <> ':':
|
||||
return options[i+1:i+2] == ':'
|
||||
raise error, 'option -' + opt + ' not recognized'
|
||||
|
||||
@@ -7,7 +7,7 @@ import fnmatch
|
||||
def glob(pathname):
|
||||
if not has_magic(pathname): return [pathname]
|
||||
dirname, basename = path.split(pathname)
|
||||
if dirname[-1:] = '/' and dirname <> '/':
|
||||
if dirname[-1:] == '/' and dirname <> '/':
|
||||
dirname = dirname[:-1]
|
||||
if has_magic(dirname):
|
||||
list = glob(dirname)
|
||||
@@ -34,9 +34,10 @@ def glob1(dirname, pattern):
|
||||
names = posix.listdir(dirname)
|
||||
except posix.error:
|
||||
return []
|
||||
names.sort()
|
||||
result = []
|
||||
for name in names:
|
||||
if name[0] <> '.' or pattern[0] = '.':
|
||||
if name[0] <> '.' or pattern[0] == '.':
|
||||
if fnmatch.fnmatch(name, pattern): result.append(name)
|
||||
return result
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ def ggrep(syntax, pat, filename):
|
||||
prefix = string.rjust(`lineno`, 3) + ': '
|
||||
print prefix + line
|
||||
if 0: # XXX
|
||||
start, end = prog.regs()[0]
|
||||
start, end = prog.regs[0]
|
||||
line = line[:start]
|
||||
if '\t' not in line:
|
||||
prefix = ' ' * (len(prefix) + start)
|
||||
|
||||
@@ -69,7 +69,7 @@ def stretch(s, a, b):
|
||||
ib = ib+b
|
||||
if i >= m:
|
||||
break
|
||||
if ib = ja:
|
||||
if ib == ja:
|
||||
out.append(y[i])
|
||||
else:
|
||||
out.append((y[i]*(ja-(ib-b)) + y[i-1]*(ib-ja)) / b)
|
||||
|
||||
@@ -49,7 +49,7 @@ def parse_forms(filename):
|
||||
def _open_formfile(filename):
|
||||
if filename[-3:] <> '.fd':
|
||||
filename = filename + '.fd'
|
||||
if filename[0] = '/':
|
||||
if filename[0] == '/':
|
||||
try:
|
||||
fp = open(filename,'r')
|
||||
except IOError:
|
||||
@@ -62,7 +62,7 @@ def _open_formfile(filename):
|
||||
break
|
||||
except IOError:
|
||||
fp = None
|
||||
if fp = None:
|
||||
if fp == None:
|
||||
raise error, 'Cannot find forms file ' + filename
|
||||
return fp
|
||||
|
||||
@@ -77,7 +77,7 @@ def _parse_fd_header(file):
|
||||
# Now skip until we know number of forms
|
||||
while 1:
|
||||
datum = _parse_1_line(file)
|
||||
if type(datum) = type(()) and datum[0] = 'Numberofforms':
|
||||
if type(datum) == type(()) and datum[0] == 'Numberofforms':
|
||||
break
|
||||
return datum[1]
|
||||
#
|
||||
@@ -89,7 +89,7 @@ def _parse_fd_form(file, name):
|
||||
if datum <> FORMLINE:
|
||||
raise error, 'Missing === FORM === line'
|
||||
form = _parse_object(file)
|
||||
if form.Name = name or name = None:
|
||||
if form.Name == name or name == None:
|
||||
objs = []
|
||||
for j in range(form.Numberofobjects):
|
||||
obj = _parse_object(file)
|
||||
@@ -147,7 +147,7 @@ def _parse_line(line):
|
||||
if not a:
|
||||
return line
|
||||
name = line[:a[1][1]]
|
||||
if name[0] = 'N':
|
||||
if name[0] == 'N':
|
||||
name = string.joinfields(string.split(name),'')
|
||||
name = string.lower(name)
|
||||
name = string.upper(name[0]) + name[1:]
|
||||
@@ -167,7 +167,7 @@ def _readline(file):
|
||||
|
||||
def _parse_1_line(file):
|
||||
line = _readline(file)
|
||||
while line = '':
|
||||
while line == '':
|
||||
line = _readline(file)
|
||||
return _parse_line(line)
|
||||
|
||||
@@ -176,7 +176,7 @@ def _skip_object(file):
|
||||
while not line in (SPLITLINE, FORMLINE, ENDLINE):
|
||||
pos = file.tell()
|
||||
line = _readline(file)
|
||||
if line = FORMLINE:
|
||||
if line == FORMLINE:
|
||||
file.seek(pos)
|
||||
|
||||
def _parse_object(file):
|
||||
@@ -185,7 +185,7 @@ def _parse_object(file):
|
||||
pos = file.tell()
|
||||
datum = _parse_1_line(file)
|
||||
if datum in (SPLITLINE, FORMLINE, ENDLINE):
|
||||
if datum = FORMLINE:
|
||||
if datum == FORMLINE:
|
||||
file.seek(pos)
|
||||
return obj
|
||||
if type(datum) <> type(()):
|
||||
@@ -266,27 +266,27 @@ def _create_object(form, odata):
|
||||
# Internal crfunc: helper function that returns correct create function
|
||||
#
|
||||
def _select_crfunc(fm, cl):
|
||||
if cl = FL.BEGIN_GROUP: return fm.bgn_group
|
||||
elif cl = FL.END_GROUP: return fm.end_group
|
||||
elif cl = FL.BITMAP: return fm.add_bitmap
|
||||
elif cl = FL.BOX: return fm.add_box
|
||||
elif cl = FL.BROWSER: return fm.add_browser
|
||||
elif cl = FL.BUTTON: return fm.add_button
|
||||
elif cl = FL.CHART: return fm.add_chart
|
||||
elif cl = FL.CHOICE: return fm.add_choice
|
||||
elif cl = FL.CLOCK: return fm.add_clock
|
||||
elif cl = FL.COUNTER: return fm.add_counter
|
||||
elif cl = FL.DIAL: return fm.add_dial
|
||||
elif cl = FL.FREE: return fm.add_free
|
||||
elif cl = FL.INPUT: return fm.add_input
|
||||
elif cl = FL.LIGHTBUTTON: return fm.add_lightbutton
|
||||
elif cl = FL.MENU: return fm.add_menu
|
||||
elif cl = FL.POSITIONER: return fm.add_positioner
|
||||
elif cl = FL.ROUNDBUTTON: return fm.add_roundbutton
|
||||
elif cl = FL.SLIDER: return fm.add_slider
|
||||
elif cl = FL.VALSLIDER: return fm.add_valslider
|
||||
elif cl = FL.TEXT: return fm.add_text
|
||||
elif cl = FL.TIMER: return fm.add_timer
|
||||
if cl == FL.BEGIN_GROUP: return fm.bgn_group
|
||||
elif cl == FL.END_GROUP: return fm.end_group
|
||||
elif cl == FL.BITMAP: return fm.add_bitmap
|
||||
elif cl == FL.BOX: return fm.add_box
|
||||
elif cl == FL.BROWSER: return fm.add_browser
|
||||
elif cl == FL.BUTTON: return fm.add_button
|
||||
elif cl == FL.CHART: return fm.add_chart
|
||||
elif cl == FL.CHOICE: return fm.add_choice
|
||||
elif cl == FL.CLOCK: return fm.add_clock
|
||||
elif cl == FL.COUNTER: return fm.add_counter
|
||||
elif cl == FL.DIAL: return fm.add_dial
|
||||
elif cl == FL.FREE: return fm.add_free
|
||||
elif cl == FL.INPUT: return fm.add_input
|
||||
elif cl == FL.LIGHTBUTTON: return fm.add_lightbutton
|
||||
elif cl == FL.MENU: return fm.add_menu
|
||||
elif cl == FL.POSITIONER: return fm.add_positioner
|
||||
elif cl == FL.ROUNDBUTTON: return fm.add_roundbutton
|
||||
elif cl == FL.SLIDER: return fm.add_slider
|
||||
elif cl == FL.VALSLIDER: return fm.add_valslider
|
||||
elif cl == FL.TEXT: return fm.add_text
|
||||
elif cl == FL.TIMER: return fm.add_timer
|
||||
else:
|
||||
raise error, 'Unknown object type: ' + `cl`
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ debug = 0
|
||||
# Test if an object is a list.
|
||||
#
|
||||
def is_list(x):
|
||||
return type(x) = type([])
|
||||
return type(x) == type([])
|
||||
|
||||
|
||||
# Reverse a list.
|
||||
@@ -34,7 +34,7 @@ def reverse(list):
|
||||
#
|
||||
def getattrlist(list, name):
|
||||
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 []
|
||||
|
||||
@@ -43,8 +43,8 @@ def getattrlist(list, name):
|
||||
#
|
||||
def getproplist(list, name):
|
||||
for item in list:
|
||||
if item and is_list(item) and item[0] = 'prop':
|
||||
if len(item) > 1 and item[1] = name:
|
||||
if item and is_list(item) and item[0] == 'prop':
|
||||
if len(item) > 1 and item[1] == name:
|
||||
return item[2:]
|
||||
return []
|
||||
|
||||
@@ -53,7 +53,7 @@ def getproplist(list, name):
|
||||
#
|
||||
def is_endgroup(list):
|
||||
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
|
||||
@@ -63,13 +63,13 @@ def show_actuator(prefix, a):
|
||||
for item in a:
|
||||
if not is_list(item):
|
||||
print prefix, item
|
||||
elif item and item[0] = 'al':
|
||||
elif item and item[0] == 'al':
|
||||
print prefix, 'Subactuator list:'
|
||||
for a in item[1:]:
|
||||
show_actuator(prefix + ' ', a)
|
||||
elif len(item) = 2:
|
||||
elif len(item) == 2:
|
||||
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 item[2]
|
||||
else:
|
||||
@@ -82,13 +82,13 @@ def show_panel(prefix, p):
|
||||
for item in p:
|
||||
if not is_list(item):
|
||||
print prefix, item
|
||||
elif item and item[0] = 'al':
|
||||
elif item and item[0] == 'al':
|
||||
print prefix, 'Actuator list:'
|
||||
for a in item[1:]:
|
||||
show_actuator(prefix + ' ', a)
|
||||
elif len(item) = 2:
|
||||
elif len(item) == 2:
|
||||
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 item[2]
|
||||
else:
|
||||
@@ -112,14 +112,14 @@ def dummy_callback(arg):
|
||||
#
|
||||
def assign_members(target, attrlist, exclist, prefix):
|
||||
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]
|
||||
ok = 1
|
||||
if value[0] in '-0123456789':
|
||||
value = eval(value)
|
||||
elif value[0] = '"':
|
||||
elif value[0] == '"':
|
||||
value = value[1:-1]
|
||||
elif value = 'move-then-resize':
|
||||
elif value == 'move-then-resize':
|
||||
# Strange default set by Panel Editor...
|
||||
ok = 0
|
||||
else:
|
||||
@@ -148,7 +148,7 @@ def build_actuator(descr):
|
||||
else:
|
||||
actuatorname = ''
|
||||
type = descr[0]
|
||||
if type[:4] = 'pnl_': type = type[4:]
|
||||
if type[:4] == 'pnl_': type = type[4:]
|
||||
act = pnl.mkact(type)
|
||||
act.downfunc = act.activefunc = act.upfunc = dummy_callback
|
||||
#
|
||||
@@ -158,9 +158,9 @@ def build_actuator(descr):
|
||||
#
|
||||
datalist = getattrlist(descr, 'data')
|
||||
prefix = ''
|
||||
if type[-4:] = 'puck':
|
||||
if type[-4:] == 'puck':
|
||||
prefix = 'puck_'
|
||||
elif type = 'mouse':
|
||||
elif type == 'mouse':
|
||||
prefix = 'mouse_'
|
||||
assign_members(act, datalist, [], prefix)
|
||||
#
|
||||
|
||||
@@ -20,16 +20,16 @@ def tokenize_string(s):
|
||||
c = s[:1]
|
||||
if c in whitespace:
|
||||
s = s[1:]
|
||||
elif c = ';':
|
||||
elif c == ';':
|
||||
s = ''
|
||||
elif c = '"':
|
||||
elif c == '"':
|
||||
n = len(s)
|
||||
i = 1
|
||||
while i < n:
|
||||
c = s[i]
|
||||
i = i+1
|
||||
if c = '"': break
|
||||
if c = '\\': i = i+1
|
||||
if c == '"': break
|
||||
if c == '\\': i = i+1
|
||||
tokens.append(s[:i])
|
||||
s = s[i:]
|
||||
elif c in operators:
|
||||
@@ -78,9 +78,9 @@ def parse_expr(tokens):
|
||||
while 1:
|
||||
if not tokens:
|
||||
raise syntax_error, 'missing ")"'
|
||||
if tokens[0] = ')':
|
||||
if tokens[0] == ')':
|
||||
return expr, tokens[1:]
|
||||
elif tokens[0] = '(':
|
||||
elif tokens[0] == '(':
|
||||
subexpr, tokens = parse_expr(tokens)
|
||||
expr.append(subexpr)
|
||||
else:
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user