0001
0002
0003import os, sys
0004import optparse
0005
0006try:
0007 here = __file__
0008except NameError:
0009 here = sys.argv[0]
0010
0011parser = optparse.OptionParser(usage='%prog [OPTIONS]')
0012parser.add_option(
0013 '-c', '--console',
0014 help="Run the interpreter in the console (not the GUI)",
0015 action="store_true",
0016 dest="console")
0017parser.add_option(
0018 '-q', '--quit',
0019 help="Quit after loading and running files",
0020 action="store_true",
0021 dest="quit_after")
0022parser.add_option(
0023 '--doctest',
0024 help="Doctest the given (text) files",
0025 action="store_true",
0026 dest="doctest")
0027
0028from pylogo import Logo
0029
0030def main():
0031 doit(sys.argv[1:])
0032
0033def doit(args):
0034 options, filenames = parser.parse_args(args)
0035 if options.doctest:
0036 from pylogo.logodoctest import testfile
0037 import doctest
0038 for fn in filenames:
0039 print '-- Testing %s %s' % (fn, '-'*(40-len(fn)))
0040 testfile(fn, optionflags=doctest.ELLIPSIS,
0041 verbose_summary=True,
0042 interp=Logo)
0043 else:
0044 for fn in filenames:
0045 Logo.import_logo(filename)
0046 if options.quit_after:
0047 return
0048 if options.console:
0049 Logo.input_loop(sys.stdin, sys.stdout)
0050 else:
0051 from pylogo import ide
0052 ide.main()