Single place to do the flex cdx-line parsing logic
495589
public static CaptureSearchResult parseCDXLineFlex(String line) {
		CaptureSearchResult result = new CaptureSearchResult();
		return parseCDXLineFlex(line, result);
	}
498868
function grepLines(src, ext, destFile){
      src = grunt.util.normalizelf(src);
      var lines = src.split(grunt.util.linefeed),
          dest = [],
          //pattern for all comments containing denotation
          denotationPattern = updatePattern({
            pattern: options.pattern, 
            ext: ext, 
            isDenotationPattern: true}),
          //pattern for one-line grep usage
          pattern = updatePattern({
            pattern: options.pattern, 
            ext: ext}),
          //patterns for multi-line grep usage
          startPattern = updatePattern({
            pattern:options.pattern, 
            augmentPattern: options.startPattern,
            ext: ext}),
          endPattern = updatePattern({
            pattern: options.pattern, 
            augmentPattern: options.endPattern,
            ext: ext});
        if (pattern !== false){
          var startedRemoving;
          //loop over each line looking for either pattern or denotation comments
          lines.forEach(function(line) {
            if (!startedRemoving){
              //looking for one-line or start of multi-line pattern 
              if (line.search(startPattern) === -1 ){
              //looking for one-line or start of one-line pattern 
                if (line.search(pattern) === -1 ){
                  //looking for denotation comments 
                  if (options.removeDenotationComments && line.search(denotationPattern) !== -1){
                    var lineDenotationLess = line.replace(new RegExp(denotationPattern), '');
                    dest.push(lineDenotationLess);
                  } else {
                    //none of patterns found
                    dest.push(line);
                  }
                }
              } else{
                //multi-line found
                startedRemoving = true;
              }
            } else {
              //looking for end of multi-line pattern 
              if (line.search(endPattern) !== -1 ){
                startedRemoving = false;
              }
            }
          });
          var destText = dest.join(grunt.util.linefeed);
          if (grunt.file.exists(destFile)){
            if (!options.fileOverride){
              grunt.fail.warn('File "' + destFile + '" already exists, though is specified as a dest file. ' +
                'Turn on option "fileOverride" so that old file is removed first.');
            } else {
              grunt.file.delete(destFile);
            }
          }
          grunt.file.write(destFile, destText);

          grunt.log.writeln('File "' + destFile + '" created.');
        } else {
          grunt.log.warn('Pattern for \'' + task.target + '\' should be a string.');
        }
    }
693422
public static void createCDXIndexFile(String urlOrPath)
    throws IOException, java.text.ParseException {
        ARCReader r = ARCReaderFactory.get(urlOrPath);
        r.setStrict(false);
        r.setParseHttpHeaders(true);
        r.setDigest(true);
        output(r, CDX_FILE);
    }
531884
def _bsecurate_cli_component_file_refs(args):
    ''''''
    data = curate.component_file_refs(args.files)

    s = ''

    for cfile, cdata in data.items():
        s += cfile + '\n'
        rows = []
        for el, refs in cdata:
            rows.append(('    ' + el, ' '.join(refs)))
        s += '\n'.join(format_columns(rows)) + '\n\n'

    return s
