コード例 #1
0
 def get_input(self, more=False):
     """Prompts for code input."""
     try:
         return self.prompt.input(more)
     except KeyboardInterrupt:
         printerr("\nKeyboardInterrupt")
     except EOFError:
         print()
         self.exit_runner()
     return None
コード例 #2
0
ファイル: command.py プロジェクト: Boscillator/coconut
 def get_input(self, more=False):
     """Prompts for code input."""
     try:
         return self.prompt.input(more)
     except KeyboardInterrupt:
         printerr("\nKeyboardInterrupt")
     except EOFError:
         print()
         self.exit_runner()
     return None
コード例 #3
0
ファイル: mypy.py プロジェクト: pyzh/coconut
def mypy_run(args):
    """Runs mypy with given arguments and shows the result."""
    try:
        stdout, stderr, exit_code = run(args)
    except BaseException:
        printerr(traceback.format_exc())
    else:
        for line in stdout.splitlines():
            yield line, False
        for line in stderr.splitlines():
            yield line, True
コード例 #4
0
ファイル: command.py プロジェクト: CS121Fresh/compiler
 def start_prompt(self):
     """Start the interpreter."""
     logger.show("Coconut Interpreter:")
     logger.show("(type 'exit()' or press Ctrl-D to end)")
     self.start_running()
     while self.running:
         try:
             code = self.get_input()
             if code:
                 compiled = self.handle_input(code)
                 if compiled:
                     self.execute(compiled, use_eval=None)
         except KeyboardInterrupt:
             printerr("\nKeyboardInterrupt")
コード例 #5
0
ファイル: command.py プロジェクト: CS121Fresh/compiler
 def handling_exceptions(self):
     """Perform proper exception handling."""
     try:
         with handling_broken_process_pool():
             yield
     except SystemExit as err:
         self.register_error(err.code)
     except BaseException as err:
         if isinstance(err, CoconutException):
             logger.display_exc()
         elif not isinstance(err, KeyboardInterrupt):
             traceback.print_exc()
             printerr(report_this_text)
         self.register_error(errmsg=err.__class__.__name__)
コード例 #6
0
ファイル: command.py プロジェクト: zhenyulin/coconut
 def run_mypy(self, paths=(), code=None):
     """Run MyPy with arguments."""
     if self.mypy:
         set_mypy_path(stub_dir)
         from coconut.command.mypy import mypy_run
         args = list(paths) + self.mypy_args
         if code is not None:
             args += ["-c", code]
         for line, is_err in mypy_run(args):
             if code is None or line not in self.mypy_errs:
                 printerr(line)
             if line not in self.mypy_errs:
                 self.mypy_errs.append(line)
             self.register_error(errmsg="MyPy error")
コード例 #7
0
ファイル: command.py プロジェクト: evhub/coconut
 def start_prompt(self):
     """Start the interpreter."""
     logger.show("Coconut Interpreter:")
     logger.show("(type 'exit()' or press Ctrl-D to end)")
     self.start_running()
     while self.running:
         try:
             code = self.get_input()
             if code:
                 compiled = self.handle_input(code)
                 if compiled:
                     self.execute(compiled, use_eval=None)
         except KeyboardInterrupt:
             printerr("\nKeyboardInterrupt")
コード例 #8
0
ファイル: command.py プロジェクト: pyzh/coconut
 def get_input(self, more=False):
     """Prompts for code input."""
     received = None
     try:
         received = self.prompt.input(more)
     except KeyboardInterrupt:
         printerr("\nKeyboardInterrupt")
     except EOFError:
         print()
         self.exit_runner()
     else:
         if received.startswith(exit_chars):
             self.exit_runner()
             received = None
     return received
コード例 #9
0
ファイル: command.py プロジェクト: Boscillator/coconut
 def run_mypy(self, paths=[], code=None):
     """Run MyPy with arguments."""
     set_mypy_path(stub_dir)
     if self.mypy:
         from coconut.command.mypy import mypy_run
         args = paths + self.mypy_args
         if code is not None:
             args += ["-c", code]
         for line, is_err in mypy_run(args):
             if code is None or line not in self.mypy_errs:
                 if is_err:
                     printerr(line)
                 else:
                     print(line)
             if line not in self.mypy_errs:
                 self.mypy_errs.append(line)
コード例 #10
0
ファイル: command.py プロジェクト: pyzh/coconut
 def run_mypy(self, paths=[], code=None):
     """Run MyPy with arguments."""
     set_mypy_path(stub_dir)
     if self.mypy:
         from coconut.command.mypy import mypy_run
         args = paths + self.mypy_args
         if code is not None:
             args += ["-c", code]
         for line, is_err in mypy_run(args):
             if code is None or line not in self.mypy_errs:
                 if is_err:
                     printerr(line)
                 else:
                     print(line)
             if line not in self.mypy_errs:
                 self.mypy_errs.append(line)
コード例 #11
0
ファイル: command.py プロジェクト: evhub/coconut
 def get_input(self, more=False):
     """Prompt for code input."""
     received = None
     try:
         received = self.prompt.input(more)
     except KeyboardInterrupt:
         print()
         printerr("KeyboardInterrupt")
     except EOFError:
         print()
         self.exit_runner()
     else:
         if received.startswith(exit_chars):
             self.exit_runner()
             received = None
     return received
コード例 #12
0
ファイル: command.py プロジェクト: evhub/coconut
 def handling_exceptions(self):
     """Perform proper exception handling."""
     try:
         if self.using_jobs:
             with handling_broken_process_pool():
                 yield
         else:
             yield
     except SystemExit as err:
         self.register_error(err.code)
     except BaseException as err:
         if isinstance(err, CoconutException):
             logger.display_exc()
         elif not isinstance(err, KeyboardInterrupt):
             traceback.print_exc()
             printerr(report_this_text)
         self.register_error(errmsg=err.__class__.__name__)