Here are the examples of the python api sys.stdin taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
145 Examples
5
View Complete Implementation : test_main.py
Copyright GNU General Public License v3.0
Author : sk1project
Copyright GNU General Public License v3.0
Author : sk1project
def run_2to3_capture(self, args, in_capture, out_capture, err_capture):
save_stdin = sys.stdin
save_stdout = sys.stdout
save_stderr = sys.stderr
sys.stdin = in_capture
sys.stdout = out_capture
sys.stderr = err_capture
try:
return main.main("lib2to3.fixes", args)
finally:
sys.stdin = save_stdin
sys.stdout = save_stdout
sys.stderr = save_stderr
5
View Complete Implementation : run.py
Copyright GNU General Public License v3.0
Author : sk1project
Copyright GNU General Public License v3.0
Author : sk1project
def handle(self):
"""Override base method"""
executive = Executive(self)
self.register("exec", executive)
self.console = self.get_remote_proxy("console")
sys.stdin = PyShell.PseudoInputFile(self.console, "stdin",
IOBinding.encoding)
sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout",
IOBinding.encoding)
sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr",
IOBinding.encoding)
# Keep a reference to stdin so that it won't try to exit IDLE if
# sys.stdin gets changed from within IDLE's shell. See issue17838.
self._keep_stdin = sys.stdin
self.interp = self.get_remote_proxy("interp")
rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05)
5
View Complete Implementation : test_refactor.py
Copyright GNU General Public License v3.0
Author : sk1project
Copyright GNU General Public License v3.0
Author : sk1project
def test_refactor_stdin(self):
clast MyRT(refactor.RefactoringTool):
def print_output(self, old_text, new_text, filename, equal):
results.extend([old_text, new_text, filename, equal])
results = []
rt = MyRT(_DEFAULT_FIXERS)
save = sys.stdin
sys.stdin = StringIO.StringIO("def parrot(): past\n\n")
try:
rt.refactor_stdin()
finally:
sys.stdin = save
expected = ["def parrot(): past\n\n",
"def cheese(): past\n\n",
"<stdin>", False]
self.astertEqual(results, expected)
5
View Complete Implementation : test_refactor.py
Copyright GNU General Public License v3.0
Author : sk1project
Copyright GNU General Public License v3.0
Author : sk1project
def test_refactor_stdin(self):
clast MyRT(refactor.RefactoringTool):
def print_output(self, old_text, new_text, filename, equal):
results.extend([old_text, new_text, filename, equal])
results = []
rt = MyRT(_DEFAULT_FIXERS)
save = sys.stdin
sys.stdin = StringIO.StringIO("def parrot(): past\n\n")
try:
rt.refactor_stdin()
finally:
sys.stdin = save
expected = ["def parrot(): past\n\n",
"def cheese(): past\n\n",
"<stdin>", False]
self.astertEqual(results, expected)
5
View Complete Implementation : run.py
Copyright GNU General Public License v3.0
Author : sk1project
Copyright GNU General Public License v3.0
Author : sk1project
def handle(self):
"""Override base method"""
executive = Executive(self)
self.register("exec", executive)
self.console = self.get_remote_proxy("console")
sys.stdin = PyShell.PseudoInputFile(self.console, "stdin",
IOBinding.encoding)
sys.stdout = PyShell.PseudoOutputFile(self.console, "stdout",
IOBinding.encoding)
sys.stderr = PyShell.PseudoOutputFile(self.console, "stderr",
IOBinding.encoding)
# Keep a reference to stdin so that it won't try to exit IDLE if
# sys.stdin gets changed from within IDLE's shell. See issue17838.
self._keep_stdin = sys.stdin
self.interp = self.get_remote_proxy("interp")
rpc.RPCHandler.getresponse(self, myseq=None, wait=0.05)
5
View Complete Implementation : test_main.py
Copyright GNU General Public License v3.0
Author : sk1project
Copyright GNU General Public License v3.0
Author : sk1project
def run_2to3_capture(self, args, in_capture, out_capture, err_capture):
save_stdin = sys.stdin
save_stdout = sys.stdout
save_stderr = sys.stderr
sys.stdin = in_capture
sys.stdout = out_capture
sys.stderr = err_capture
try:
return main.main("lib2to3.fixes", args)
finally:
sys.stdin = save_stdin
sys.stdout = save_stdout
sys.stderr = save_stderr
5
View Complete Implementation : test_pydoc.py
Copyright GNU General Public License v3.0
Author : sk1project
Copyright GNU General Public License v3.0
Author : sk1project
def test_getpager_with_stdin_none(self):
previous_stdin = sys.stdin
try:
sys.stdin = None
pydoc.getpager() # Shouldn't fail.
finally:
sys.stdin = previous_stdin
5
View Complete Implementation : test_pydoc.py
Copyright GNU General Public License v3.0
Author : sk1project
Copyright GNU General Public License v3.0
Author : sk1project
def test_getpager_with_stdin_none(self):
previous_stdin = sys.stdin
try:
sys.stdin = None
pydoc.getpager() # Shouldn't fail.
finally:
sys.stdin = previous_stdin
3
View Complete Implementation : rm_dup_tss.py
Copyright GNU General Public License v3.0
Author : dputhier
Copyright GNU General Public License v3.0
Author : dputhier
def make_parser():
""" Parser """
parser = argparse.ArgumentParser(add_help=True)
parser_grp = parser.add_argument_group('Argument')
parser_grp.add_argument('-i', '--inputfile',
help="Path to the GTF file. Default to STDIN",
default=sys.stdin,
metavar="GTF",
type=arg_formatter.FormattedFile(mode='r', file_ext=('gtf', 'gtf.gz')))
parser_grp.add_argument('-o', '--outputfile',
help="Output file.",
default=sys.stdout,
metavar="GTF",
type=arg_formatter.FormattedFile(mode='w', file_ext=('gtf')))
return parser
3
View Complete Implementation : select_by_max_exon_nb.py
Copyright GNU General Public License v3.0
Author : dputhier
Copyright GNU General Public License v3.0
Author : dputhier
def make_parser():
"""The program parser."""
parser = argparse.ArgumentParser(add_help=True)
parser.add_argument('-i', '--inputfile',
help="Path to the GTF file. Default to STDIN",
default=sys.stdin,
metavar="GTF",
type=arg_formatter.FormattedFile(mode='r', file_ext=('gtf', 'gtf.gz')))
parser.add_argument('-o', '--outputfile',
help="Output file.",
default=sys.stdout,
metavar="GTF",
type=arg_formatter.FormattedFile(mode='w', file_ext=('gtf')))
return parser