License URL matches License text on name table?
505712
def com_google_fonts_check_name_license_url(ttFont, familyname):
  """""""
  from fontbakery.constants import PLACEHOLDER_LICENSING_TEXT
  LEGACY_UFL_FAMILIES = ["Ubuntu", "UbuntuCondensed", "UbuntuMono"]
  LICENSE_URL = {
    'OFL.txt': 'http://scripts.sil.org/OFL',
    'LICENSE.txt': 'http://www.apache.org/licenses/LICENSE-2.0',
    'UFL.txt': 'https://www.ubuntu.com/legal/terms-and-policies/font-licence'
  }
  LICENSE_NAME = {
    'OFL.txt': 'Open Font',
    'LICENSE.txt': 'Apache',
    'UFL.txt': 'Ubuntu Font License'
  }
  detected_license = False
  for license in ['OFL.txt', 'LICENSE.txt', 'UFL.txt']:
    placeholder = PLACEHOLDER_LICENSING_TEXT[license]
    for nameRecord in ttFont['name'].names:
      string = nameRecord.string.decode(nameRecord.getEncoding())
      if nameRecord.nameID == NameID.LICENSE_DESCRIPTION and\
         string == placeholder:
        detected_license = license
        break

  if detected_license == "UFL.txt" and familyname not in LEGACY_UFL_FAMILIES:
    yield FAIL, Message("ufl",
                        ("The Ubuntu Font License is only acceptable on"
                         " the Google Fonts collection for legacy font"
                         " families that already adopted such license."
                         " New Families should use eigther Apache or"
                         " Open Font License."))
  else:
    found_good_entry = False
    if detected_license:
      failed = False
      expected = LICENSE_URL[detected_license]
      for nameRecord in ttFont['name'].names:
        if nameRecord.nameID == NameID.LICENSE_INFO_URL:
          string = nameRecord.string.decode(nameRecord.getEncoding())
          if string == expected:
            found_good_entry = True
          else:
            failed = True
            yield FAIL, Message("licensing-inconsistency",
                                ("Licensing inconsistency in name table"
                                 " entries! NameID={} (LICENSE DESCRIPTION)"
                                 " indicates {} licensing, but NameID={}"
                                 " (LICENSE URL) has '{}'. Expected: '{}'"
                                 "").format(NameID.LICENSE_DESCRIPTION,
                                            LICENSE_NAME[detected_license],
                                            NameID.LICENSE_INFO_URL,
                                            string, expected))
    if not found_good_entry:
      yield FAIL, Message("no-license-found",
                          ("A known license URL must be provided in the"
                           " NameID {} (LICENSE INFO URL) entry."
                           " Currently accepted licenses are Apache or"
                           " Open Font License. For a small set of legacy"
                           " families the Ubuntu Font License may be"
                           " acceptable as well."
                           "").format(NameID.LICENSE_INFO_URL))
    else:
      if failed:
        yield FAIL, Message("bad-entries",
                            ("Even though a valid license URL was seen in"
                             " NAME table, there were also bad entries."
                             " Please review NameIDs {} (LICENSE DESCRIPTION)"
                             " and {} (LICENSE INFO URL)."
                             "").format(NameID.LICENSE_DESCRIPTION,
                                        NameID.LICENSE_INFO_URL))
      else:
        yield PASS, "Font has a valid license URL in NAME table."
820926
function stripLinkDefinitions(text) {

        var text = text.replace(/^[ ]{0,3}\[(.+)\]:[ \t]*\n?[ \t]*<?(\S+?)>?[ \t]*\n?[ \t]*(?:(\n*)["(](.+?)[")][ \t]*)?(?:\n+|\Z)/gm, function (wholeMatch,m1,m2,m3,m4) {
            m1 = m1.toLowerCase();
            urls[m1] = encodeAmpsAndAngles(m2);
            if (m3) {
                return m3+m4;
            } else if (m4) {
                titles[m1] = m4.replace(/"/g,"&quot;");
            }
            return "";
        });

        return text;
    }
839241
def com_google_fonts_check_name_license(ttFont, license):
  """"""
  from fontbakery.constants import PLACEHOLDER_LICENSING_TEXT
  failed = False
  placeholder = PLACEHOLDER_LICENSING_TEXT[license]
  entry_found = False
  for i, nameRecord in enumerate(ttFont["name"].names):
    if nameRecord.nameID == NameID.LICENSE_DESCRIPTION:
      entry_found = True
      value = nameRecord.toUnicode()
      if value != placeholder:
        failed = True
        yield FAIL, Message("wrong", \
                            ("License file {} exists but"
                             " NameID {} (LICENSE DESCRIPTION) value"
                             " on platform {} ({})"
                             " is not specified for that."
                             " Value was: \"{}\""
                             " Must be changed to \"{}\""
                             "").format(license,
                                        NameID.LICENSE_DESCRIPTION,
                                        nameRecord.platformID,
                                        PlatformID(nameRecord.platformID).name,
                                        value,
                                        placeholder))
  if not entry_found:
    yield FAIL, Message("missing", \
                        ("Font lacks NameID {} "
                         "(LICENSE DESCRIPTION). A proper licensing entry"
                         " must be set.").format(NameID.LICENSE_DESCRIPTION))
  elif not failed:
    yield PASS, "Licensing entry on name table is correctly set."
181698
def com_google_fonts_check_name_rfn(ttFont):
  """"""
  failed = False
  for entry in ttFont["name"].names:
    string = entry.toUnicode()
    if "reserved font name" in string.lower():
      yield WARN, ("Name table entry (\"{}\")"
                   " contains \"Reserved Font Name\"."
                   " This is an error except in a few specific"
                   " rare cases.").format(string)
      failed = True
  if not failed:
    yield PASS, ("None of the name table strings"
                 " contain \"Reserved Font Name\".")
1065981
def _get_pkg_license(pkg):
    '''
    
    '''
    licenses = set()
    cpr = "/usr/share/doc/{0}/copyright".format(pkg)
    if os.path.exists(cpr):
        with salt.utils.files.fopen(cpr) as fp_:
            for line in salt.utils.stringutils.to_unicode(fp_.read()).split(os.linesep):
                if line.startswith("License:"):
                    licenses.add(line.split(":", 1)[1].strip())

    return ", ".join(sorted(licenses))
38143
function getLicenseFromUrl (url) {
  var regex = {
    opensource: /(http(s)?:\/\/)?(www.)?opensource.org\/licenses\/([A-Za-z0-9\-._]+)$/,
    spdx: /(http(s)?:\/\/)?(www.)?spdx.org\/licenses\/([A-Za-z0-9\-._]+)$/
  }

  for (var re in regex) {
    var tokens = url.match(regex[re])

    if (tokens) {
      var license = tokens[tokens.length - 1]

      // remove .html, .php, etc. from license name
      var extensions = ['.html', '.php', '-license']
      for (var i in extensions) {
        if (license.slice(-extensions[i].length) === extensions[i]) {
          license = license.slice(0, -extensions[i].length)
        }
      }

      return license
    }
  }

  return false
}
601686
def _name_matches(name, matches):
    '''
    
    '''
    for m in matches:
        if name.endswith(m):
            return True
        if name.lower().endswith('_' + m.lower()):
            return True
        if name.lower() == m.lower():
            return True
    return False
30657
def special_links_replace(text, urls):
    '''
    
    '''
    match_number = r'([A-Za-z0-9]+)' + r'(\+*)'
    reference_list = [(r'regulations:article:' + match_number, urls['regulations']),
                      (r'regulations:regulation:' + match_number, urls['regulations']),
                      (r'guidelines:article:' + match_number, urls['guidelines']),
                      (r'guidelines:guideline:' + match_number, urls['guidelines']),
                     ]
    anchor_list = [(r'regulations:contents', urls['regulations'] + r'#contents'),
                   (r'guidelines:contents', urls['guidelines'] + r'#contents'),
                   (r'regulations:top', urls['regulations'] + r'#'),
                   (r'guidelines:top', urls['guidelines'] + r'#'),
                   (r'link:pdf', urls['pdf'] + '.pdf'),
                  ]
    retval = text
    for match, repl in reference_list:
        retval = re.sub(match, repl + r'#\1\2', retval)
    for match, repl in anchor_list:
        retval = re.sub(match, repl, retval)
    return retval
350401
function () {
        var pkg = require(process.cwd() + '/package.json');
        var licenses = [];
        pkg.licenses.forEach(function (license) {
            licenses.push(license.type);
        });

        return '/*! ' + pkg.name + ' - v' + pkg.version + ' - ' + gutil.date("yyyy-mm-dd") + "\n" +
            (pkg.homepage ? "* " + pkg.homepage + "\n" : "") +
            '* Copyright (c) ' + gutil.date("yyyy") + ' ' + pkg.author.name +
            '; Licensed ' + licenses.join(', ') + ' */\n';
    }
384981
public static License createLicense(final String name, final String longName, final String comments, final String regexp, final String url){
		final License license = new License();

		license.setName(name);
		license.setLongName(longName);
		license.setComments(comments);
		license.setRegexp(regexp);
		license.setUrl(url);

		return license;
	}
101888
def license_present(name):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': False,
           'comment': ''}

    if not __salt__['powerpath.has_powerpath']():
        ret['result'] = False
        ret['comment'] = 'PowerPath is not installed.'
        return ret

    licenses = [l['key'] for l in __salt__['powerpath.list_licenses']()]

    if name in licenses:
        ret['result'] = True
        ret['comment'] = 'License key {0} already present'.format(name)
        return ret

    if __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'License key {0} is set to be added'.format(name)
        return ret

    data = __salt__['powerpath.add_license'](name)
    if data['result']:
        ret['changes'] = {name: 'added'}
        ret['result'] = True
        ret['comment'] = data['output']
        return ret
    else:
        ret['result'] = False
        ret['comment'] = data['output']
        return ret
1372222
function getJsonLicense (json) {
  var license = 'nomatch'
  if (typeof json === 'string') {
    license = matchLicense(json) || 'nomatch'
  } else {
    if (json.url) {
      license = { name: json.type, url: json.url }
    } else {
      license = matchLicense(json.type)
    }
  }
  return license
}
1155260
def com_google_fonts_check_name_trailing_spaces(ttFont):
  """"""
  failed = False
  for name_record in ttFont['name'].names:
    name_string = name_record.toUnicode()
    if name_string != name_string.strip():
      failed = True
      name_key = tuple([name_record.platformID, name_record.platEncID,
                       name_record.langID, name_record.nameID])
      shortened_str = name_record.toUnicode()
      if len(shortened_str) > 20:
        shortened_str = shortened_str[:10] + "[...]" + shortened_str[-10:]
      yield FAIL, (f"Name table record with key = {name_key} has"
                    " trailing spaces that must be removed:"
                   f" '{shortened_str}'")
  if not failed:
    yield PASS, ("No trailing spaces on name table entries.")
1064675
def user_licenses(self):
        """"""
        url = '{domain}/license'.format(domain=self.domain)
        res = self.session.get(url)
        self._check_response(res)
        return res.json()
1130385
function _update_site_license( $new_license ) {
            $this->_logger->entrance();

            $this->_license = $new_license;

            if ( ! is_object( $new_license ) ) {
                $this->_site->license_id = null;
                $this->_sync_site_subscription( null );

                return $this->_license;
            }

            $this->_site->license_id = $this->_license->id;

            if ( ! is_array( $this->_licenses ) ) {
                $this->_licenses = array();
            }

            $is_license_found = false;
            for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
                if ( $new_license->id == $this->_licenses[ $i ]->id ) {
                    $this->_licenses[ $i ] = $new_license;

                    $is_license_found = true;
                    break;
                }
            }

            // If new license just append.
            if ( ! $is_license_found ) {
                $this->_licenses[] = $new_license;
            }

            $this->_sync_site_subscription( $new_license );

            return $this->_license;
        }
1159695
def get_metadata(ident_hash):
    
    id, version = get_id_n_version(ident_hash)

    stmt = _get_sql('get-metadata.sql')
    args = dict(id=id, version=version)

    # FIXME The license_url and license_text metadata attributes need to
    # change to a License structure similar to what is used in cnx-authoring.

    with db_connect() as db_conn:
        with db_conn.cursor() as cursor:
            cursor.execute(stmt, args)
            try:
                metadata = cursor.fetchone()[0]
            except TypeError:
                raise NotFound(ident_hash)
    return metadata
104738
def _agl_compliant_name(glyph_name):
    """"""
    MAX_GLYPH_NAME_LENGTH = 63
    clean_name = re.sub("[^0-9a-zA-Z_.]", "", glyph_name)
    if len(clean_name) > MAX_GLYPH_NAME_LENGTH:
        return None
    return clean_name