701548
def main():
    

    scheme_names = sorted(six.iterkeys(SCHEME))
    version_str = pkg_resources.get_distribution('ansi2html').version
    parser = optparse.OptionParser(
        usage=main.__doc__,
        version="%%prog %s" % version_str)
    parser.add_option(
        "-p", "--partial", dest="partial",
        default=False, action="store_true",
        help="Process lines as them come in.  No headers are produced.")
    parser.add_option(
        "-L", "--latex", dest="latex",
        default=False, action="store_true",
        help="Export as LaTeX instead of HTML.")
    parser.add_option(
        "-i", "--inline", dest="inline",
        default=False, action="store_true",
        help="Inline style without headers or template.")
    parser.add_option(
        "-H", "--headers", dest="headers",
        default=False, action="store_true",
        help="Just produce the <style> tag.")
    parser.add_option(
        "-f", '--font-size', dest='font_size', metavar='SIZE',
        default="normal",
        help="Set the global font size in the output.")
    parser.add_option(
        "-l", '--light-background', dest='light_background',
        default=False, action="store_true",
        help="Set output to 'light background' mode.")
    parser.add_option(
        "-W", '--no-line-wrap', dest='no_line_wrap',
        default=False, action="store_true",
        help="Disable line wrapping.")
    parser.add_option(
        "-a", '--linkify', dest='linkify',
        default=False, action="store_true",
        help="Transform URLs into <a> links.")
    parser.add_option(
        "-u", '--unescape', dest='escaped',
        default=True, action="store_false",
        help="Do not escape XML tags found in the input.")
    parser.add_option(
        "-m", '--markup-lines', dest="markup_lines",
        default=False, action="store_true",
        help="Surround lines with <span id='line-n'>..</span>.")
    parser.add_option(
        '--input-encoding', dest='input_encoding', metavar='ENCODING',
        default='utf-8',
        help="Specify input encoding")
    parser.add_option(
        '--output-encoding', dest='output_encoding', metavar='ENCODING',
        default='utf-8',
        help="Specify output encoding")
    parser.add_option(
        '-s', '--scheme', dest='scheme', metavar='SCHEME',
        default='ansi2html', choices=scheme_names,
        help=("Specify color palette scheme. Default: %%default. Choices: %s"
              % scheme_names))
    parser.add_option(
        '-t', '--title', dest='output_title',
        default='',
        help="Specify output title")

    opts, args = parser.parse_args()

    conv = Ansi2HTMLConverter(
        latex=opts.latex,
        inline=opts.inline,
        dark_bg=not opts.light_background,
        line_wrap=not opts.no_line_wrap,
        font_size=opts.font_size,
        linkify=opts.linkify,
        escaped=opts.escaped,
        markup_lines=opts.markup_lines,
        output_encoding=opts.output_encoding,
        scheme=opts.scheme,
        title=opts.output_title,
    )

    if six.PY3:
        try:
            sys.stdin = io.TextIOWrapper(sys.stdin.detach(), opts.input_encoding, "replace")
        except io.UnsupportedOperation:
            # This only fails in the test suite...
            pass

    def _read(input_bytes):
        if six.PY3:
            return input_bytes
        else:
            return input_bytes.decode(opts.input_encoding)

    def _print(output_unicode, end='\n'):
        if hasattr(sys.stdout, 'buffer'):
            output_bytes = (output_unicode + end).encode(opts.output_encoding)
            sys.stdout.buffer.write(output_bytes)
        elif not six.PY3:
            sys.stdout.write((output_unicode + end).encode(opts.output_encoding))
        else:
            sys.stdout.write(output_unicode + end)

    # Produce only the headers and quit
    if opts.headers:
        _print(conv.produce_headers(), end='')
        return

    full = not bool(opts.partial or opts.inline)
    if six.PY3:
        output = conv.convert("".join(sys.stdin.readlines()), full=full, ensure_trailing_newline=True)
        _print(output, end='')
    else:
        output = conv.convert(six.u("").join(
            map(_read, sys.stdin.readlines())
        ), full=full, ensure_trailing_newline=True)
        _print(output, end='')
622566
def parse_fixed_width(types, lines):
    """"""
    values = []
    line = []
    for width, parser in types:
        if not line:
            line = lines.pop(0).replace('\n', '')

        values.append(parser(line[:width]))
        line = line[width:]

    return values
