Parses a file or directory of files into a set of ``Document`` objects.
323099
def _generate(self):
        """"""
        doc_count = 0
        for fp in self.all_files:
            for doc in self._get_docs_for_path(fp):
                yield doc
                doc_count += 1
                if doc_count >= self.max_docs:
                    return
843264
function parse(context, file) {
  var message

  if (stats(file).fatal) {
    return
  }

  if (context.treeIn) {
    debug('Not parsing already parsed document')

    try {
      context.tree = json(file.toString())
    } catch (error) {
      message = file.message(
        new Error('Cannot read file as JSON\n' + error.message)
      )
      message.fatal = true
    }

    /* Add the preferred extension to ensure the file, when compiled, is
     * correctly recognized. Only add it if there’s a path — not if the
     * file is for example stdin. */
    if (file.path) {
      file.extname = context.extensions[0]
    }

    file.contents = ''

    return
  }

  debug('Parsing `%s`', file.path)

  context.tree = context.processor.parse(file)

  debug('Parsed document')
}
615527
def read_set_from_file(filename: str) -> Set[str]:
    
    collection = set()
    with open(filename, 'r') as file_:
        for line in file_:
            collection.add(line.rstrip())
    return collection
436848
def parse(self, limit=None):
        
        if limit is not None:
            LOG.info("Only parsing first %s rows fo each file", str(limit))

        LOG.info("Parsing files...")

        if self.test_only:
            self.test_mode = True

        # for f in ['impc', 'euro', 'mgd', '3i']:
        for f in ['all']:
            file = '/'.join((self.rawdir, self.files[f]['file']))
            self._process_data(file, limit)

        LOG.info("Finished parsing")

        return
559132
def parseFile( self, file_or_filename ):
        
        try:
            file_contents = file_or_filename.read()
        except AttributeError:
            f = open(file_or_filename, "rb")
            file_contents = f.read()
            f.close()
        return self.parseString(file_contents)
317404
def _parse_document(document: Path, system: System = None, profile=EProfile.FULL):
        
        logger.debug('parse document: {0}'.format(document))
        stream = FileStream(str(document), encoding='utf-8')
        system = FileSystem._parse_stream(stream, system, document, profile)
        FileSystem.merge_annotations(system, document.stripext() + '.yaml')
        return system
635380
def parse_document(lexer: Lexer) -> DocumentNode:
    """"""
    start = lexer.token
    return DocumentNode(
        definitions=many_nodes(lexer, TokenKind.SOF, parse_definition, TokenKind.EOF),
        loc=loc(lexer, start),
    )
397049
function parseFile (file, content) {
  let type = getParseType(file)

  debug('parse file: file = %s, parseType = %s', file, type)

  if (type in parser) {
    if (typeof content !== 'string') {
      content = fs.readFileSync(file, 'utf8')
    }

    return parser[type](content)
  }
}
256805
def DoxyfileParse(file_contents):
   
   data = {}

   import shlex
   lex = shlex.shlex(instream = file_contents, posix = True)
   lex.wordchars += "*+./-:"
   lex.whitespace = lex.whitespace.replace("\n", "")
   lex.escape = ""

   lineno = lex.lineno
   token = lex.get_token()
   key = token   # the first token should be a key
   last_token = ""
   key_token = False
   next_key = False
   new_data = True

   def append_data(data, key, new_data, token):
      if new_data or len(data[key]) == 0:
         data[key].append(token)
      else:
         data[key][-1] += token

   while token:
      if token in ['\n']:
         if last_token not in ['\\']:
            key_token = True
      elif token in ['\\']:
         pass
      elif key_token:
         key = token
         key_token = False
      else:
         if token == "+=":
            if not data.has_key(key):
               data[key] = list()
         elif token == "=":
            if key == "TAGFILES" and data.has_key(key):
               append_data( data, key, False, "=" )
               new_data=False
            else:
               data[key] = list()
         else:
            append_data( data, key, new_data, token )
            new_data = True

      last_token = token
      token = lex.get_token()

      if last_token == '\\' and token != '\n':
         new_data = False
         append_data( data, key, new_data, '\\' )

   # compress lists of len 1 into single strings
   for (k, v) in data.items():
      if len(v) == 0:
         data.pop(k)

      # items in the following list will be kept as lists and not converted to strings
      if k in ["INPUT", "FILE_PATTERNS", "EXCLUDE_PATTERNS", "TAGFILES"]:
         continue

      if len(v) == 1:
         data[k] = v[0]

   return data
