Parses a vcf file.\n
        \n
        Usage:\n
            parser infile.vcf\n
        If pipe:\n
            parser -
191326
def cli(variant_file, vep, split):
    
    from datetime import datetime
    from pprint import pprint as pp
    if variant_file == '-':
        my_parser = VCFParser(fsock=sys.stdin, split_variants=split)
    else:
        my_parser = VCFParser(infile = variant_file, split_variants=split)
    start = datetime.now()
    nr_of_variants = 0
    for line in my_parser.metadata.print_header():
        print(line)
    for variant in my_parser:
        pp(variant)
        nr_of_variants += 1
    print('Number of variants: %s' % nr_of_variants)
1357072
def _CheckParserCanProcessFileEntry(self, parser, file_entry):
    
    for filter_object in parser.FILTERS:
      if filter_object.Match(file_entry):
        return True

    return False
1156612
def parser(scope, usage=''):
    
    subcmds = []
    for cmd in commands(scope):
        subcmds.append(cmd.usage())

    if subcmds:
        subcmds.sort()
        usage += '\n\nSub-Commands:\n  '
        usage += '\n  '.join(subcmds)

    parse = PARSER_CLASS(usage=usage)
    parse.prog = PROGRAM_NAME
    return parse
1277630
static function parse_file( $f ){
		$src = file_get_contents( $f, true );
		if( $src === false ){
			throw new Exception("Cannot read file $f");
		}
		return self::parse_string( $src );
	}
1238278
def parsefile(self, filename):
        
        with open(filename, 'rb') as fd:
            return self.parse(fd.read())
726080
public void parse(File file) throws UpdateException {
        LOGGER.debug("Parsing " + file.getName());
        try (InputStream fin = new FileInputStream(file);
                InputStream in = new GZIPInputStream(fin);
                InputStreamReader isr = new InputStreamReader(in, UTF_8);
                JsonReader reader = new JsonReader(isr)) {
            final Gson gson = new GsonBuilder().create();

            reader.beginObject();

            while (reader.hasNext() && !JsonToken.BEGIN_ARRAY.equals(reader.peek())) {
                reader.skipValue();
            }
            reader.beginArray();
            while (reader.hasNext()) {
                final DefCveItem cve = gson.fromJson(reader, DefCveItem.class);

                //cve.getCve().getCVEDataMeta().getSTATE();
                if (testCveCpeStartWithFilter(cve)) {
                    cveDB.updateVulnerability(cve);
                }
            }
        } catch (FileNotFoundException ex) {
            LOGGER.error(ex.getMessage());
            throw new UpdateException("Unable to find the NVD CPE file, `" + file + "`, to parse", ex);
        } catch (IOException ex) {
            LOGGER.error("Error reading NVD JSON data: {}", file);
            LOGGER.debug("Error extracting the NVD JSON data from: " + file.toString(), ex);
            throw new UpdateException("Unable to find the NVD CPE file to parse", ex);
        }
    }
139302
def ParseFileObject(self, parser_mediator, file_object):
    
    display_name = parser_mediator.GetDisplayName()
    self.ParseFileLNKFile(parser_mediator, file_object, display_name)
1305526
def _Parse(self):
    """"""
    root_file_entry = self._file_system.GetRootFileEntry()
    tsk_volume = self._file_system.GetTSKVolume()
    self.bytes_per_sector = tsk_partition.TSKVolumeGetBytesPerSector(tsk_volume)

    for sub_file_entry in root_file_entry.sub_file_entries:
      tsk_vs_part = sub_file_entry.GetTSKVsPart()
      start_sector = tsk_partition.TSKVsPartGetStartSector(tsk_vs_part)
      number_of_sectors = tsk_partition.TSKVsPartGetNumberOfSectors(tsk_vs_part)

      if start_sector is None or number_of_sectors is None:
        continue

      if tsk_partition.TSKVsPartIsAllocated(tsk_vs_part):
        volume = TSKVolume(sub_file_entry, self.bytes_per_sector)
        self._AddVolume(volume)

      volume_extent = volume_system.VolumeExtent(
          start_sector * self.bytes_per_sector,
          number_of_sectors * self.bytes_per_sector)

      self._sections.append(volume_extent)
