Try to parse all input streams from file
335457
def parse_streams(self):
        
        logger.debug("Parsing streams of {}".format(self.input_file))

        cmd = [
            self.ffmpeg_normalize.ffmpeg_exe, '-i', self.input_file,
            '-c', 'copy', '-t', '0', '-map', '0',
            '-f', 'null', NUL
        ]

        cmd_runner = CommandRunner(cmd)
        cmd_runner.run_command()
        output = cmd_runner.get_output()

        logger.debug("Stream parsing command output:")
        logger.debug(output)

        output_lines = [line.strip() for line in output.split('\n')]

        for line in output_lines:

            if not line.startswith('Stream'):
                continue

            stream_id_match = re.search(r'#0:([\d]+)', line)
            if stream_id_match:
                stream_id = int(stream_id_match.group(1))
                if stream_id in self._stream_ids():
                    continue
            else:
                continue

            if 'Audio' in line:
                logger.debug("Found audio stream at index {}".format(stream_id))
                sample_rate_match = re.search(r'(\d+) Hz', line)
                sample_rate = int(sample_rate_match.group(1)) if sample_rate_match else None
                bit_depth_match = re.search(r's(\d+)p?,', line)
                bit_depth = int(bit_depth_match.group(1)) if bit_depth_match else None
                self.streams['audio'][stream_id] = AudioStream(self, stream_id, sample_rate, bit_depth)

            elif 'Video' in line:
                logger.debug("Found video stream at index {}".format(stream_id))
                self.streams['video'][stream_id] = VideoStream(self, stream_id)

            elif 'Subtitle' in line:
                logger.debug("Found subtitle stream at index {}".format(stream_id))
                self.streams['subtitle'][stream_id] = SubtitleStream(self, stream_id)

        if not self.streams['audio']:
            raise FFmpegNormalizeError(
                "Input file {} does not contain any audio streams"
                .format(self.input_file))

        if os.path.splitext(self.output_file)[1].lower() in ['.wav', '.mp3', '.aac']:
            logger.warning(
                "Output file only supports one stream. "
                "Keeping only first audio stream."
            )
            first_stream = list(self.streams['audio'].values())[0]
            self.streams['audio'] = {first_stream.stream_id: first_stream}
            self.streams['video'] = {}
            self.streams['subtitle'] = {}
456908
def __parse_stream(self, stream):
        """"""

        nline = 0
        lines = stream.split('\n')

        for line in lines:
            nline += 1

            # Ignore blank lines and comments
            m = re.match(self.LINES_TO_IGNORE_REGEX, line, re.UNICODE)
            if m:
                continue

            line = line.strip('\n').strip(' ')
            parts = line.split('>')

            if len(parts) == 0:
                cause = "line %s: invalid format" % str(nline)
                raise InvalidFormatError(cause=cause)

            aliases = []

            for part in parts:
                part = part.replace(',', ' ')
                part = part.strip('\n').strip(' ')

                if len(part) == 0:
                    continue

                if part.find('<') < 0:
                    cause = "line %s: invalid format" % str(nline)
                    raise InvalidFormatError(cause=cause)

                alias = email.utils.parseaddr(part + '>')
                aliases.append(alias)

            yield aliases
734532
@Override
	public List<XLog> parse(InputStream is)
			throws Exception {
		is = new GZIPInputStream(new BufferedInputStream(is));
		return super.parse(is);
	}