481836
public Document parse(File file) throws SAXException, IOException
    {
        return verify(_WrappedBuilder.parse(file));
    }
681487
function _extractFiles (dir, callback) {

			if ("undefined" === typeof dir) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof dir) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === dir.trim()) {
					throw new Error("\"directory\" argument is empty");
				}
			else if ("undefined" === typeof callback) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				const _dir = dir.trim();

				isDirectoryProm(_dir).then((exists) => {
					return exists ? Promise.resolve() : Promise.reject(new Error("\"" + _dir + "\" is not a valid directory"));
				}).then(() => {

					readdir(_dir, (_err, files) => {
						return _err ? callback(_err) : _extractRealFiles(_dir, files, [], callback);
					});

				}).catch(callback);

			}

		}
89638
function parseDirectory( path ) {

            return fs.readdirSync( path )

                .map( function( file ) {

                    var filePath = path + "/" + file;

                    if ( isIncludeFile( filePath ) ) return parseFile( filePath );
                    else if ( isDirectory( filePath ) ) return parseDirectory( filePath );

                    return null;
                } )

                .filter( function( value ) {

                    return value !== null;

                } );
        }
1332957
def parse_file(self, file_or_fname):
        
        with self._context():
            if hasattr(file_or_fname, 'read'):
                self.filename = getattr(
                    file_or_fname, 'name', file_or_fname.__class__.__name__)
                self.p.ParseFile(file_or_fname)
            else:
                self.filename = file_or_fname
                with open(file_or_fname, 'rb') as f:
                    self.p.ParseFile(f)
        return self._root
915876
function parseFile(dir, filename) {
  const filePath = path.join(dir, filename);
  const fileStat = fs.statSync(filePath);
  const fileExt = path.extname(filename);

  return {
    path: filePath,
    stat: fileStat,
    ext: fileExt
  };
}
169338
def Parse(self, filename, feed):
    
    dom = minidom.parse(filename)
    self.ParseDom(dom, feed)
690863
function(files) {
		var regex;
		if (options.webroot instanceof RegExp) {
			regex = options.webroot;
		} else {
			regex = new RegExp('^' + options.webroot);
		}
		_.each(files, function (value, key) {
			files[key] = value.replace(regex, '');
		});
		return files;
	}
856125
def ParseMultiple(self, stats, file_objects, knowledge_base):
    """"""
    _ = knowledge_base

    # Collate files into path: contents dictionary.
    found_files = self._Combine(stats, file_objects)

    # Determine collected files and apply weighting.
    weights = [w for w in self.WEIGHTS if w.path in found_files]
    weights = sorted(weights, key=lambda x: x.weight)

    for _, path, handler in weights:
      contents = found_files[path]
      obj = handler(contents)

      complete, result = obj.Parse()
      if result is None:
        continue
      elif complete:
        yield rdf_protodict.Dict({
            'os_release': result.release,
            'os_major_version': result.major,
            'os_minor_version': result.minor
        })
        return

    # Amazon AMIs place release info in /etc/system-release.
    # https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/amazon-linux-ami-basics.html
    system_release = found_files.get('/etc/system-release', None)
    if system_release and 'Amazon Linux' in system_release:
      match_object = ReleaseFileParseHandler.RH_RE.search(system_release)
      if match_object and match_object.lastindex > 1:
        yield rdf_protodict.Dict({
            'os_release': 'AmazonLinuxAMI',
            'os_major_version': int(match_object.group(1)),
            'os_minor_version': int(match_object.group(2))
        })
        return

    # Fall back to /etc/os-release.
    results_dict = self._ParseOSReleaseFile(found_files)
    if results_dict is not None:
      yield results_dict
      return

    # No successful parse.
    yield rdf_anomaly.Anomaly(
        type='PARSER_ANOMALY', symptom='Unable to determine distribution.')