mirror of https://github.com/python/cpython
new syntax
This commit is contained in:
parent
d61bbb33f7
commit
f47d0485a0
|
@ -23,7 +23,7 @@ if sys.argv[1:]:
|
|||
|
||||
if sys.argv[2:]:
|
||||
HOST = sys.argv[2]
|
||||
if HOST = 'all':
|
||||
if HOST == 'all':
|
||||
HOST = '<broadcast>'
|
||||
MAX = 1400
|
||||
|
||||
|
@ -47,7 +47,7 @@ def main():
|
|||
readsource(SRC_FRAMEGRABBER)
|
||||
|
||||
s = socket(AF_INET, SOCK_DGRAM)
|
||||
if HOST = '<broadcast>':
|
||||
if HOST == '<broadcast>':
|
||||
s.allowbroadcast(1)
|
||||
addr = HOST, PORT
|
||||
|
||||
|
@ -72,7 +72,7 @@ def main():
|
|||
while 1:
|
||||
while qtest():
|
||||
dev, val = qread()
|
||||
if dev = REDRAW:
|
||||
if dev == REDRAW:
|
||||
reshapeviewport()
|
||||
w, h = getsize()
|
||||
ortho2(0, w, 0, h)
|
||||
|
@ -93,7 +93,7 @@ def main():
|
|||
|
||||
fps = 0
|
||||
|
||||
elif dev = ESCKEY:
|
||||
elif dev == ESCKEY:
|
||||
winclose(wid)
|
||||
return
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ def wrheader(f, w, h, pf):
|
|||
f.write('CMIF video 1.0\n')
|
||||
f.write(`w,h,pf` + '\n')
|
||||
print 'width,height,pf:', w, h, pf,
|
||||
if pf = 0: pf = 4
|
||||
if pf == 0: pf = 4
|
||||
print '(i.e.,', w*h*pf, 'bytes/frame)'
|
||||
|
||||
def main():
|
||||
|
@ -103,14 +103,14 @@ def main():
|
|||
austart = 0
|
||||
optlist, args = getopt.getopt(sys.argv[1:],'ca:sp:')
|
||||
for opt, arg in optlist:
|
||||
if opt = '-c':
|
||||
if opt == '-c':
|
||||
pf = 0
|
||||
elif opt = '-a':
|
||||
elif opt == '-a':
|
||||
ausync = 1
|
||||
aumachine = arg
|
||||
elif opt = '-s':
|
||||
elif opt == '-s':
|
||||
austart = 1
|
||||
elif opt = '-p':
|
||||
elif opt == '-p':
|
||||
pf = int(eval(arg))
|
||||
else:
|
||||
usage()
|
||||
|
@ -184,13 +184,13 @@ def main():
|
|||
if qtest() or \
|
||||
not (mousing or inrunning or insingle or outrunning or outsingle):
|
||||
ev, val = qread()
|
||||
if ev = LEFTMOUSE and val = 1:
|
||||
if ev == LEFTMOUSE and val == 1:
|
||||
drawframe(x,y,w,h,0)
|
||||
mousing = 1
|
||||
ox, oy = getorigin()
|
||||
x = getvaluator(MOUSEX)-ox
|
||||
y = getvaluator(MOUSEY)-oy
|
||||
elif ev = LEFTMOUSE and val = 0:
|
||||
elif ev == LEFTMOUSE and val == 0:
|
||||
if h < 0:
|
||||
y, h = y+h, -h
|
||||
if w < 0:
|
||||
|
@ -200,7 +200,7 @@ def main():
|
|||
wrheader(f, w, h, pf)
|
||||
sizewritten = 1
|
||||
prealloc(w, h)
|
||||
elif ev = RKEY and val = 1:
|
||||
elif ev == RKEY and val == 1:
|
||||
if not inrunning:
|
||||
ringbell()
|
||||
else:
|
||||
|
@ -211,7 +211,7 @@ def main():
|
|||
starttime = time.millitimer()
|
||||
if ausync:
|
||||
ctl.sendto(`(1,starttime)`, aua)
|
||||
elif ev = PKEY and val = 1 and outrunning:
|
||||
elif ev == PKEY and val == 1 and outrunning:
|
||||
outrunning = 0
|
||||
stoptime = time.millitimer()
|
||||
if ausync:
|
||||
|
@ -222,11 +222,11 @@ def main():
|
|||
print 'Saving...'
|
||||
saveframes(f, w, h, pf)
|
||||
print 'Done.'
|
||||
elif ev = PKEY and val = 1 and not outrunning:
|
||||
elif ev == PKEY and val == 1 and not outrunning:
|
||||
outsingle = 1
|
||||
elif ev = CKEY and val = 1:
|
||||
elif ev == CKEY and val == 1:
|
||||
inrunning = 1
|
||||
elif ev = SKEY and val = 1:
|
||||
elif ev == SKEY and val == 1:
|
||||
if outrunning:
|
||||
ringbell()
|
||||
elif inrunning:
|
||||
|
@ -237,7 +237,7 @@ def main():
|
|||
if ausync:
|
||||
ctl.sendto(`(2,time.millitimer())`, aua)
|
||||
raise stop
|
||||
elif ev = REDRAW:
|
||||
elif ev == REDRAW:
|
||||
drawframe(x,y,w,h,0)
|
||||
reshapeviewport()
|
||||
drawframe(x,y,w,h,1)
|
||||
|
|
|
@ -96,11 +96,11 @@ def hsv_to_rgb(h,s,v):
|
|||
q = v*(1.0-s*f)
|
||||
t = v*(1.0-s*(1.0-f))
|
||||
if i in (0,6): return v,t,p
|
||||
if i = 1: return q,v,p
|
||||
if i = 2: return p,v,t
|
||||
if i = 3: return p,q,v
|
||||
if i = 4: return t,p,v
|
||||
if i = 5: return v,p,q
|
||||
if i == 1: return q,v,p
|
||||
if i == 2: return p,v,t
|
||||
if i == 3: return p,q,v
|
||||
if i == 4: return t,p,v
|
||||
if i == 5: return v,p,q
|
||||
print i, h, f
|
||||
print h, s, v
|
||||
raise 'Bad color'
|
||||
|
|
|
@ -94,7 +94,7 @@ def packline(line):
|
|||
i, n = 1, len(bytes)
|
||||
while i < n:
|
||||
for pack in (0, 2, 4, 8):
|
||||
if pack = 0:
|
||||
if pack == 0:
|
||||
lo, hi = 0, 0
|
||||
else:
|
||||
hi = pow(2, pack-1)-1
|
||||
|
|
|
@ -70,8 +70,8 @@ def mainloop(ofile, ctl, inp, out, globaltime):
|
|||
# buffer. Discard all buffered data upto his starttime
|
||||
#
|
||||
startstop,histime = eval(ctl.recv(100))
|
||||
if (ofile = None and startstop = 0) or \
|
||||
(ofile <> None and startstop = 1):
|
||||
if (ofile == None and startstop == 0) or \
|
||||
(ofile <> None and startstop == 1):
|
||||
print 'Sync error: saving=',save,' request=',startstop
|
||||
sys.exit(1)
|
||||
filllevel = inp.getfilled()
|
||||
|
@ -89,6 +89,6 @@ def mainloop(ofile, ctl, inp, out, globaltime):
|
|||
print 'Time: ', time.millitimer()-starttime, ', Bytes: ', totbytes, ', Samples: ', totsamps
|
||||
if ofile <> None:
|
||||
ofile.write(data)
|
||||
return (startstop = 2)
|
||||
return (startstop == 2)
|
||||
|
||||
main()
|
||||
|
|
|
@ -44,10 +44,10 @@ def main():
|
|||
while 1:
|
||||
if qtest():
|
||||
dev, val = qread()
|
||||
if dev = ESCKEY:
|
||||
if dev == ESCKEY:
|
||||
winclose(wid)
|
||||
return
|
||||
elif dev = REDRAW:
|
||||
elif dev == REDRAW:
|
||||
oldw, oldh = reshape()
|
||||
elif s.avail():
|
||||
data = s.recv(17000)
|
||||
|
|
|
@ -7,10 +7,10 @@ from DEVICE import *
|
|||
|
||||
def loadframe(f, w, h, pf):
|
||||
line = f.readline()
|
||||
if not line or line = '\n':
|
||||
if not line or line == '\n':
|
||||
raise EOFError
|
||||
x = eval(line[:-1])
|
||||
if type(x) = type(0):
|
||||
if type(x) == type(0):
|
||||
if pf: size = w*h*4
|
||||
else: size = w*h*pf
|
||||
else:
|
||||
|
@ -47,10 +47,10 @@ def main():
|
|||
ofp = open(ofile, 'w')
|
||||
#
|
||||
line = ifp.readline()
|
||||
if line[:4] = 'CMIF':
|
||||
if line[:4] == 'CMIF':
|
||||
line = ifp.readline()
|
||||
x = eval(line[:-1])
|
||||
if len(x) = 3:
|
||||
if len(x) == 3:
|
||||
w, h, pf = x
|
||||
else:
|
||||
w, h = x
|
||||
|
@ -82,11 +82,11 @@ def main():
|
|||
dev, val = qread()
|
||||
if dev in (ESCKEY, WINQUIT, WINSHUT):
|
||||
break
|
||||
if dev = REDRAW:
|
||||
if dev == REDRAW:
|
||||
reshapeviewport()
|
||||
elif dev = KEYBD:
|
||||
elif dev == KEYBD:
|
||||
c = chr(val)
|
||||
if c = 'n':
|
||||
if c == 'n':
|
||||
try:
|
||||
time, data = loadframe(ifp, w, h, pf)
|
||||
iframe = iframe+1
|
||||
|
@ -94,13 +94,13 @@ def main():
|
|||
except EOFError:
|
||||
print 'EOF'
|
||||
ringbell()
|
||||
elif c = 'w':
|
||||
elif c == 'w':
|
||||
ofp.write(`time, len(data)` + '\n')
|
||||
ofp.write(data)
|
||||
print 'Frame', iframe, 'written.'
|
||||
else:
|
||||
print 'Character', `c`, 'ignored'
|
||||
elif dev = INPUTCHANGE:
|
||||
elif dev == INPUTCHANGE:
|
||||
pass
|
||||
else:
|
||||
print '(dev, val) =', (dev, val)
|
||||
|
|
|
@ -31,26 +31,26 @@ def openvideo(name):
|
|||
sys.exit(1)
|
||||
line = f.readline()
|
||||
if not line: raise EndOfFile
|
||||
if line[:4] = 'CMIF':
|
||||
if line[:14] = 'CMIF video 2.0':
|
||||
if line[:4] == 'CMIF':
|
||||
if line[:14] == 'CMIF video 2.0':
|
||||
line = f.readline()
|
||||
colorinfo = eval(line[:-1])
|
||||
else:
|
||||
colorinfo = (8,0,0,0)
|
||||
line = f.readline()
|
||||
x = eval(line[:-1])
|
||||
if len(x) = 3: w, h, pf = x
|
||||
if len(x) == 3: w, h, pf = x
|
||||
else: w, h = x; pf = 2
|
||||
return f, w, h, pf, colorinfo
|
||||
|
||||
def loadframe(f,w,h,pf,af,spkr, (ybits,ibits,qbits,chrompack),mf):
|
||||
line = f.readline()
|
||||
if line = '':
|
||||
if line == '':
|
||||
raise EndOfFile
|
||||
x = eval(line[:-1])
|
||||
if type(x) = type(0) or type(x) = type(0.0):
|
||||
if type(x) == type(0) or type(x) == type(0.0):
|
||||
tijd = x
|
||||
if pf = 0:
|
||||
if pf == 0:
|
||||
size = w*h*4
|
||||
else:
|
||||
size = (w/pf) * (h/pf)
|
||||
|
@ -98,10 +98,10 @@ def initcmap(ybits,ibits,qbits,chrompack):
|
|||
for y in range(maxy):
|
||||
yv = float(y)/float(maxy-1)
|
||||
for i in range(maxi):
|
||||
if maxi = 1: iv = 0
|
||||
if maxi == 1: iv = 0
|
||||
else: iv = (float(i)/float(maxi-1))-0.5
|
||||
for q in range(maxq):
|
||||
if maxq = 1: qv = 0
|
||||
if maxq == 1: qv = 0
|
||||
else: qv = (float(q)/float(maxq-1))-0.5
|
||||
index = 2048 + y + (i << ybits) + (q << (ybits+ibits))
|
||||
rv,gv,bv = colorsys.yiq_to_rgb(yv,iv,qv)
|
||||
|
@ -125,13 +125,13 @@ def main():
|
|||
'[-l] [-p pf] [-m mag] [-F] [moviefile [soundfile [skipbytes]]]\n')
|
||||
sys.exit(2)
|
||||
for opt, arg in opts:
|
||||
if opt = '-m':
|
||||
if opt == '-m':
|
||||
magfactor = int(eval(arg))
|
||||
elif opt = '-p':
|
||||
elif opt == '-p':
|
||||
packfactor = int(eval(arg))
|
||||
elif opt = '-l':
|
||||
elif opt == '-l':
|
||||
looping = 1
|
||||
elif opt = '-F':
|
||||
elif opt == '-F':
|
||||
epoch.correcttiming = 0
|
||||
if args:
|
||||
filename = args[0]
|
||||
|
@ -206,7 +206,7 @@ def main():
|
|||
dev, val = qread()
|
||||
if dev in (ESCKEY, WINSHUT, WINQUIT):
|
||||
raise bye
|
||||
elif dev = REDRAW:
|
||||
elif dev == REDRAW:
|
||||
reshapeviewport()
|
||||
except bye:
|
||||
pass
|
||||
|
|
|
@ -14,20 +14,20 @@ def openvideo(filename):
|
|||
f = open(filename, 'r')
|
||||
line = f.readline()
|
||||
if not line: raise EndOfFile
|
||||
if line[:4] = 'CMIF': line = f.readline()
|
||||
if line[:4] == 'CMIF': line = f.readline()
|
||||
x = eval(line[:-1])
|
||||
if len(x) = 3: w, h, pf = x
|
||||
if len(x) == 3: w, h, pf = x
|
||||
else: w, h = x; pf = 2
|
||||
return f, w, h, pf
|
||||
|
||||
def loadframe(f, w, h, pf):
|
||||
line = f.readline()
|
||||
if line = '':
|
||||
if line == '':
|
||||
raise EndOfFile
|
||||
x = eval(line[:-1])
|
||||
if type(x) = type(0) or type(x) = type(0.0):
|
||||
if type(x) == type(0) or type(x) == type(0.0):
|
||||
tijd = x
|
||||
if pf = 0:
|
||||
if pf == 0:
|
||||
size = w*h*4
|
||||
else:
|
||||
size = (w/pf) * (h/pf)
|
||||
|
@ -47,8 +47,8 @@ def main():
|
|||
delta = 0
|
||||
opts, names = getopt.getopt(sys.argv[1:], 'd')
|
||||
for opt, arg in opts:
|
||||
if opt = '-d': delta = 1
|
||||
if names = []:
|
||||
if opt == '-d': delta = 1
|
||||
if names == []:
|
||||
names = ['film.video']
|
||||
for name in names:
|
||||
try:
|
||||
|
@ -67,7 +67,7 @@ def main():
|
|||
else: print '\t', tijd,
|
||||
otijd = tijd
|
||||
num = num + 1
|
||||
if num % 8 = 0:
|
||||
if num % 8 == 0:
|
||||
print
|
||||
except EndOfFile:
|
||||
raise bye
|
||||
|
|
|
@ -59,7 +59,7 @@ class VTime():
|
|||
print 'Someone else syncing to us: ', other
|
||||
raise bad_connect
|
||||
data = eval(data)
|
||||
if data[:2] = (loopct+1,curtijd):
|
||||
if data[:2] == (loopct+1,curtijd):
|
||||
break
|
||||
if data[0] <> 2:
|
||||
print 'Illegal sync reply: ', data
|
||||
|
@ -83,7 +83,7 @@ class VTime():
|
|||
if data[0] in (0,2):
|
||||
curtijd = time.millitimer()
|
||||
s.sendto(`(data[0]+1,data[1],curtijd)`,raddr)
|
||||
elif data[0] = 4:
|
||||
elif data[0] == 4:
|
||||
newtijd = time.millitimer()
|
||||
histime = data[1]
|
||||
mytime = timeavg(curtijd,newtijd)
|
||||
|
|
Loading…
Reference in New Issue