The main stdin iteration loop.
329267
def import_keys(hsm, args):
    
    res = True

    # ykksm 1
    #123456,ftftftcccc,534543524554,fcacd309a20ce1809c2db257f0e8d6ea,000000000000,,,

    for line in sys.stdin:
        if line[0] == '#':
            continue

        l = line.split(',')
        modhex_id = l[1]
        uid = l[2].decode('hex')
        key = l[3].decode('hex')

        if modhex_id and uid and key:
            public_id = pyhsm.yubikey.modhex_decode(modhex_id)
            padded_id = modhex_id.rjust(args.public_id_chars, 'c')

        if int(public_id, 16) == 0:
            print "WARNING: Skipping import of key with public ID: %s" % (padded_id)
            print "This public ID is unsupported by the YubiHSM.\n"
            continue

        if args.verbose:
            print "  %s" % (padded_id)

        secret = pyhsm.aead_cmd.YHSM_YubiKeySecret(key, uid)
        hsm.load_secret(secret)

        for kh in args.key_handles.keys():
            if(args.random_nonce):
                nonce = ""
            else:
                nonce = public_id.decode('hex')
            aead = hsm.generate_aead(nonce, kh)

            if args.internal_db:
                if not store_in_internal_db(
                        args, hsm, modhex_id, public_id, kh, aead):
                    res = False
                continue

            filename = output_filename(
                args.output_dir, args.key_handles[kh], padded_id)

            if args.verbose:
                print "    %4s, %i bytes (%s) -> %s" % \
                    (args.key_handles[kh], len(aead.data), shorten_aead(aead), filename)

            aead.save(filename)

        if args.verbose:
            print ""

    if res:
        print "\nDone\n"
    else:
        print "\nDone (one or more entries rejected)"
    return res
75283
def run(stream=sys.stdin.buffer):
    
    payload = decode.decode(stream)
    sys.stdout.write(payload.decode('utf8'))
1293026
def main(pargs):
    
    input_file = sys.argv[1]
    fp = ParseFileLineByLine(input_file)
    for i in fp:
        print(i)
1141313
function readStdin() {
    var stdin = process.stdin,
      fd = stdin.isTTY && process.platform !== 'win32' ?
        fs.openSync('/dev/tty', 'rs') : stdin.fd,
      bufSize = stdin.isTTY ? DEFAULT_BUF_SIZE :
        (fs.fstatSync(fd).size || DEFAULT_BUF_SIZE),
      buffer = Buffer.allocUnsafe && Buffer.alloc ? Buffer.alloc(bufSize) : new Buffer(bufSize),
      rsize, input = '';
    while (true) {
      rsize = 0;
      try {
        rsize = fs.readSync(fd, buffer, 0, bufSize);
      } catch (e) {
        if (e.code === 'EOF') { break; }
        throw e;
      }
      if (rsize === 0) { break; }
      input += buffer.toString(program.encoding, 0, rsize);
    }
    return input;
  }
1314717
def main():
    
    import re
    with open('rgb.txt') as fp:
        line = fp.readline()
        while line:
            reg = re.match(r'\s*(\d+)\s*(\d+)\s*(\d+)\s*(\w.*\w).*', line)
            if reg:
                r = int(reg.group(1)) / 255.
                g = int(reg.group(2)) / 255.
                b = int(reg.group(3)) / 255.
                d = reg.group(4)
                print "'%s' : np.array([%.2f, %.2f, %.2f])," % (d, r, g, b)
            line = fp.readline()
1349850
public function main() {
        $this->stdout->styles('success', array('text' => 'green'));

        $this->hr(1);
        $this->out(sprintf('%s Steps:', $this->name));

        $counter = 1;

        foreach ($this->steps as $method) {
            $this->steps($counter);

            try {
                if (!call_user_func(array($this, $method))) {
                    $this->err('<error>Process aborted!</error>');
                    break;
                }
            } catch (Exception $e) {
                $this->err(sprintf('<error>Unexpected error has occurred; %s</error>', $e->getMessage()));
                break;
            }

            $counter++;
        }
    }