11875
def ParseFileObject(self, parser_mediator, file_object):
    
    msiecf_file = pymsiecf.file()
    msiecf_file.set_ascii_codepage(parser_mediator.codepage)

    try:
      msiecf_file.open_file_object(file_object)
    except IOError as exception:
      parser_mediator.ProduceExtractionWarning(
          'unable to open file with error: {0!s}'.format(exception))
      return

    try:
      self._ParseItems(parser_mediator, msiecf_file)
    finally:
      msiecf_file.close()
15529
def split_vcf(in_file, ref_file, config, out_dir=None):
    
    if out_dir is None:
        out_dir = os.path.join(os.path.dirname(in_file), "split")
    out_files = []
    with open(ref.fasta_idx(ref_file, config)) as in_handle:
        for line in in_handle:
            chrom, size = line.split()[:2]
            out_file = os.path.join(out_dir,
                                    os.path.basename(replace_suffix(append_stem(in_file, "-%s" % chrom), ".vcf")))
            subset_vcf(in_file, (chrom, 0, size), out_file, config)
            out_files.append(out_file)
    return out_files
717580
def parse_files(options)
 
      file_info = []

      files = options.files
      files = ["."] if files.empty?

      file_list = normalized_file_list(options, files, true)

      file_list.each do |fn|
        $stderr.printf("\n%35s: ", File.basename(fn)) unless options.quiet
        
        content = File.open(fn, "r") {|f| f.read}

        top_level = TopLevel.new(fn)
        parser = ParserFactory.parser_for(top_level, fn, content, options, @stats)
        file_info << parser.scan
        @stats.num_files += 1
      end

      file_info
    end
49527
def do_parse(infilename: str, outfilename: str, verbose: bool) -> bool:
    
    python = parse(FileStream(infilename, encoding="utf-8"), infilename)
    if python is not None:
        with open(outfilename, 'w') as outfile:
            outfile.write(python)
        if verbose:
            print("Output written to {}".format(outfilename))
        return True
    return False
264087
function parseFile (args) {
    var file = args.file;
    var next = args.next;

    try {
      // Optimistically try to parse the file as JSON.
      return JSON.parse(file.data);
    }
    catch (error) {
      if (isJsonFile(file)) {
        // This is a JSON file, but its contents are invalid
        throw error;
      }
      else {
        // This probably isn't a JSON file, so call the next parser plugin
        next();
      }
    }
  }
1257030
def vcf2abook():
    """"""
    from argparse import ArgumentParser, FileType
    from sys import stdin

    parser = ArgumentParser(description='Converter from vCard to Abook syntax.')
    parser.add_argument('infile', nargs='?', type=FileType('r'), default=stdin,
                        help='Input vCard file (default: stdin)')
    parser.add_argument('outfile', nargs='?', default=expanduser('~/.abook/addressbook'),
                        help='Output Abook file (default: ~/.abook/addressbook)')
    args = parser.parse_args()

    Abook.abook_file(args.infile, args.outfile)
141306
def parse_file(filename, parse_direction=False, **kwargs):
    
    importer, parser = make_importer_parser(OSMParser, **kwargs)
    parser.parse(filename)

    return importer.get_graph(parse_direction=parse_direction)
689313
def _parse_file(cls, path, pickle=False):
        """"""

        fname = path
        if fname.endswith(".gz"):
            fname = path[:-3]

        if fname.endswith('.pkl'):
            #you asked for the pickled file. I'll give it to you
            log.debug("loading pickled file %s ..." % fname)
            return cPickle.load( open(fname, "rb") )
        elif os.path.isfile("%s.pkl" % fname):
            #there is a cached version I can give to you
            log.info("loading pickled file %s.pkl ..." % fname)
            if os.stat(path).st_mtime > os.stat("%s.pkl" % fname).st_mtime:
                log.critical("*** pickled file %s.pkl is not up to date ***" % (path))
            return cPickle.load( open("%s.pkl" % fname, "rb") )

        data = fastLoadChain(path, cls._strfactory)
        if pickle and not os.path.isfile('%s.pkl' % fname):
            log.info("pckling to %s.pkl" % (fname))
            with open('%s.pkl' % fname, 'wb') as fd:
                cPickle.dump(data, fd)
        return data
74093
def _parse_singlefile(self, desired_type: Type[T], file_path: str, encoding: str, logger: Logger,
                          options: Dict[str, Dict[str, Any]]) -> T:
        
        # first use the base parser to parse something compliant with the conversion chain
        first = self._base_parser._parse_singlefile(self._converter.from_type, file_path, encoding,
                                                    logger, options)

        # then apply the conversion chain
        return self._converter.convert(desired_type, first, logger, options)