Show DevBest Simple Python Python Compiler

Status
Not open for further replies.

Pro123

New Member
Feb 20, 2011
21
0
Code:
#81ack Interface (C) Under the LGPL license v3 <http://www.gnu.org/licenses/lgpl.txt>

import sys

try:
    import py_compile
except ImportError:
    print 'ERROR: py_compile module not found...'
    sys.exit(0)
else:
    print 'Imported module py_compile...'
try:
    import compileall
except ImportError:
    print 'ERROR: comileall module not found...'
    sys.exit(0)
else:
    print 'Imported module compileall...'

ifd = raw_input('Compile all?{y|n}[n]')
if ifd == 'y' or ifd == 'Y':
    p = raw_input('Directory: ')
    if p != '':
        compileall.compile_dir(p)
        sys.exit(0)
    else:
        print 'ERROR: please specify a directory...'
        sys.exit(0)

p = raw_input('File: ')
try:
    py_compile.compile(p)
except IOError:
    print 'ERROR: file not specified or directory does not exist'
    sys.exit(0)
else:
    print p+' compiled...'
 
Status
Not open for further replies.

Users who are viewing this thread

Top