986678
def mt_interact(self):
        """"""
        import _thread
        _thread.start_new_thread(self.listener, ())
        while 1:
            line = sys.stdin.readline()
            if not line:
                break
            self.write(line)
225978
def input_loop():
    ''''''
    while mestate.exit != True:
        try:
            if mestate.exit != True:
                line = input(mestate.rl.prompt)
        except EOFError:
            mestate.exit = True
            sys.exit(1)
        mestate.input_queue.put(line)
314641
def run(self):
        '''
        
        '''

        # Parse the stdin into a global event object
        stdin = self.read_stdin()
        self.event = self.read_event(stdin)

        # Prepare global settings
        self.settings = get_settings()
        self.api_settings = self.get_api_settings()

        # Prepare command line arguments and
        self.parser = argparse.ArgumentParser()

        # set up the 2.x to 1.x event mapping argument
        self.parser.add_argument("--map-v2-event-into-v1",
                                 action="store_true",
                                 default=False,
                                 dest="v2event")

        if hasattr(self, 'setup'):
            self.setup()
        (self.options, self.remain) = self.parser.parse_known_args()

        # map the event if required
        if (self.options.v2event or
                os.environ.get("SENSU_MAP_V2_EVENT_INTO_V1")):
            self.event = map_v2_event_into_v1(self.event)

        # Filter (deprecated) and handle
        self.filter()
        self.handle()
43400
def main_loop(self):
        
        sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        port = int(getattr(self, 'port', 1738))
        sock.bind(('127.0.0.1', port))
        while True:
            data, addr = sock.recvfrom(512)
            color = data.decode().strip()
            self.color = self.colors.get(color, color)
904986
def create_stdin_shell(shell, loop=None):
    
    @asyncio.coroutine
    def feed_stdin(loop, reader, shell):
        history = InMemoryHistory()
        completer = WordCompleter([name for name, _ in shell.get_commands()], ignore_case=True)
        while True:
            line = yield from prompt(
                ">", patch_stdout=True, return_asyncio_coroutine=True, history=history, completer=completer)
            line += '\n'
            reader.feed_data(line.encode())

    @asyncio.coroutine
    def read_stdout(writer):
        while True:
            c = yield from writer.read(1)
            print(c.decode(), end='')
            sys.stdout.flush()

    reader = asyncio.StreamReader()
    writer = asyncio.StreamReader()
    shell.reader = reader
    shell.writer = writer
    if loop is None:
        loop = asyncio.get_event_loop()

    reader_task = loop.create_task(feed_stdin(loop, reader, shell))
    writer_task = loop.create_task(read_stdout(writer))
    shell_task = loop.create_task(shell.run())
    return asyncio.gather(shell_task, writer_task, reader_task)
1075583
def main(sys=sys):
    
    if len(sys.argv) != 2:
        sys.stderr.write(USAGE)
        return 1
    EliotFilter(sys.argv[1], sys.stdin, sys.stdout).run()
    return 0
572960
def main():
    """"""
    # Helper method so that the coroutine exits cleanly if an exception
    # happens (which would leave resources dangling)
    async def _run_application(loop):
        try:
            return await cli_handler(loop)

        except KeyboardInterrupt:
            pass  # User pressed Ctrl+C, just ignore it

        except SystemExit:
            pass  # sys.exit() was used - do nothing

        except:  # pylint: disable=bare-except  # noqa
            import traceback

            traceback.print_exc(file=sys.stderr)
            sys.stderr.writelines(
                '\n>>> An error occurred, full stack trace above\n')

        return 1

    try:
        loop = asyncio.get_event_loop()
        return loop.run_until_complete(_run_application(loop))
    except KeyboardInterrupt:
        pass

    return 1
