Parses the given log file.

@param {string} filename File to parse
482394
function (filename) {
		var resume = filename === true; // should only ever be set by resume calls
		var fd = this._fd = resume ? this._fd : fs.openSync(filename, 'r');
		var buffer = new Buffer(4096);
		var bytesRead;
		var current = '';
		var remainder = resume ? this._remainder : '';

		while (!this._paused && (bytesRead = fs.readSync(fd, buffer, 0, buffer.length))) {
			current = buffer.toString('utf-8');
			if (current.length > bytesRead) {
				current = current.slice(0, bytesRead);
			}
			remainder = this._remainder = this._parseLines(remainder + current);
		}

		// The loop will end either when EOF is reached, or pause was called.
		// In the former case, close the file; in the latter case, leave it
		// open with the expectation that we'll pick up where we left off.
		if (!this._paused) {
			fs.closeSync(fd);
		}
	}
947996
function loadFromFile(filename) {
  var cfg = {}
  Object.assign(
    cfg,
    loadDefault(),
    JSON.parse(fs.readFileSync(filename))
  )

  return cfg
}
1277789
def parse_file(self, filename=None, buffer=None, fileobj=None):
        """"""
        if filename:
            self.file = GzipFile(filename, 'rb')
        elif buffer:
            if hasattr(buffer, 'name'):
                self.filename = buffer.name
            self.file = buffer
        elif fileobj:
            if hasattr(fileobj, 'name'):
                self.filename = fileobj.name
            self.file = GzipFile(fileobj=fileobj)
        if self.file:
            try:
                type = TAG_Byte(buffer=self.file)
                if type.value == self.id:
                    name = TAG_String(buffer=self.file).value
                    self._parse_buffer(self.file)
                    self.name = name
                    self.file.close()
                else:
                    raise MalformedFileError(
                        "First record is not a Compound Tag")
            except StructError as e:
                raise MalformedFileError(
                    "Partial File Parse: file possibly truncated.")
        else:
            raise ValueError(
                "NBTFile.parse_file(): Need to specify either a "
                "filename or a file object"
            )
1310027
function parseInstallerLog(filepath, searchstring, encoding, callback) {
        var line = "";
        var searchFn = function searchFn(str) {
            var arr = str.split('\n'),
                lineNum,
                pos;
            for (lineNum = arr.length - 1; lineNum >= 0; lineNum--) {
                var searchStrNum;
                for (searchStrNum = 0; searchStrNum < searchstring.length; searchStrNum++) {
                    pos = arr[lineNum].search(searchstring[searchStrNum]);
                    if (pos !== -1) {
                        line = arr[lineNum];
                        break;
                    }
                }
                if (pos !== -1) {
                    break;
                }
            }
            callback(line);
        };

        fs.readFile(filepath, {"encoding": encoding})
            .then(function (str) {
                return searchFn(str);
            }).catch(function () {
                callback("");
            });
    }
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)
  }
}
1359355
public void parse(final String filename, final File dir) {
        filePath = stripFragment(filename);
        dirPath = dir;
        try {
            final File f = new File(dir, filePath);
            reader.setErrorHandler(new DITAOTXMLErrorHandler(f.getAbsolutePath(), logger));
            logger.info("Processing " + f.getAbsolutePath());
            reader.parse(f.toURI().toString());
        } catch (final RuntimeException e) {
            throw e;
        } catch (final Exception e) {
            throw new RuntimeException("Failed to parse " + filename + ": " + e.getMessage(), e);
        }
    }
414906
public static function readLog($filename)
    {
        if (file_exists($filename)) {
            $content = file_get_contents($filename);
            $json = json_decode('[' . $content . ']', true);
        } else {
            $json = '{"msg":"The file does not exist."}';
        }
        return $json;
    }
811597
def parse_file(fname):
        
        try:
            with fopen(fname) as f:
                fstr = f.read()
        except IOError:
            if fname != 'stdin':
                raise
            sys.stdout.write('\nReading from stdin:\n\n')
            fstr = sys.stdin.read()
        fstr = fstr.replace('\r\n', '\n').replace('\r', '\n')
        if not fstr.endswith('\n'):
            fstr += '\n'
        return ast.parse(fstr, filename=fname)
441727
private void parse(String fileName, @WillClose InputStream stream) throws IOException, SAXException {
        try {
            SAXBugCollectionHandler handler = new SAXBugCollectionHandler(this, new File(fileName));
            XMLReader xr = XMLReaderFactory.createXMLReader();
            xr.setContentHandler(handler);
            xr.setErrorHandler(handler);
            Reader reader = Util.getReader(stream);
            xr.parse(new InputSource(reader));
        } finally {
            Util.closeSilently(stream);
        }
    }
