コード例 #1
0
ファイル: hyperj.py プロジェクト: Synthetica9/HyperJ
def main():
    import commandline_args
    args = commandline_args.parser.parse_args()
    flags = args.__dict__
    if args.debug >= 7:
        print 'Arguments namespace: '
        print repr(args)
    if args.infile is None:
        import console
        console.main(**flags)
    else:
        import lexer
        raw_code = open(args.infile).read()
        lexed = lexer.lexer(raw_code, **flags)

        import dissecter
        solved = dissecter.parser(lexed, **flags)

        import semi_assembly_generator
        semi_assembly = semi_assembly_generator.single_op(solved, **flags)

        if args.outfile == 'stdout':
            outfile = sys.stdout
        else:
            if args.outfile is None:
                args.outfile = args.infile + '.out'
            outfile = open(args.outfile, 'w')
        outfile.write('\n'.join(map(str, semi_assembly)))
コード例 #2
0
ファイル: othello.py プロジェクト: xpheal/Othello
def main():
	parser = argparse.ArgumentParser(description='Othello game')
	parser.add_argument('-c', action='store_true', help='Run othello game in the console, if not specified, will run in GUI')
	args = parser.parse_args()

	# Size of the board
	size = 8

	if args.c:
		# Run in console
		print("Othello: ")
		opt = input("Do you want to start first, 'y' or 'n': ")

		if opt.lower() == 'y':
			# Player 1 starts first
			player1 = Player("BLACK", Cell.B)
			player2 = AI_Random("AI_RANDOM", Cell.W)
			cs.main(size, player1, player2)
		elif opt.lower() == 'n':
			# AI starts first
			player1 = AI_Random("AI_RANDOM", Cell.B)
			player2 = Player("WHITE", Cell.W)
			cs.main(size, player1, player2)
		else:
			print("Wrong input, try again, exiting")
	else:
		# Run using Tkinter GUI
		player1 = Player("BLACK", Cell.B)
		player2 = Player("WHITE", Cell.W)
		gui = GUI(size, player1, player2)
		gui.run()
コード例 #3
0
    def download(self):
        self.urls = []
        self.extract_text.delete(0.0, 'end')
        self.download_text.delete(0.0, 'end')

        self.extract_url()
        for url in self.urls:
            main(url, download_text=self.download_text)
コード例 #4
0
def console(args):
    if not only(args, {"console"}):
        print("Error: Expected only --console, no other options")
        sys.exit(1)

    # Save PEP 3122!
    if "." in __name__:
        from . import console
    else:
        import console

    # @@ suppress the load warnings
    console.main()
コード例 #5
0
ファイル: gui.py プロジェクト: owerbat/Cubic_Spline
    def solve(self):
        try:
            file = open('dots.txt', 'w', encoding='utf-8')
        except FileNotFoundError:
            print("Dots file is nor founded")
            exit(2)

        for i in range(8):
            x = self.x_entries[i].get()
            y = self.y_entries[i].get()
            if x != '' and y != '':
                if x_check(x, i, self.x_entries):
                    file.write(x + ' ' + y + '\n')
                else:
                    messagebox.showinfo('Error',
                                        'All points must have different x')
                    raise ValueError

        file.close()

        console.main()
コード例 #6
0
import console
import host
import sys

if len(sys.argv) < 2:
    print("Usage: main.py <console|host>")
else:
    if sys.argv[1] == "console":
        console.main()
    elif sys.argv[1] == "host":
        host.main()
    else:
        print("Unknown argument '" + sys.argv[1] +
              "'. Usage: main.py <console|host>")
コード例 #7
0
ファイル: runConsole.py プロジェクト: CafeGIS/gvSIG2_0
from console import main
main()
コード例 #8
0
ファイル: __main__.py プロジェクト: pavanad/openredragon
import sys

if __name__ == "__main__":
    from console import main

    sys.exit(main())
コード例 #9
0
import console
if __name__ == '__main__':
    print("Enter user name")
    username = str(input())
    print("Enter password")
    password = str(input())
    console.main(username, password)
