]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Standardize indentation to 8 chars; remove redundant "saveframe";
authorGuido van Rossum <guido@python.org>
Wed, 6 May 1992 17:58:34 +0000 (17:58 +0000)
committerGuido van Rossum <guido@python.org>
Wed, 6 May 1992 17:58:34 +0000 (17:58 +0000)
add -s (short listing) option; don't print space after tab;
print data size in bytes and whether it
is a color image.

Demo/sgi/video/vinfo.py

index 6f8b54341ec9fa7f13af801c900ce6f4ef2ee227..f34f574c717454c29fe491949fa19e61d502ae81 100755 (executable)
@@ -11,43 +11,43 @@ EndOfFile = 'End of file'
 bye = 'bye'
 
 def openvideo(filename):
-    f = open(filename, 'r')
-    line = f.readline()
-    if not line: raise EndOfFile
-    if line[:4] == 'CMIF': line = f.readline()
-    x = eval(line[:-1])
-    if len(x) == 3: w, h, pf = x
-    else: w, h = x; pf = 2
-    return f, w, h, pf
+       f = open(filename, 'r')
+       line = f.readline()
+       if not line: raise EndOfFile
+       if line[:4] == 'CMIF': line = f.readline()
+       x = eval(line[:-1])
+       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 == '':
-       raise EndOfFile
-    x = eval(line[:-1])
-    if type(x) == type(0) or type(x) == type(0.0):
-       tijd = x
-       if pf == 0:
-               size = w*h*4
-       else:
-               size = (w/pf) * (h/pf)
-    else:
-       tijd, size = x
-    f.seek(size, 1)
-    return tijd
-
-def saveframe(name, w, h, tijd, data):
-    f = open(name, 'w')
-    f.write(`w,h` + '\n')
-    f.write(`tijd` + '\n')
-    f.write(data)
-    f.close()
+       line = f.readline()
+       if line == '':
+               raise EndOfFile
+       x = eval(line[:-1])
+       if type(x) == type(0) or type(x) == type(0.0):
+               tijd = x
+               if pf == 0:
+                       size = w*h*4
+               else:
+                       size = (w/pf) * (h/pf)
+       else:
+               tijd, size = x
+       f.seek(size, 1)
+       return tijd
 
 def main():
        delta = 0
-       opts, names = getopt.getopt(sys.argv[1:], 'd')
+       short = 0
+       try:
+               opts, names = getopt.getopt(sys.argv[1:], 'ds')
+       except getopt.error, msg:
+               sys.stderr.write(msg + '\n')
+               sys.stderr.write('usage: vinfo [-d] [-s] [file] ...\n')
+               sys.exit(2)
        for opt, arg in opts:
-               if opt == '-d': delta = 1
+               if opt == '-d': delta = 1       # print delta between frames
+               elif opt == '-s': short = 1     # short: don't print times
        if names == []:
                names = ['film.video']
        for name in names:
@@ -56,15 +56,21 @@ def main():
            except:
                sys.stderr.write(name + ': cannot open\n')
                continue
-           print name, ':', w, 'x', h, '; pf =', pf
+           if pf == 0:
+               size = w*h*4
+           else:
+               size = (w/pf) * (h/pf)
+           print name, ':', w, 'x', h, '; pf =', pf, ', size =', size,
+           if pf == 0: print '(color)',
+           print
            num = 0
            try:
                otijd = 0
-               while 1:
+               while not short:
                    try:
                        tijd = loadframe(f, w, h, pf)
-                       if delta: print '\t', tijd-otijd,
-                       else: print '\t', tijd,
+                       if delta: print '\t' + `tijd-otijd`,
+                       else: print '\t' + `tijd`,
                        otijd = tijd
                        num = num + 1
                        if num % 8 == 0: