remoting/tools/verify_resources.py
def VerifyFile(filename, messages, used_tags):
  """
  Parse |filename|, looking for tags and report any that are not included in
  |messages|. Return True if all tags are present and correct, or False if
  any are missing.
  """

  base_name, file_type = os.path.splitext(filename)
  file_type = file_type[1:]
  if file_type == 'jinja2' and base_name.endswith('.json'):
    file_type = 'json.jinja2'
  if file_type not in ['js', 'cc', 'html', 'json.jinja2', 'jinja2', 'mm']:
    raise Exception("Unknown file type: %s" % file_type)

  result = True
  matches = False
  f = open(filename, 'r')
  lines = f.readlines()
  for i in range(0, len(lines)):
    tag = ExtractTagFromLine(file_type, lines[i])
    if tag:
      tag = tag.upper()
      used_tags.add(tag)
      matches = True
      if not tag in messages:
        result = False
        print('%s/%s:%d: error: Undefined tag: %s' %
            (os.getcwd(), filename, i + 1, tag))
  f.close()
  return result

  Parse |filename|, looking for tags and report any that are not included in
  |messages|. Return True if all tags are present and correct, or False if
  any are missing.
  
Parse |filename|, looking for tags and report any that are not included in
|messages|. Return True if all tags are present and correct, or False if
any are missing.
Parse |filename| looking for tags and report any that are not included in |messages| . Return True if all tags are present and correct or False if any are missing .
def VerifyFile(filename, messages, used_tags):
  base_name, file_type = os.path.splitext(filename)
  file_type = file_type[1:]
  if file_type == 'jinja2' and base_name.endswith('.json'):
    file_type = 'json.jinja2'
  if file_type not in ['js', 'cc', 'html', 'json.jinja2', 'jinja2', 'mm']:
    raise Exception("Unknown file type: %s" % file_type)
  result = True
  matches = False
  f = open(filename, 'r')
  lines = f.readlines()
  for i in range(0, len(lines)):
    tag = ExtractTagFromLine(file_type, lines[i])
    if tag:
      tag = tag.upper()
      used_tags.add(tag)
      matches = True
      if not tag in messages:
        result = False
        print('%s/%s:%d: error: Undefined tag: %s' %
            (os.getcwd(), filename, i + 1, tag))
  f.close()
  return result
def VerifyFile ( filename , messages , used_tags ) : base_name , file_type = os . path . splitext ( filename ) file_type = file_type [ 1 : ] if file_type == 'jinja2' and base_name . endswith ( '.json' ) : file_type = 'json.jinja2' if file_type not in [ 'js' , 'cc' , 'html' , 'json.jinja2' , 'jinja2' , 'mm' ] : raise Exception ( "Unknown file type: %s" % file_type ) result = True matches = False f = open ( filename , 'r' ) lines = f . readlines ( ) for i in range ( 0 , len ( lines ) ) : tag = ExtractTagFromLine ( file_type , lines [ i ] ) if tag : tag = tag . upper ( ) used_tags . add ( tag ) matches = True if not tag in messages : result = False print ( '%s/%s:%d: error: Undefined tag: %s' % ( os . getcwd ( ) , filename , i + 1 , tag ) ) f . close ( ) return result
Parse |filename|, looking for tags and report any that are not included in
|messages|.
Parse |filename| looking for tags and report any that are not included in |messages| .
"""
  Parse |filename|, looking for tags and report any that are not included in
  |messages|. Return True if all tags are present and correct, or False if
  any are missing.
  """
filename
messages
used_tags