392152
function parseAwsIni(ini) {
  var section,
      out = Object.create(null),
      re = /^\[([^\]]+)\]\s*$|^([a-z_]+)\s*=\s*(.+?)\s*$/,
      lines = ini.split(/\r?\n/)

  lines.forEach(function(line) {
    var match = line.match(re)
    if (!match) return
    if (match[1]) {
      section = match[1]
      if (out[section] == null) out[section] = Object.create(null)
    } else if (section) {
      out[section][match[2]] = match[3]
    }
  })

  return out
}
1140387
function astFromSource(options, source, extension, cb) {
  if (typeof cb === 'undefined') {
    cb = extension;
    extension = null;
  }
  pegParser(options, extension, function (err, parser, key) {
    if (err) {
      return cb(err);
    }
    var ast;
    try {
      ast = parser.parse(source);
      addLineNumbers(ast, source);
      if (ast.type === 'program') {
        ast.type = 'script';
      } else if (ast.type === 'markdown') {
        ast.content = source;
      }
      ast.grammarFile = key;
      // adding in comment nodes, in case they get added to the grammar later
      walk(ast, function (node) {
        if (!node.comments && node.type !== 'undefined') {
          node.comments = [];
        }
      });
      //console.log(JSON.stringify(ast, null, 2));
    } catch (e) {
      return cb(e);
    }
    return cb(null, ast);
  });
}
1308517
def _parse_xfs_info(data):
    '''
    
    '''
    ret = {}
    spr = re.compile(r'\s+')
    entry = None
    for line in [spr.sub(" ", l).strip().replace(", ", " ") for l in data.split("\n")]:
        if not line:
            continue
        nfo = _xfs_info_get_kv(line)
        if not line.startswith("="):
            entry = nfo.pop(0)
            ret[entry[0]] = {'section': entry[(entry[1] != '***' and 1 or 0)]}
        ret[entry[0]].update(dict(nfo))

    return ret
496540
function parseLine(line, lineno, options) {
	let command = null;
	const lineContinuationRegex = (options && options.lineContinuationRegex
		|| TOKEN_LINE_CONTINUATION);

	line = line.trim();

	if (!line) {
		// Ignore empty lines
		return { command: null, remainder: '' };
	}

	if (isComment(line)) {
		// Handle comment lines.
		command = { name: 'COMMENT', args: line, lineno: lineno };
		return { command: command, remainder: '' };
	}

	if (line.match(lineContinuationRegex)) {
		// Line continues on next line.
		const remainder = line.replace(lineContinuationRegex, '', 'g');
		return { command: null, remainder: remainder };
	}

	command = splitCommand(line);
	command.lineno = lineno;

	let commandParserFn = commandParsers[command.name];
	if (!commandParserFn) {
		// Invalid Dockerfile instruction, but allow it and move on.
		// log.debug('Invalid Dockerfile command:', command.name);
		commandParserFn = parseString;
	}

	if (commandParserFn(command)) {
		// Successfully converted the arguments.
		command.raw = line;
		delete command.rest;
	}

	return { command: command, remainder: '' };
}
1155267
private void parseRxnCXSMILES(String title, IReaction rxn) {
        CxSmilesState cxstate;
        int pos;
        if (title != null && title.startsWith("|")) {
            if ((pos = CxSmilesParser.processCx(title, cxstate = new CxSmilesState())) >= 0) {

                // set the correct title
                rxn.setProperty(CDKConstants.TITLE, title.substring(pos));

                final Map<IAtom, IAtomContainer> atomToMol = new HashMap<>(100);
                final List<IAtom> atoms = new ArrayList<>();
                handleFragmentGrouping(rxn, cxstate);

                // merge all together
                for (IAtomContainer mol : rxn.getReactants().atomContainers()) {
                    for (IAtom atom : mol.atoms()) {
                        atoms.add(atom);
                        atomToMol.put(atom, mol);
                    }
                }
                for (IAtomContainer mol : rxn.getAgents().atomContainers()) {
                    for (IAtom atom : mol.atoms()) {
                        atoms.add(atom);
                        atomToMol.put(atom, mol);
                    }
                }
                for (IAtomContainer mol : rxn.getProducts().atomContainers()) {
                    for (IAtom atom : mol.atoms()) {
                        atoms.add(atom);
                        atomToMol.put(atom, mol);
                    }
                }

                assignCxSmilesInfo(rxn.getBuilder(), rxn, atoms, atomToMol, cxstate);
            }
        }
    }
