当前位置: 首页>>代码示例>>Python>>正文


Python sys.ps2方法代码示例

本文整理汇总了Python中sys.ps2方法的典型用法代码示例。如果您正苦于以下问题:Python sys.ps2方法的具体用法?Python sys.ps2怎么用?Python sys.ps2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sys的用法示例。


在下文中一共展示了sys.ps2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: runCommand

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def runCommand(self, command, commandNumber=1, nCommands=1):
        pipeline = self.pipeline

        if self._handleSpecial(command):
            return

        try:
            incomplete, doPrint = pipeline.run(command, commandNumber,
                                               nCommands)
        except KeyboardInterrupt:
            print('^C', file=sys.stderr)
            self.reset()
            return False
        except Exception:
            print(traceback.format_exc(), file=sys.stderr)
            self.reset()
            return False
        else:
            self.prompt = sys.ps2 if incomplete else sys.ps1
            if doPrint:
                pipeline.print_()

        return True 
开发者ID:terrycojones,项目名称:daudin,代码行数:25,代码来源:interaction.py

示例2: AppendToPrompt

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def AppendToPrompt(self,bufLines, oldPrompt = None):
		" Take a command and stick it at the end of the buffer (with python prompts inserted if required)."
		self.flush()
		lastLineNo = self.GetLineCount()-1
		line = self.DoGetLine(lastLineNo)
		if oldPrompt and line==oldPrompt:
			self.SetSel(self.GetTextLength()-len(oldPrompt), self.GetTextLength())
			self.ReplaceSel(sys.ps1)
		elif (line!=str(sys.ps1)):
			if len(line)!=0: self.write('\n')
			self.write(sys.ps1)
		self.flush()
		self.idle.text.mark_set("iomark", "end-1c")
		if not bufLines:
			return
		terms = (["\n" + sys.ps2] * (len(bufLines)-1)) + ['']
		for bufLine, term in zip(bufLines, terms):
			if bufLine.strip():
				self.write( bufLine + term )
		self.flush() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:interact.py

示例3: HookHandlers

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def HookHandlers(self):
		# Hook menu command (executed when a menu item with that ID is selected from a menu/toolbar
		self.HookCommand(self.OnSelectBlock, win32ui.ID_EDIT_SELECT_BLOCK)
		self.HookCommand(self.OnEditCopyCode, ID_EDIT_COPY_CODE)
		self.HookCommand(self.OnEditExecClipboard, ID_EDIT_EXEC_CLIPBOARD)
		mod = pywin.scintilla.IDLEenvironment.GetIDLEModule("IdleHistory")
		if mod is not None:
			self.history = mod.History(self.idle.text, "\n" + sys.ps2)
		else:
			self.history = None
		# hack for now for event handling.

	# GetBlockBoundary takes a line number, and will return the
	# start and and line numbers of the block, and a flag indicating if the
	# block is a Python code block.
	# If the line specified has a Python prompt, then the lines are parsed
	# backwards and forwards, and the flag is true.
	# If the line does not start with a prompt, the block is searched forward
	# and backward until a prompt _is_ found, and all lines in between without
	# prompts are returned, and the flag is false. 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:22,代码来源:interact.py

示例4: OnEditCopyCode

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def OnEditCopyCode(self, command, code):
		""" Sanitizes code from interactive window, removing prompts and output,
			and inserts it in the clipboard."""
		code=self.GetSelText()
		lines=code.splitlines()
		out_lines=[]
		for line in lines:
			if line.startswith(sys.ps1):
				line=line[len(sys.ps1):]
				out_lines.append(line)
			elif line.startswith(sys.ps2):
				line=line[len(sys.ps2):]
				out_lines.append(line)
		out_code=os.linesep.join(out_lines)
		win32clipboard.OpenClipboard()
		try:
			win32clipboard.SetClipboardData(win32clipboard.CF_UNICODETEXT, unicode(out_code))
		finally:
			win32clipboard.CloseClipboard() 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:21,代码来源:interact.py