1262956
public List<String[]> parse(InputStream stream) throws IOException
    {
        int columnCount = -1;
        List<String[]> lines = new ArrayList<String[]>();
        rows.clear();

        // Excel spreadsheet
        if(CommonFiles.isExcelFile(name))
        {
            if(worksheet != null && worksheet.length() > 0)
            {
                SimpleDateFormat df = new SimpleDateFormat(Formats.DATETIME_FORMAT);
                df.setTimeZone(TimeZone.getTimeZone("GMT"));

                Workbook workbook = Workbook.getWorkbook(name, stream);
                Worksheet sheet = workbook.getSheet(worksheet);
                if(sheet != null)
                {
                    columnCount = sheet.getColumns();
                    for(int i = 0; i < sheet.getRows(); i++)
                    {
                        String[] values = sheet.getRow(i, df);
                        if(values != null)
                            lines.add(values);
                    }
                }
                else
                {
                    throw new IllegalStateException("Worksheet '"+worksheet+"' not found");
                }

                workbook.close();
            }
            else
            {
                throw new IllegalArgumentException("Worksheet not specified");
            }
        }
        else if(CommonFiles.isCsvFile(name))
        {
            Reader reader = new InputStreamReader(stream);
            CSVReader csv = new CSVReader(reader, delimiter.separator().charAt(0));
            String [] line;
            while ((line = csv.readNext()) != null) 
            {
                if(columnCount == -1)
                    columnCount = line.length;
                lines.add(line);
            }
            reader.close();
        }

        int lineCount = lines.size();

        logger.fine("InputFileReader.parse: lines="+lineCount+" columns="+columnCount);

        // Error if the file is empty
        if(lineCount <= 0 || columnCount == 0)
            throw new IllegalStateException("input file does not contain any data");

        // Parse the file headers and rows
        int count = 0;
        for(String[] line : lines)
        {
            // Ignore the line if there is no data
            if(isBlankRow(line))
                continue;

            String[] row = new String[columnCount];  // the row of data

            for(int column = 0; column < columnCount; column++)
            {

                // Check that the row column count matches the header column count
                if(column >= line.length)
                {
                    if(line.length > 0 && isCompleteLine(line))
                        break;
                    else
                        throw new IllegalStateException("Row "+count+" has more columns than the header row");
                }

                // The first row gives the column headers
                if(count == 0)
                {
                    try
                    {
                        row[column] = line[column].trim();
                    }
                    catch(NoSuchElementException e)
                    {
                        row[column] = "";
                    }
                }
                else // The subsequent rows give the actual data
                {
                    try
                    {
                        String token = line[column];

                        // Remove quotes
                        if(removeQuotes && token.startsWith("\""))
                        {
                            token = token.substring(1);
                            if(token.endsWith("\""))
                                token = token.substring(0,token.length()-1);

                            // Replace all other double quotes with a single quote
                            token = token.replaceAll("\"\"", "\"");
                        }

                        // Trim the value (if required)
                        if(trim)
                            token.trim();

                        // Put the processed token in the array
                        row[column] = token;
                        logger.fine("InputFileReader.parse: row["+count+","+headers[column]+"]="+token);
                    }
                    catch(NoSuchElementException e)
                    {
                        row[column] = "";
                    }
                }
            }

            if(count == 0)
                headers = row;
            else
                rows.add(row);
            ++count;
        }

        return rows;
    }
535637
def reader(stream):
    """"""
    string = stream.read()
    decoder = json.JSONDecoder().raw_decode
    index = START.match(string, 0).end()

    while index < len(string):
        obj, end = decoder(string, index)
        item = Item()
        item.primitive = obj
        yield item
        index = END.match(string, end).end()
309982
def __parse(self, stream):
        """"""

        if not stream:
            raise InvalidFormatError(cause="stream cannot be empty or None")

        json = self.__load_json(stream)

        self.__parse_organizations(json)
        self.__parse_identities(json)
        self.__parse_blacklist(json)
