def registered_vendor_ids():
  """Get a list of vendor IDs from Microsoft's website."""
  from bs4 import BeautifulSoup
  from pkg_resources import resource_filename

  registered_vendor_ids = {}
  CACHED = resource_filename('fontbakery',
                             'data/fontbakery-microsoft-vendorlist.cache')
  content = open(CACHED, encoding='utf-8').read()
  soup = BeautifulSoup(content, 'html.parser')

  IDs = [chr(c + ord('a')) for c in range(ord('z') - ord('a') + 1)]
  IDs.append("0-9-")

  for section_id in IDs:
    section = soup.find('h2', {'id': section_id})
    table = section.find_next_sibling('table')
    if not table: continue

    #print ("table: '{}'".format(table))
    for row in table.findAll('tr'):
      #print("ROW: '{}'".format(row))
      cells = row.findAll('td')
      # pad the code to make sure it is a 4 char string,
      # otherwise eg "CF  " will not be matched to "CF"
      code = cells[0].string.strip()
      code = code + (4 - len(code)) * ' '
      labels = [label for label in cells[1].stripped_strings]
      registered_vendor_ids[code] = labels[0]

  return registered_vendor_ids
def registered_vendor_ids ( ) : from bs4 import BeautifulSoup from pkg_resources import resource_filename registered_vendor_ids = { } CACHED = resource_filename ( 'fontbakery' , 'data/fontbakery-microsoft-vendorlist.cache' ) content = open ( CACHED , encoding = 'utf-8' ) . read ( ) soup = BeautifulSoup ( content , 'html.parser' ) IDs = [ chr ( c + ord ( 'a' ) ) for c in range ( ord ( 'z' ) - ord ( 'a' ) + 1 ) ] IDs . append ( "0-9-" ) for section_id in IDs : section = soup . find ( 'h2' , { 'id' : section_id } ) table = section . find_next_sibling ( 'table' ) if not table : continue for row in table . findAll ( 'tr' ) : cells = row . findAll ( 'td' ) code = cells [ 0 ] . string . strip ( ) code = code + ( 4 - len ( code ) ) * ' ' labels = [ label for label in cells [ 1 ] . stripped_strings ] registered_vendor_ids [ code ] = labels [ 0 ] return registered_vendor_ids
Get a list of vendor IDs from Microsoft's website.