示例5: test_cp4299

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def test_cp4299(self):
        superConsole.SendKeys('outputRedirectStart{(}{)}{ENTER}')
        superConsole.SendKeys('import sys{ENTER}')
        superConsole.SendKeys('print sys.ps1{ENTER}')
        superConsole.SendKeys('print sys.ps2{ENTER}')
        
        superConsole.SendKeys('sys.ps1 = "abc "{ENTER}')
        superConsole.SendKeys('sys.ps2 = "xyz "{ENTER}')
        superConsole.SendKeys('def f{(}{)}:{ENTER}    pass{ENTER}{ENTER}')
        superConsole.SendKeys('outputRedirectStop{(}{)}{ENTER}')
        lines = getTestOutput()[0]
        expected_lines = ['>>> import sys\n', 
                        '>>> print sys.ps1\n', '>>> \n', 
                        '>>> print sys.ps2\n', '... \n', 
                        '>>> sys.ps1 = "abc "\n', 'abc sys.ps2 = "xyz "\n', 
                        'abc def f():\n', 'xyz         pass\n', 'xyz         \n', 
                        'abc outputRedirectStop()\n']
        
        for i in xrange(len(lines)):
            AreEqual(lines[i], expected_lines[i])
        AreEqual(len(lines), len(expected_lines)) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:23,代码来源:test_superconsole.py

示例6: _do_PYREPL

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def _do_PYREPL(self, params):
        # SOURCE: https://github.com/python/cpython/blob/e42b705188271da108de42b55d9344642170aa2b/Lib/code.py
        cprt = 'Type "help", "copyright", "credits" or "license" for more information.'
        self.push("=== PYREPL START ===\nPython %s on %s\n%s\n" % (sys.version, sys.platform, cprt))

        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ">>> "

        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = "... "

        self.push(sys.ps1)

        # Redirect STDOUT & STDERR
        self._stdout = sys.stdout
        sys.stdout = IOProxy(self, prefix="STDOUT")
        self._stderr = sys.stderr
        sys.stderr = IOProxy(self, prefix="STDERR")

        self._in_repl = True 
开发者ID:SafeBreach-Labs,项目名称:backdoros,代码行数:26,代码来源:backdoros.py

示例7: bash

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def bash(command="bash"):
    """Start a bash shell and return a :class:`REPLWrapper` object."""
    bashrc = os.path.join(os.path.dirname(__file__), 'bashrc.sh')
    child = pexpect.spawn(command, ['--rcfile', bashrc], echo=False,
                          encoding='utf-8')

    # If the user runs 'env', the value of PS1 will be in the output. To avoid
    # replwrap seeing that as the next prompt, we'll embed the marker characters
    # for invisible characters in the prompt; these show up when inspecting the
    # environment variable, but not when bash displays the prompt.
    ps1 = PEXPECT_PROMPT[:5] + u'\\[\\]' + PEXPECT_PROMPT[5:]
    ps2 = PEXPECT_CONTINUATION_PROMPT[:5] + u'\\[\\]' + PEXPECT_CONTINUATION_PROMPT[5:]
    prompt_change = u"PS1='{0}' PS2='{1}' PROMPT_COMMAND=''".format(ps1, ps2)

    return REPLWrapper(child, u'\\$', prompt_change,
                       extra_init_cmd="export PAGER=cat") 
开发者ID:pypa,项目名称:pipenv,代码行数:18,代码来源:replwrap.py

示例8: python

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def python(self, argv):
        import code
        ns = self._get_ns()
        console = code.InteractiveConsole(ns)
        console.raw_input = self._ui.user_input
        try:
            saveps1, saveps2 = sys.ps1, sys.ps2
        except AttributeError:
            saveps1, saveps2 = ">>> ", "... "
        sys.ps1, sys.ps2 = "%%GPython%%N:%s> " % (self._obj.__class__.__name__,), "more> "
        if readline:
            oc = readline.get_completer()
            readline.set_completer(Completer(ns).complete)
        console.interact("You are now in Python. ^D exits.")
        if readline:
            readline.set_completer(oc)
        sys.ps1, sys.ps2 = saveps1, saveps2
        self._reset_scopes()


# This is needed to reset PagedIO so background events don't cause the pager to activate. 
开发者ID:kdart,项目名称:pycopia,代码行数:23,代码来源:CLI.py

