home *** CD-ROM | disk | FTP | other *** search
/ PC World 2002 May / PCWorld_2002-05_cd.bin / Software / TemaCD / activepython / ActivePython-2.1.1.msi / Python21_Tools_compiler_compile.py < prev    next >
Encoding:
Python Source  |  2001-07-26  |  825 b   |  32 lines

  1. import sys
  2. import getopt
  3.  
  4. from compiler import compile, visitor
  5.  
  6. def main():
  7.     VERBOSE = 0
  8.     DISPLAY = 0
  9.     opts, args = getopt.getopt(sys.argv[1:], 'vqd')
  10.     for k, v in opts:
  11.         if k == '-v':
  12.             VERBOSE = 1
  13.             visitor.ASTVisitor.VERBOSE = visitor.ASTVisitor.VERBOSE + 1
  14.         if k == '-q':
  15.             if sys.platform[:3]=="win":
  16.                 f = open('nul', 'wb') # /dev/null fails on Windows...
  17.             else:
  18.                 f = open('/dev/null', 'wb')
  19.             sys.stdout = f
  20.         if k == '-d':
  21.             DISPLAY = 1
  22.     if not args:
  23.         print "no files to compile"
  24.     else:
  25.         for filename in args:
  26.             if VERBOSE:
  27.                 print filename
  28.             compile(filename, DISPLAY)
  29.  
  30. if __name__ == "__main__":
  31.     main()
  32.