コード例 #10
0
 def submit(self, *_):
     line = self.input.input()
     self.output.print_echo(line)
     console.main(line, self.output.print_out,
                  lambda x: (self.output.print_err(x), self.status.read_err(x)),
                  self.op_list)
コード例 #11
0
 def __init__(self, master):
     self.master = master
     self.frame = tkinter.Frame(self.master.frame, background='#DDF')
     self.drg_mode = tkinter.StringVar()
     self.drg_mode.set('DEG')
     self.dms_mode = tkinter.StringVar()
     self.dms_mode.set('POINT')
     self.drg_button = tkinter.Button(self.frame, font=('consolas', 12, 'bold'), width=5, background='#CCE',
                                      foreground='#000', borderwidth=0, highlightthickness=1,
                                      textvariable=self.drg_mode,
                                      command=lambda: (console.main({'DEG': 'rad',
                                                                     'RAD': 'grad',
                                                                     'GRAD': 'deg'}[self.drg_mode.get()],
                                                                    self.master.output.print_err,
                                                                    self.read_err,
                                                                    self.master.op_list))
                                      )
     self.dms_button = tkinter.Button(self.frame, font=('consolas', 12, 'bold'), width=5, background='#CCE',
                                      foreground='#000', borderwidth=0, highlightthickness=1,
                                      textvariable=self.dms_mode,
                                      command=lambda: (console.main('dms', self.master.output.print_err,
                                                                    self.read_err,
                                                                    self.master.op_list))
                                      )
     self.prec_text = tkinter.StringVar(value='PRECISION 50')
     self.prec_button = tkinter.Button(self.frame, font=('consolas', 12, 'bold'), width=13, background='#CCE',
                                       foreground='#000', borderwidth=0, highlightthickness=1,
                                       textvariable=self.prec_text,
                                       command=lambda: (console.main('prec %d' %
                                                                     ((int(self.prec_text.get()[10:]) + 4) % 50 + 1),
                                                                     self.master.output.print_err,
                                                                     self.read_err, self.master.op_list))
                                       )
     self.center_label = tkinter.Label(self.frame, background='#CCE', highlightthickness=0, width=23)
     self.output_height = tkinter.StringVar()
     self.output_height.set('NARROW CONSOLE')
     self.output_height_button = tkinter.Button(self.frame, font=('consolas', 12, 'bold'), width=15,
                                                background='#CCE', foreground='#000', borderwidth=0,
                                                highlightthickness=1,
                                                textvariable=self.output_height,
                                                command=lambda: (
                                                    self.output_height.set(
                                                        {'MEDIUM CONSOLE': 'LARGE CONSOLE',
                                                         'LARGE CONSOLE': 'NARROW CONSOLE',
                                                         'NARROW CONSOLE': 'MEDIUM CONSOLE'
                                                         }[self.output_height.get()]),
                                                    self.master.output.set_height(
                                                        {'MEDIUM CONSOLE': 10,
                                                         'LARGE CONSOLE': 30,
                                                         'NARROW CONSOLE': 3,
                                                         }[self.output_height.get()]),
                                                    self.master.refresh_keyboard()),
                                                )
     self.keyboard_open = tkinter.BooleanVar()
     self.keyboard_open.set(False)
     self.keyboard_button = tkinter.Button(self.frame, image=_get_keyboard_img(), height=27, foreground='#000',
                                           background='#EEE', borderwidth=0, highlightthickness=1,
                                           command=lambda: (
                                           self.keyboard_open.set(not self.keyboard_open.get()),
                                           self.keyboard_button.config(background=(
                                               '#CCE' if self.keyboard_open.get() else '#EEE')),
                                           self.master.close_keyboard() if self.keyboard_open.get()
                                           else self.master.open_keyboard()))
     self.drg_button.grid(row=0, column=0, padx=0, sticky='w')
     self.dms_button.grid(row=0, column=1, padx=0, sticky='w')
     self.prec_button.grid(row=0, column=2, padx=0, sticky='w')
     self.center_label.grid(row=0, column=3, padx=0, sticky='wens')
     self.output_height_button.grid(row=0, column=4, padx=0, sticky='e')
     self.keyboard_button.grid(row=0, column=5, padx=0, sticky='e')