1296657
private static List<Map<String, String>> loadWords(InputStream stream) {
    List<Map<String, String>> list = new ArrayList<>();
    try (
      InputStreamReader isr = new InputStreamReader(stream, FILE_ENCODING);
      BufferedReader br = new BufferedReader(isr);
    ) {
      String line;

      Tokenizer wordTokenizer = new Breton().getWordTokenizer();
      while ((line = br.readLine()) != null) {
        line = line.trim();
        if (line.isEmpty() || line.charAt(0) == '#') { // ignore comments
          continue;
        }
        String[] parts = line.split("=");
        if (parts.length != 2) {
          throw new IOException("Format error in file "
                  + JLanguageTool.getDataBroker().getFromRulesDirAsUrl(FILE_NAME)
                  + ", line: " + line);
        }
        String[] wrongForms = parts[0].split("\\|"); // multiple incorrect forms
        for (String wrongForm : wrongForms) {
          int wordCount = 0;
          List<String> tokens = wordTokenizer.tokenize(wrongForm);
          for (String token : tokens) {
            if (!StringTools.isWhitespace(token)) {
              wordCount++;
            }
          }
          // grow if necessary
          for (int i = list.size(); i < wordCount; i++) {
            list.add(new HashMap<>());
          }
          list.get(wordCount - 1).put(wrongForm, parts[1]);
        }
      }
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
    // seal the result (prevent modification from outside this class)
    List<Map<String,String>> result = new ArrayList<>();
    for (Map<String, String> map : list) {
      result.add(Collections.unmodifiableMap(map));
    }
    return Collections.unmodifiableList(result);
  }
307247
def parse(input_: Union[str, FileStream], default_base: Optional[str]=None) -> Optional[Schema]:
    

    # Step 1: Tokenize the input stream
    error_listener = ParseErrorListener()
    if not isinstance(input_, FileStream):
        input_ = InputStream(input_)
    lexer = ShExDocLexer(input_)
    lexer.addErrorListener(error_listener)
    tokens = CommonTokenStream(lexer)
    tokens.fill()
    if error_listener.n_errors:         # Lexer prints errors directly
        return None

    # Step 2: Generate the parse tree
    parser = ShExDocParser(tokens)
    parser.addErrorListener(error_listener)
    parse_tree = parser.shExDoc()
    if error_listener.n_errors:
        print('\n'.join(error_listener.errors), file=sys.stderr)
        return None

    # Step 3: Transform the results the results
    parser = ShexDocParser(default_base=default_base)
    parser.visit(parse_tree)

    return parser.context.schema
815590
function getInputAsStream(input) {

    return new Promise(function(resolve, reject) {

        if (input.write) {

            // already a stream
            resolve(input);
        }
        else {

            // read from file
            fs.readFileAsync(input, 'utf-8').then(function(data) {

                // convert file string into stream and pipe into jsdoc-parse
                var stream = string2stream(data);

                // return stream
                resolve(stream);

            })
            .catch(function(err) {
                reject(err);
            });
        }

    });
}
535555
def _file_iter(input_stream, size, offset=0):
    
    input_stream.seek(offset)
    d = input_stream.read(size)
    while d:
        yield d
        d = input_stream.read(size)
1138682
def lint(input_file, debug=False):
    """"""
    options = load_options()

    if isinstance(input_file, string_types):
        text = input_file
    else:
        text = input_file.read()

    # Get the checks.
    checks = get_checks(options)

    # Apply all the checks.
    errors = []
    for check in checks:

        result = check(text)

        for error in result:
            (start, end, check, message, replacements) = error
            (line, column) = line_and_column(text, start)
            if not is_quoted(start, text):
                errors += [(check, message, line, column, start, end,
                           end - start, "warning", replacements)]

        if len(errors) > options["max_errors"]:
            break

    # Sort the errors by line and column number.
    errors = sorted(errors[:options["max_errors"]], key=lambda e: (e[2], e[3]))

    return errors
1039590
def read_input(self, filename, has_header=True):
        
        stream = open(filename)
        reader = csv.reader(stream)
        csv_data = []
        for (i, row) in enumerate(reader):
            if i==0:
                if not has_header:
                    csv_data.append([str(i) for i in xrange(0,len(row))])
            csv_data.append(row)
        self.data = csv_data
1114773
def parse(self, stream):
        """"""
        (result, _) = (self << eof).parse_partial(stream)
        return result
949876
def read_stream (stream):
    """"""

    section = None
    key = None
    data = None

    for fullline in stream:
        line = fullline.split ('#', 1)[0]

        m = sectionre.match (line)
        if m is not None:
            # New section
            if section is not None:
                if key is not None:
                    section.set_one (key, data.strip ().decode ('utf8'))
                    key = data = None
                yield section

            section = Holder ()
            section.section = m.group (1)
            continue

        if len (line.strip ()) == 0:
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
                key = data = None
            continue

        m = escre.match (fullline)
        if m is not None:
            if section is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2).replace (r'\"', '"').replace (r'\n', '\n').replace (r'\\', '\\')
            section.set_one (key, data.decode ('utf8'))
            key = data = None
            continue

        m = keyre.match (line)
        if m is not None:
            if section is None:
                raise InifileError ('key seen without section!')
            if key is not None:
                section.set_one (key, data.strip ().decode ('utf8'))
            key = m.group (1)
            data = m.group (2)
            if not len (data):
                data = ' '
            elif not data[-1].isspace ():
                data += ' '
            continue

        if line[0].isspace () and key is not None:
            data += line.strip () + ' '
            continue

        raise InifileError ('unparsable line: ' + line[:-1])

    if section is not None:
        if key is not None:
            section.set_one (key, data.strip ().decode ('utf8'))
        yield section
392138
def load_stream(filename):
    """"""
    rawfile = pkg_resources.resource_stream(__name__, filename)
    if six.PY2:
        return rawfile
    return io.TextIOWrapper(rawfile, 'utf-8')
931272
def parse_file(self, sourcepath):
        """"""

        # Open input file and read JSON array:
        with open(sourcepath, 'r') as logfile:
            jsonstr = logfile.read()

        # Set our attributes for this entry and add it to data.entries:
        data = {}
        data['entries'] = json.loads(jsonstr)
        if self.tzone:
            for e in data['entries']:
                e['tzone'] = self.tzone

        # Return the parsed data
        return data
268837
function input (args, stream) {
  const list = Array.isArray(args) ? args : args.split(' ').filter(Boolean)
  const ports = list.map(Number).filter(num)

  if (ports.length || !stream) {
    return Promise.resolve(ports)
  }

  return stdin().then(s => input(s, false))
}