示例9: python

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def python(self, argv):
        import code
        ns = self._get_ns()
        console = code.InteractiveConsole(ns)
        console.raw_input = self._ui.user_input
        try:
            saveps1, saveps2 = sys.ps1, sys.ps2
        except AttributeError:
            saveps1, saveps2 = ">>> ", "... "
        sys.ps1, sys.ps2 = "%%GPython%%N:%s> " % (self._obj.__class__.__name__,), "more> "
        if readline:
            oc = readline.get_completer()
            readline.set_completer(Completer(ns).complete)
        console.interact("You are now in Python. ^D exits.")
        if readline:
            readline.set_completer(oc)
        sys.ps1, sys.ps2 = saveps1, saveps2
        self._reset_scopes() 
开发者ID:kdart,项目名称:pycopia,代码行数:20,代码来源:CLI.py

示例10: interact

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def interact(self, locals=None):
        class LambdaConsole(code.InteractiveConsole):
            def runsource(code_console, source, filename=None, symbol=None):
                try:
                    self.runner.run(source)
                except SystemExit:
                    raise
                except:
                    code_console.showtraceback()
                return False

        try:
            import readline; readline
        except ImportError:
            pass

        ps1, ps2 = getattr(sys, 'ps1', None), getattr(sys, 'ps2', None)
        try:
            sys.ps1, sys.ps2 = self.ps1, self.ps2
            LambdaConsole(locals=locals, filename="<demo>").interact(banner='')
        finally:
            sys.ps1, sys.ps2 = ps1, ps2 
开发者ID:florianholzapfel,项目名称:panasonic-viera,代码行数:24,代码来源:__main__.py

示例11: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def __init__(self, parent=None):
        super().__init__(parent)
        if not hasattr(sys, 'ps1'):
            sys.ps1 = '>>> '
        if not hasattr(sys, 'ps2'):
            sys.ps2 = '... '
        namespace = {
            '__name__': '__console__',
            '__doc__': None,
            'q_app': QApplication.instance(),
            # We use parent as self here because the user "feels" the whole
            # console, not just the line edit.
            'self': parent,
            'objreg': objreg,
        }
        self._more = False
        self._buffer = []  # type: typing.MutableSequence[str]
        self._lineedit = ConsoleLineEdit(namespace, self)
        self._lineedit.execute.connect(self.push)
        self._output = ConsoleTextEdit()
        self.write(self._curprompt())
        self._vbox = QVBoxLayout()
        self._vbox.setSpacing(0)
        self._vbox.addWidget(self._output)
        self._vbox.addWidget(self._lineedit)
        stylesheet.set_register(self)
        self.setLayout(self._vbox)
        self._lineedit.setFocus()
        self._interpreter = code.InteractiveInterpreter(namespace) 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:31,代码来源:consolewidget.py

示例12: _curprompt

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def _curprompt(self):
        """Get the prompt which is visible currently."""
        return sys.ps2 if self._more else sys.ps1 
开发者ID:qutebrowser,项目名称:qutebrowser,代码行数:5,代码来源:consolewidget.py

示例13: __init__

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def __init__(self, pipeline=None, ps1=DEFAULT_PS1, ps2=DEFAULT_PS2):
        super().__init__(pipeline)

        try:
            sys.ps1
        except AttributeError:
            sys.ps1 = ps1

        try:
            sys.ps2
        except AttributeError:
            sys.ps2 = ps2

        self.prompt = sys.ps1 
开发者ID:terrycojones,项目名称:daudin,代码行数:16,代码来源:interaction.py

示例14: setup_method

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def setup_method(self, method):
        try:
            del sys.ps1
        except AttributeError:
            pass
        try:
            del sys.ps2
        except AttributeError:
            pass 
开发者ID:terrycojones,项目名称:daudin,代码行数:11,代码来源:test_interaction.py

示例15: testSetPrompts

# 需要导入模块: import sys [as 别名]
# 或者: from sys import ps2 [as 别名]
def testSetPrompts(self):
        """
        Setting the prompts via __init__ must work.
        """
        pl = Pipeline(loadInitFile=False)
        repl = REPL(pipeline=pl, ps1='x', ps2='y')
        self.assertEqual('x', repl.prompt)
        self.assertEqual('x', sys.ps1)
        self.assertEqual('y', sys.ps2) 
开发者ID:terrycojones,项目名称:daudin,代码行数:11,代码来源:test_interaction.py


注:本文中的sys.ps2方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。