468829
def _parse_content(fh):
    """"""
    content = iter(fh)
    deps = {}

    for line in content:
        # quickly discard most of the lines
        if 'fades' not in line:
            continue

        # discard other string with 'fades' that isn't a comment
        if '#' not in line:
            continue

        # assure that it's a well commented line and no other stuff
        line = line.strip()
        index_of_last_fades = line.rfind('fades')
        index_of_first_hash = line.index('#')

        # discard when fades does not appear after #
        if index_of_first_hash > index_of_last_fades:
            continue

        import_part, fades_part = line.rsplit("#", 1)

        # discard other comments in the same line that aren't for fades
        if "fades" not in fades_part:
            import_part, fades_part = import_part.rsplit("#", 1)

        fades_part = fades_part.strip()
        if not fades_part.startswith("fades"):
            continue

        if not import_part:
            # the fades comment was done at the beginning of the line,
            # which means that the import info is in the next one
            import_part = next(content).strip()

        if import_part.startswith('#'):
            continue

        # get module
        import_tokens = import_part.split()
        if import_tokens[0] == 'import':
            module_path = import_tokens[1]
        elif import_tokens[0] == 'from' and import_tokens[2] == 'import':
            module_path = import_tokens[1]
        else:
            logger.debug("Not understood import info: %s", import_tokens)
            continue
        module = module_path.split(".")[0]
        # If fades know the real name of the pkg. Replace it!
        if module in PKG_NAMES_DB:
            module = PKG_NAMES_DB[module]
        # To match the "safe" name that pkg_resources creates:
        module = module.replace('_', '-')

        # get the fades info after 'fades' mark, if any
        if len(fades_part) == 5 or fades_part[5:].strip()[0] in "<>=!":
            # just the 'fades' mark, and maybe a version specification, the requirement is what
            # was imported (maybe with that version comparison)
            requirement = module + fades_part[5:]
        elif fades_part[5] != " ":
            # starts with fades but it's part of a longer weird word
            logger.warning("Not understood fades info: %r", fades_part)
            continue
        else:
            # more complex stuff, to be parsed as a normal requirement
            requirement = fades_part[5:]

        # parse and convert the requirement
        parsed_req = parse_fade_requirement(requirement)
        if parsed_req is None:
            continue
        repo, dependency = parsed_req
        deps.setdefault(repo, []).append(dependency)

    return deps
130478
def Engauge_2d_parser(lines, flat=False):
    '''
    '''
    z_values = []
    x_lists = []
    y_lists = []
    working_xs = []
    working_ys = []
    
    new_curve = True
    for line in lines:
        if line.strip() == '':
            new_curve = True
        elif new_curve:
            z = float(line.split(',')[1])
            z_values.append(z)
            if working_xs and working_ys:
                x_lists.append(working_xs)
                y_lists.append(working_ys)
            working_xs = []
            working_ys = []
            new_curve = False
        else:
            x, y = [float(i) for i in line.strip().split(',')]
            working_xs.append(x)
            working_ys.append(y)
    x_lists.append(working_xs)
    y_lists.append(working_ys)
    
    if flat:
        all_zs = []
        all_xs = []
        all_ys = []
        for z, xs, ys in zip(z_values, x_lists, y_lists):
            for x, y in zip(xs, ys):
                all_zs.append(z)
                all_xs.append(x)
                all_ys.append(y)
        return all_zs, all_xs, all_ys

    return z_values, x_lists, y_lists
