runall.py 1.9 KB

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