According to rate, get matching.

@param {object} file nodeJS file object.
@param {string} license The license template string.
@param {float} rate Matching rate.
@param {string} srcNLReg new line char code.
@returns {boolean} dose match.
513499
function isMatch(file, license, rate, srcNLReg) {
        var srcLines = file.contents.toString('utf8').split(/\r?\n/),
                templateLines = license.split(/\r?\n/),
                type = path.extname(file.path),
                matchRates = 0,
                removed = false;

        // after '<?php' has new line, remove it 
        switch (type) {
            case '.php':
                if (srcLines[1].replace(/\s/, '') === '') {
                    srcLines.splice(1, 1);
                    removed = true;
                }
                break;
            default:
                break;
        }

        // count match line
        var minLength = templateLines.length > srcLines.length ? srcLines.length : templateLines.length;
        for (var i = 0; i < minLength; i++) {
            if (templateLines[templateLines.length - 1] === '' && i === templateLines.length - 1) {
                matchRates += 1;
            } else {
                switch (type) {
                    case '.php':
                        matchRates += getMatchRate(srcLines[i + 1], templateLines[i]);
                        break;
                    default:
                        matchRates += getMatchRate(srcLines[i], templateLines[i]);
                        break;
                }
            }
        }

        // has similar license, remove the license.
        var matchPer = matchRates / templateLines.length;

        if (matchPer >= rate && matchPer < 1) {
            // remove
            switch (type) {
                case '.php':
                    if (srcLines[templateLines.length].replace(/\s/, '') === '' && !removed) {
                        // after license, should be have a blank line. if has not, we don't need remove blank line. && after '<?php' has not new line
                        srcLines.splice(1, templateLines.length);
                    } else {
                        srcLines.splice(1, templateLines.length - 1);
                    }
                    file.contents = new Buffer(srcLines.join(srcNLReg));
                    break;
                default:
                    // after license, should be have a blank line. if have not, we don't need remove blank line.
                    if (srcLines[templateLines.length - 1].replace(/\s/, '') === '') {
                        srcLines.splice(0, templateLines.length);
                    } else {
                        srcLines.splice(0, templateLines.length - 1);
                    }
                    file.contents = new Buffer(srcLines.join(srcNLReg));
                    break;
            }
            return false;
        } else if (matchPer === 1) {
            return true;
        }
    }
1143767
def get_license_from_url(url):
    
    if not url:
        return

    split_url = urlsplit(url, scheme='http')

    if split_url.netloc.lower() == 'creativecommons.org':
        if 'publicdomain' in split_url.path:
            match = _RE_PUBLIC_DOMAIN_URL.match(split_url.path)
            if match is None:
                license = ['public domain']
            else:
                license = ['CC0']
                license.extend(part for part in match.groups() if part)
        else:
            license = ['CC']
            match = _RE_LICENSE_URL.match(split_url.path)
            license.extend(part.upper() for part in match.groups() if part)
    elif split_url.netloc == 'arxiv.org':
        license = ['arXiv']
        match = _RE_LICENSE_URL.match(split_url.path)
        license.extend(part for part in match.groups() if part)
    else:
        raise ValueError('Unknown license URL')

    return u' '.join(license)
498737
def run_gvcftyper(vrn_files, out_file, region, data):
    
    if not utils.file_exists(out_file):
        with file_transaction(data, out_file) as tx_out_file:
            license = license_export(data)
            ref_file = dd.get_ref_file(data)
            input_files = " ".join(vrn_files)
            region = bamprep.region_to_gatk(region)
            cmd = ("{license}sentieon driver -r {ref_file} --interval {region} "
                   "--algo GVCFtyper {tx_out_file} {input_files}")
            do.run(cmd.format(**locals()), "Sentieon GVCFtyper")
    return out_file
120502
def build_license_file(directory, spec):
    
    name, text = '', ''

    try:
        name = spec['LICENSE']
        text = spec['X_MSI_LICENSE_TEXT']
    except KeyError:
        pass # ignore this as X_MSI_LICENSE_TEXT is optional

    if name!='' or text!='':
        file = open( os.path.join(directory.get_path(), 'License.rtf'), 'w' )
        file.write('{\\rtf')
        if text!='':
             file.write(text.replace('\n', '\\par '))
        else:
             file.write(name+'\\par\\par')
        file.write('}')
        file.close()
404672
def license(self, license):
        
        allowed_values = ["Public Domain", "PDDL", "CC-0", "CC-BY", "ODC-BY", "CC-BY-SA", "ODC-ODbL", "CC BY-NC", "CC BY-NC-SA", "Other"]
        if license not in allowed_values:
            raise ValueError(
                "Invalid value for `license` ({0}), must be one of {1}"
                .format(license, allowed_values)
            )

        self._license = license
