src/reportlab/graphics/samples/runall.py
branchpy33
changeset 3721 0c93dd8ff567
parent 2964 32352db0d71e
child 3794 398ea04239b5
equal deleted inserted replaced
3720:7a059dde5bf5 3721:0c93dd8ff567
     5 import string
     5 import string
     6 import inspect
     6 import inspect
     7 import types
     7 import types
     8 
     8 
     9 def moduleClasses(mod):
     9 def moduleClasses(mod):
    10     def P(obj, m=mod.__name__, CT=types.ClassType):
    10     def P(obj, m=mod.__name__, CT=type):
    11         return (type(obj)==CT and obj.__module__==m)
    11         return (type(obj)==CT and obj.__module__==m)
    12     try:
    12     try:
    13         return inspect.getmembers(mod, P)[0][1]
    13         return inspect.getmembers(mod, P)[0][1]
    14     except:
    14     except:
    15         return None
    15         return None
    25     allfiles.sort()
    25     allfiles.sort()
    26     for fn in allfiles:
    26     for fn in allfiles:
    27         f = string.split(fn, '.')[0]
    27         f = string.split(fn, '.')[0]
    28         c = getclass(f)
    28         c = getclass(f)
    29         if c != None:
    29         if c != None:
    30             print c.__name__
    30             print(c.__name__)
    31             try:
    31             try:
    32                 for fmt in formats:
    32                 for fmt in formats:
    33                     if fmt:
    33                     if fmt:
    34                         c().save(formats=[fmt],outDir='.',fnRoot=c.__name__)
    34                         c().save(formats=[fmt],outDir='.',fnRoot=c.__name__)
    35                         if VERBOSE:
    35                         if VERBOSE:
    36                             print "  %s.%s" % (c.__name__, fmt)
    36                             print("  %s.%s" % (c.__name__, fmt))
    37             except:
    37             except:
    38                 print "  COULDN'T CREATE '%s.%s'!" % (c.__name__, format)
    38                 print("  COULDN'T CREATE '%s.%s'!" % (c.__name__, format))
    39 
    39 
    40 if __name__ == "__main__":
    40 if __name__ == "__main__":
    41     if len(sys.argv) == 1:
    41     if len(sys.argv) == 1:
    42         run('pdf,pict,png')
    42         run('pdf,pict,png')
    43     else:
    43     else:
    44         try:
    44         try:
    45             if sys.argv[1] == "-h":
    45             if sys.argv[1] == "-h":
    46                 print 'usage: runall.py [FORMAT] [-h]'
    46                 print('usage: runall.py [FORMAT] [-h]')
    47                 print '   if format is supplied is should be one or more of pdf,gif,eps,png etc'
    47                 print('   if format is supplied is should be one or more of pdf,gif,eps,png etc')
    48                 print '   if format is missing the following formats are assumed: pdf,pict,png'
    48                 print('   if format is missing the following formats are assumed: pdf,pict,png')
    49                 print '   -h prints this message'
    49                 print('   -h prints this message')
    50             else:
    50             else:
    51                 t = sys.argv[1:]
    51                 t = sys.argv[1:]
    52                 for f in t:
    52                 for f in t:
    53                     run(f)
    53                     run(f)
    54         except:
    54         except:
    55             print 'usage: runall.py [FORMAT][-h]'
    55             print('usage: runall.py [FORMAT][-h]')
    56             print '   if format is supplied is should be one or more of pdf,gif,eps,png etc'
    56             print('   if format is supplied is should be one or more of pdf,gif,eps,png etc')
    57             print '   if format is missing the following formats are assumed: pdf,pict,png'
    57             print('   if format is missing the following formats are assumed: pdf,pict,png')
    58             print '   -h prints this message'
    58             print('   -h prints this message')
    59             raise
    59             raise