1236956
function() {

    // Grab JXCore bin
    var jxBin = require('jxcore').findpath();

    // "Constants"
    var pkgName = 'kbox-' + common.kalabox.pkgType;
    var shellOpts = {
      execOptions: {
        cwd: 'build/cli',
        maxBuffer: 20 * 1024 * 1024
      }
    };

    // Include patterns
    var jxAddPatterns = common.files.jxAdd;

    // Exclude patterns
    var jxSlimPatterns = common.files.jxSlim;

    // JX package command
    var jxCmd = [
      jxBin,
      'package',
      'bin/kbox.js',
      pkgName,
      '--add "' + jxAddPatterns.join(',') + '"',
      '--slim "' + jxSlimPatterns.join(',') + '"',
      '--native'
    ].join(' ');

    // Start to build the command
    var cmd = [];
    cmd.push(npmInstallCmd());
    cmd.push(jxCmd);

    // Add executable perms on POSIX
    if (platform !== 'win32') {
      cmd.push('chmod +x ' + pkgName);
      cmd.push('sleep 2');
    }

    // Return the CLI build task
    return {
      options: shellOpts,
      command: cmd.join(' && ')
    };

  }
1298835
@Override
    protected ConfigElement processTextLine(String configfile, int lineno, String line) throws ConfigParseException
    {
        ConfigElement configElement;

        if ((line.trim().startsWith("exten") || line.trim().startsWith("include")) && currentCategory != null
                && (currentCategory.getName().equals("general") || currentCategory.getName().equals("globals")))
            throw new ConfigParseException(configfile, lineno,
                    "cannot have 'exten' or 'include' in global or general sections");

        /*
         * Goal here is to break out anything unique that we might want to look
         * at and parse separately. For now, only exten and include fit that
         * criteria. Eventually, I could see parsing sections for things from
         * macros, contexts to differentiate them from categories, switch for
         * realtime, and more.
         */
        if (line.trim().startsWith("exten"))
        {
            configElement = parseExtension(configfile, lineno, line);
            currentCategory.addElement(configElement);
            return configElement;
        }
        else if (line.trim().startsWith("include"))
        {
            // use parseVariable since we have access to it
            ConfigVariable configvar = parseVariable(configfile, lineno, line);
            configElement = new ConfigInclude(configfile, lineno, configvar.getValue());
            currentCategory.addElement(configElement);
            return configElement;
        }

        // leave everything else the same
        configElement = super.processTextLine(configfile, lineno, line);

        return configElement;
    }
956372
function parseRawLines(rawText, extendedSyntax, parsedRawLinesCallback) {
        var entries = rawText.replace(reBlank, '').split(/[\r\n]+/);
        var currentLang = '*';
        var genericLang = lang.split('-', 1)[0];
        var skipLang = false;
        var match = '';

        function nextEntry() {
          // Use infinite loop instead of recursion to avoid reaching the
          // maximum recursion limit for content with many lines.
          while (true) {
            if (!entries.length) {
              parsedRawLinesCallback();
              return;
            }
            var line = entries.shift();

            // comment or blank line?
            if (reComment.test(line))
              continue;

            // the extended syntax supports [lang] sections and @import rules
            if (extendedSyntax) {
              match = reSection.exec(line);
              if (match) { // section start?
                // RFC 4646, section 4.4, "All comparisons MUST be performed
                // in a case-insensitive manner."

                currentLang = match[1].toLowerCase();
                skipLang = (currentLang !== '*') &&
                    (currentLang !== lang) && (currentLang !== genericLang);
                continue;
              } else if (skipLang) {
                continue;
              }
              match = reImport.exec(line);
              if (match) { // @import rule?
                loadImport(baseURL + match[1], nextEntry);
                return;
              }
            }

            // key-value pair
            var tmp = line.match(reSplit);
            if (tmp && tmp.length == 3) {
              dictionary[tmp[1]] = evalString(tmp[2]);
            }
          }
        }
        nextEntry();
      }
1297009
function Lexer(text, cfg) {
        var self = this;
        self.page = new Page(text);
        self.cursor = new Cursor();
        self.nodeFactory = this;
        this.cfg = cfg || {};
    }