260764
function () {
			process.stdin.resume();
			process.stdin.setEncoding('utf8');
			_execCtx = [self];
			process.stdin.on('data', function (chunk) {
				var ctx = _execCtx[0],
					cmd = chunk.substr(0,chunk.length-1);

				if (cmd.substr(0,2) == '..')
				{
					cmd = 'if (_execCtx.length>1) _execCtx.shift(); undefined;'
				} else if (cmd.substr(0,1) == ':')
				{
					cmd = 'var newCtx = '+cmd.substr(1)+'; _execCtx.unshift(newCtx); undefined;';
				} else if (cmd.substr(0,1) == '/')
				{
					cmd = '';
					_execCtx = [self];
				}

				self.exec(cmd,ctx?ctx:undefined);
				return false;
			});
		}
796651
def main_loop(self):
        """"""

        def exit(signum, frame):
            shutdown()
            sys.exit(0)

        signal.signal(signal.SIGTERM, exit)

        while True:
            task = self._get_next_task_from_raylet()
            self._wait_for_and_process_task(task)
363600
def main():
    
    (options, strings) = parseArgv()
    global _suffixArray, _trace

    #############
    # Verbosity #
    #############
    _trace = options.verbose

    ###################
    # Processing unit #
    ###################
    if options.unit == "byte":
        options.unit = UNIT_BYTE
    elif options.unit == "character":
        options.unit = UNIT_CHARACTER
    elif options.unit == "word":
        options.unit = UNIT_WORD
    else:
        print >> _stderr, "Please specify a valid unit type."
        exit(EXIT_BAD_OPTION)

    ######################
    # Build suffix array #
    ######################
    if not options.SAFile:  # Build the suffix array from INPUT
        if not options.input:  # default is standard input
            options.input = "-"
        try:
            string = _open(options.input, "r").read()
        except IOError:
            print >> _stderr, "File %s does not exist." % options.input
            exit(EXIT_ERROR_FILE)

        SA = SuffixArray(string, options.unit, options.encoding, options.noLCPs)
    ########################
    # Or load suffix array #
    ########################
    elif not options.input and options.SAFile:  # Load suffix array from SA_FILE
        try:
            SA = SuffixArray.fromFile(options.SAFile)
        except IOError:
            print >> _stderr, "SA_FILE %s does not exist." % options.SAFile
            exit(EXIT_ERROR_FILE)
    else:
        print >> _stderr, "Please set only one option amongst --input and --load.\n" + \
        "Type %s --help for more details." % _argv[0]
        exit(EXIT_BAD_OPTION)

    ######################
    # Print suffix array #
    ######################
    if options.printSA:
        # Buffered ouptut
        deltaLength = 1000
        start = 0
        while start < SA.length:
            print >> _stderr, SA.__str__(start, start + deltaLength)
            start += deltaLength

    ####################################
    # Look for every string in strings #
    ####################################
    for string in strings:
        print >> _stderr, ""
        print >> _stderr, "Positions of %s:" % string
        print >> _stderr, "  %s" % list(SA.find(string))

    #########################
    # Save SAFILE if needed #
    #########################
    if options.output:
        SA.toFile(options.output)

    if _trace: print >> _stderr, "Done\r\n"
296687
def input_thread(log, stdin, is_alive, quit, close_before_term):
    

    done = False
    closed = False
    alive = True
    poller = Poller()
    poller.register_write(stdin)

    while poller and alive:
        changed = poller.poll(1)
        for fd, events in changed:
            if events & (POLLER_EVENT_WRITE | POLLER_EVENT_HUP):
                log.debug("%r ready for more input", stdin)
                done = stdin.write()

                if done:
                    poller.unregister(stdin)
                    if close_before_term:
                        stdin.close()
                        closed = True

        alive, _ = is_alive()

    while alive:
        quit.wait(1)
        alive, _ = is_alive()

    if not closed:
        stdin.close()