"Fossies" - the Fresh Open Source Software Archive

Member "reportlab-3.5.23/src/reportlab/graphics/samples/runall.py" (26 Mar 2014, 1970 Bytes) of package /linux/privat/reportlab-3.5.23.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. For more information about "runall.py" see the Fossies "Dox" file reference documentation.

    1 # runs all the GUIedit charts in this directory -
    2 # makes a PDF sample for eaxh existing chart type
    3 import sys
    4 import glob
    5 import inspect
    6 import types
    7 
    8 def moduleClasses(mod):
    9     def P(obj, m=mod.__name__, CT=type):
   10         return (type(obj)==CT and obj.__module__==m)
   11     try:
   12         return inspect.getmembers(mod, P)[0][1]
   13     except:
   14         return None
   15 
   16 def getclass(f):
   17     return moduleClasses(__import__(f))
   18 
   19 def run(format, VERBOSE=0):
   20     formats = format.split( ',')
   21     for i in range(0, len(formats)):
   22         formats[i] == formats[i].strip().lower()
   23     allfiles = glob.glob('*.py')
   24     allfiles.sort()
   25     for fn in allfiles:
   26         f = fn.split('.')[0]
   27         c = getclass(f)
   28         if c != None:
   29             print(c.__name__)
   30             try:
   31                 for fmt in formats:
   32                     if fmt:
   33                         c().save(formats=[fmt],outDir='.',fnRoot=c.__name__)
   34                         if VERBOSE:
   35                             print("  %s.%s" % (c.__name__, fmt))
   36             except:
   37                 print("  COULDN'T CREATE '%s.%s'!" % (c.__name__, format))
   38 
   39 if __name__ == "__main__":
   40     if len(sys.argv) == 1:
   41         run('pdf,pict,png')
   42     else:
   43         try:
   44             if sys.argv[1] == "-h":
   45                 print('usage: runall.py [FORMAT] [-h]')
   46                 print('   if format is supplied is should be one or more of pdf,gif,eps,png etc')
   47                 print('   if format is missing the following formats are assumed: pdf,pict,png')
   48                 print('   -h prints this message')
   49             else:
   50                 t = sys.argv[1:]
   51                 for f in t:
   52                     run(f)
   53         except:
   54             print('usage: runall.py [FORMAT][-h]')
   55             print('   if format is supplied is should be one or more of pdf,gif,eps,png etc')
   56             print('   if format is missing the following formats are assumed: pdf,pict,png')
   57             print('   -h prints this message')
   58             raise