155648
function parse_files(files, options) {
  let nodes = {
    // root section node
    '': {
      id: '',
      type: 'section',
      children: [],
      description: '',
      short_description: '',
      href: '#',
      root: true,
      file: '',
      line: 0
    }
  };

  files.forEach(file => {
    let fn = NDoc.parsers[path.extname(file)];

    if (!fn) return;

    /* eslint-disable no-console */
    console.info('Parsing file: ' + file);

    let file_nodes = fn(file, options);

    // TODO:  fail on name clash here as well -- as we might get name clash
    //        from different parsers, or even differnret files
    _.extend(nodes, file_nodes);
  });

  return nodes;
}
271258
def load_file(self, filename):
        
        self._say("Loading file: " + filename)

        fh    = codecs.open(filename, 'r', 'utf-8')
        lines = fh.readlines()
        fh.close()

        self._say("Parsing " + str(len(lines)) + " lines of code from " + filename)
        self._parse(filename, lines)
1082893
def parse_file(self,filename):
        """"""
        try:
            return self.rProgram.ignore(cStyleComment).parseFile(filename, parseAll=True)
        except SemanticException as err:
            print(err)
            exit(3)
        except ParseException as err:
            print(err)
            exit(3)
95793
async function readLogStream(file, instance) {
    return new Promise(resolve => {
        var stream = fs.createReadStream(file, { encoding: 'utf8', highWaterMark: instance.chunkSize });
        var hasStarted = false;
        // Split data into chunks so we dont stall the client
        stream.on('data', chunk => {
            if (!hasStarted) instance.emit("parsingStarted");
            hasStarted = true;
            var lines = chunk.toString().split("\n");
            // Pause stream until this chunk is completed to avoid spamming the thread
            stream.pause();
            async.each(lines, function (line, callback) {
                instance.registerMatch(line);
                callback();
            }, function (err) {
                setTimeout(() => {
                    stream.resume();
                }, instance.chunkInterval);
            });
        });
        stream.on('end', () => {
            instance.emit("parsingComplete");
            resolve();
            stream.close();
        });
    });
}
1026369
private int getLogFileIndex(String fileName) {
		int fileIndex = 0;
		try {
			fileIndex = Integer.parseInt(fileName.substring(fileName
					.lastIndexOf(COUNT_SEPARATOR) + 1));
		} catch (NumberFormatException e) {
			e.printStackTrace();
		}
		return fileIndex;
	}
583289
def parse(self, filename, verbose=0):
        
        run_completed, start_datetime, end_datetime = False, None, None
        filename = os.path.abspath(filename)
        report = EventReport(filename)

        w = WildCard("*Error|*Warning|*Comment|*Bug|*ERROR|*WARNING|*COMMENT|*BUG")
        import warnings
        warnings.simplefilter('ignore', yaml.error.UnsafeLoaderWarning)
        with YamlTokenizer(filename) as tokens:
            for doc in tokens:
                if w.match(doc.tag):
                    #print("got doc.tag", doc.tag,"--")
                    try:
                        #print(doc.text)
                        event = yaml.load(doc.text)   # Can't use ruamel safe_load!
                        #yaml.load(doc.text, Loader=ruamel.yaml.Loader)
                        #print(event.yaml_tag, type(event))
                    except:
                        #raise
                        # Wrong YAML doc. Check tha doc tag and instantiate the proper event.
                        message = "Malformatted YAML document at line: %d\n" % doc.lineno
                        message += doc.text

                        # This call is very expensive when we have many exceptions due to malformatted YAML docs.
                        if verbose:
                            message += "Traceback:\n %s" % straceback()

                        if "error" in doc.tag.lower():
                            print("It seems an error. doc.tag:", doc.tag)
                            event = AbinitYamlError(message=message, src_file=__file__, src_line=0)
                        else:
                            event = AbinitYamlWarning(message=message, src_file=__file__, src_line=0)

                    event.lineno = doc.lineno
                    report.append(event)

                # Check whether the calculation completed.
                if doc.tag == "!FinalSummary":
                    #print(doc)
                    run_completed = True
                    d = doc.as_dict()
                    #print(d)
                    start_datetime, end_datetime = d["start_datetime"], d["end_datetime"]

        report.set_run_completed(run_completed, start_datetime, end_datetime)
        return report
272025
public function parseFile($filename)
    {
        $data = json_decode(file_get_contents($filename), true);

        return (array)$this->parse($data, $filename);
    }
511813
public JCTree.JCCompilationUnit parse(JavaFileObject filename) {
        JavaFileObject prev = log.useSource(filename);
        try {
            JCTree.JCCompilationUnit t = parse(filename, readSource(filename));
            if (t.endPositions != null)
                log.setEndPosTable(filename, t.endPositions);
            return t;
        } finally {
            log.useSource(prev);
        }
    }