274754
function parse_markdown(file, options, callback) { 
  fs.readFile(file, 'utf8', function (err, source) {
    if (err) {
      callback(err);
      return;
    }
    var sourceLines = source.split("\n");
    var metaExpr = /\{(([\"\']).+\1\s*:\s*[\"\'].+\1)\}/g;
    var metaString;

    var firstClass = {
        found: false,
        name: ""
    };
    var re;

    if (re = sourceLines[0].match(/^\#{1}\s+(.+)/)) { // if #, it's a title
        var metaString = sourceLines[1].match(metaExpr);

        if (!metaString) {
            console.error("Error".red + ": on " + file + " you started with #, but provided no context--that's bad.");
            process.exit(1);
        }

        var metaJson = JSON.parse(metaString);

        if (metaJson.type == 'misc') {
            var title = sourceLines[0].substr(2).replace(/(\w) /g, "$1");
            sourceLines[0] = "/** section: " + title + "\n";
            sourceLines[1] = "* class " + title;

            for (l = 2; l < sourceLines.length; l++) {
                sourceLines[l] = "* " + sourceLines[l];
            }
            sourceLines.push("**/");
            return pdoc_parser("", {registered: true, source: sourceLines.join("\n"), file: file, options: options, callback: callback});
        }
        else {
            console.error("In " + file + " I did not understand the type '" + metaJson.type + "'");
        }
    }
    else if (re = sourceLines[0].match(/^\#{2}\s+(.+)/)) { // if ##, it's a class
        if (!firstClass.found) {
            firstClass.found = true;
            firstClass.name = re[1];
            sourceLines[0] = "/**\n* " + "class " + firstClass.name;
            if ( (metaString = sourceLines[1].match(metaExpr) ) ) {
                var metaString = metaString[0].replace("(", "").replace(")", "");
                sourceLines[0] = "/** " + metaString + "\n* " + "class " + firstClass.name;
                sourceLines[1] = "* ";
            }
            else
                sourceLines[1] = "* ";
        }
    }
    else {
        console.error("Error".red + ": first line in " + file + " is neither # or ##--that's bad.");
        process.exit(1);
    }

    for (var l = 2; l < sourceLines.length; l++) {
        if (re = sourceLines[l].match(/^\#{2}\s+(.+)/)) { // if ##, it's a class
            if (!firstClass.found) {
                firstClass.found = true;
                firstClass.name = re[1];
                sourceLines[l] = "/**\n* " + sourceLines[l].replace("##", "class " + firstClass.name);
            }
            else {
                if (re[1].indexOf("<") < 0) {
                    sourceLines[l] = "**/\n\n/**\n* " + "class " + re[1] + " < " + firstClass.name;
                }
                else {
                    sourceLines[l] = "**/\n\n/**\n* " + "class " + re[1];
                }
            }
        }
        else if (sourceLines[l].match(/^\#{3}\s+/)) { // if ###, it's a member
            var startingDefPos = l;
            sourceLines[l] = "**/\n\n/**\n* " + sourceLines[l].replace("###", "");
            var n = l + 1;

            while (sourceLines[n].match(/^\#{3}\s+/)) { // it has aliases
                sourceLines[n] = " " + sourceLines[n].replace("###", "");
                n++;
            }

            var tagRE = sourceLines[n].match(/^(\((.+)\))$/);
            if (tagRE) { // if it's got tags, add them appropriately to the starting /**
                sourceLines[l] = sourceLines[l].replace("/**", "/** " + tagRE[2]);
                sourceLines[n] = "";
                n++;
            }
           // while (sourceLines[n].match(/[-|*|+]\s*.+?\s*{.+?}\s*/)) {
             //   sourceLines[n] = sourceLines[n].replace("{", "(").replace("}", "):");
             /*   n++;
            } */
        }
        else { // catch tags after param lists
            var tagRE = sourceLines[l].match(/^(\((.+)\))$/);
            var indentedParam = sourceLines[l].match(/^\s+[*|-]/);
            
            if (tagRE) { // if it's got tags, add them appropriately to the starting /**
                sourceLines[startingDefPos] = sourceLines[startingDefPos].replace("/**", "/** " + tagRE[2]);
                sourceLines[l] = "";
            }
            else if (indentedParam) {
                // noop
            }
            else { // everything else just prefix with a "*"
                 sourceLines[l] = "*" + sourceLines[l];
            }
        }
    }

    sourceLines.push("**/");

    pdoc_parser("", {registered: true, source: sourceLines.join("\n"), file: file, options: options, callback: callback});
  });
}
179440
def match(license):
    ''''''
    if license not in VALID_LICENSES:
        for l1 in _split_license(license):
            if l1 in VALID_LICENSES:
                continue
            for l2 in _split_license(l1):
                if l2 not in VALID_LICENSES:
                    return False
                    valid_license = False
    return True
177441
protected boolean doesFileMatch(final File file, final CSNodeWrapper node) {
        if (!node.getNodeType().equals(CommonConstants.CS_NODE_FILE)) return false;

        // If the unique id is not from the parser, in which case it will start with a number than use the unique id to compare
        if (file.getUniqueId() != null && file.getUniqueId().matches("^\\d.*")) {
            return file.getUniqueId().equals(Integer.toString(node.getId()));
        } else {
            // Since a content spec doesn't contain the database ids for the nodes use what is available to see if the files match
            return file.getId().equals(node.getEntityId());
        }
    }
66625
def custom_licenses(self):
        
        buf = (ctypes.c_char * self.MAX_BUF_SIZE)()
        result = self._dll.JLINK_EMU_GetLicenses(buf, self.MAX_BUF_SIZE)
        if result < 0:
            raise errors.JLinkException(result)
        return ctypes.string_at(buf).decode()
758582
function checkLicenses(rootDir){

    var licenses = {},
        nodeModulesFolder = path.resolve(rootDir, "./node_modules"),
        moduleFolders = fs.readdirSync(nodeModulesFolder),
        res;

    _(moduleFolders).each(function(module) {
        licenses[module] = checkModuleLicense(nodeModulesFolder + "/" + module);
    });

    return licenses;
}
672668
def license():
    ''' 

    '''
    from os.path import join
    with open(join(__path__[0], 'LICENSE.txt')) as lic:
        print(lic.read())
441293
function streamLicense (grunt, fileData, options) {
    let content = grunt.file.read(options.license);

    // Use JSDoc license tag to preserve file content as
    // comment when minifying.
    if (options.deploy && options.minify) {
        content = `/**@license ${content}*/`;
    } else {
        content = `/*\x0A${content}*/\x0A\x0A`;
    }

    stream.write(content, () => {
        streamWrapperStart(grunt, fileData, options);
    });
}
1116851
def hacking_has_license(physical_line, filename, lines, line_number):
    
    # don't work about init files for now
    # TODO(sdague): enforce license in init file if it's not empty of content
    license_found = False

    # skip files that are < 10 lines, which isn't enough for a license to fit
    # this allows us to handle empty files, as well as not fail on the Okay
    # doctests.
    if line_number is 1 and len(lines) > 10 and _project_is_apache():
        for idx, line in enumerate(lines):
            # if it's more than 10 characters in, it's probably not in the
            # header
            if 0 <= line.find('Licensed under the Apache License') < 10:
                    license_found = True
            if 0 <= line.find('SPDX-License-Identifier:') < 10:
                    license_found = True
        if not license_found:
            return (0, "H102: Apache 2.0 license header not found")
251694
function parse(data, options, next) {
    data = this.get(data);

    if ('function' === typeof options) {
      next = options;
      options = {};
    }

    //
    // We cannot detect a license so we call the callback without any arguments
    // which symbolises a failed attempt.
    //
    if (!data) return next();

    debug('found %s in the package contents', data);

    // @TODO handle the edge case where people give us an URL instead of an
    // actual license.
    next(undefined, this.normalize(data));
  }
605416
function isPackageMeta(file) {
  if (file.match(/^readme(\.[^\.]*)$/i)) {
    return true;
  }
  if (file.match(/^(license|licence)(\.[^\.]*)?$/i)) {
    return true;
  }
  if (file.match(/^(notice)(\.[^\.]*)?$/i)) {
    return true;
  }
  if (file.match(/^(changes|changelog|history)(\.[^\.]*)?$/i)) {
    return true;
  }
}
889923
private License getLicense(final String licenseId) {
        License result = null;
        final Set<DbLicense> matchingLicenses = licenseMatcher.getMatchingLicenses(licenseId);

        if (matchingLicenses.isEmpty()) {
            result = DataModelFactory.createLicense("#" + licenseId + "# (to be identified)", NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET, NOT_IDENTIFIED_YET);
            result.setUnknown(true);
        } else {
            if (matchingLicenses.size() > 1 && LOG.isWarnEnabled()) {
                LOG.warn(String.format("%s matches multiple licenses %s. " +
                                "Please run the report showing multiple matching on licenses",
                        licenseId, matchingLicenses.toString()));
            }
            result = mapper.getLicense(matchingLicenses.iterator().next());

        }

        return result;
    }
317319
def ldiff(license)
      xml = Nokogiri::XML(File.open(@path), &:noblanks)
      comment = xml.xpath('/comment()')[0]
      now = comment.nil? ? '' : comment.text.to_s.strip
      ideal = license.strip
      differ(ideal, now)
    end