parameters: (path)
return_statement: return metadata
docstring: Examine a third_party/foo component and extract its metadata.
docstring_summary: Examine a third_party/foo component and extract its metadata.
docstring_tokens: Examine a third_party / foo component and extract its metadata .
function: def ParseDir(path):
      """Examine a third_party/foo component and extract its metadata."""
  
      # Parse metadata fields out of README.chromium.
      # We examine "LICENSE" for the license file by default.
      metadata = {
          "License File": "LICENSE",  # Relative path to license text.
          "Name": None,               # Short name (for header on about:credits).
          "URL": None,                # Project home page.
          }
  
      # Relative path to a file containing some html we're required to place in
      # about:credits.
      optional_keys = ["Required Text"]
  
      if path in SPECIAL_CASES:
          metadata.update(SPECIAL_CASES[path])
      else:
          # Try to find README.chromium.
          readme_path = os.path.join(path, 'README.chromium')
          if not os.path.exists(readme_path):
              raise LicenseError("missing README.chromium")
  
          for line in open(readme_path):
              line = line.strip()
              if not line:
                  break
              for key in metadata.keys() + optional_keys:
                  field = key + ": "
                  if line.startswith(field):
                      metadata[key] = line[len(field):]
  
      # Check that all expected metadata is present.
      for key, value in metadata.iteritems():
          if not value:
              raise LicenseError("couldn't find '" + key + "' line "
                                 "in README.chromium or licences.py "
                                 "SPECIAL_CASES")
  
      # Check that the license file exists.
      for filename in (metadata["License File"], "COPYING"):
          license_path = AbsolutePath(path, filename)
          if license_path is not None:
              metadata["License File"] = license_path
              break
  
      if not license_path:
          raise LicenseError("License file not found. "
                             "Either add a file named LICENSE, "
                             "import upstream's COPYING if available, "
                             "or add a 'License File:' line to README.chromium "
                             "with the appropriate path.")
  
      if "Required Text" in metadata:
          required_path = AbsolutePath(path, metadata["Required Text"])
          if required_path is not None:
              metadata["Required Text"] = required_path
          else:
              raise LicenseError("Required text file listed but not found.")
  
      return metadata
function_tokens: def ParseDir ( path ) : # Parse metadata fields out of README.chromium. # We examine "LICENSE" for the license file by default. metadata = { "License File" : "LICENSE" , # Relative path to license text. "Name" : None , # Short name (for header on about:credits). "URL" : None , # Project home page. } # Relative path to a file containing some html we're required to place in # about:credits. optional_keys = [ "Required Text" ] if path in SPECIAL_CASES : metadata . update ( SPECIAL_CASES [ path ] ) else : # Try to find README.chromium. readme_path = os . path . join ( path , 'README.chromium' ) if not os . path . exists ( readme_path ) : raise LicenseError ( "missing README.chromium" ) for line in open ( readme_path ) : line = line . strip ( ) if not line : break for key in metadata . keys ( ) + optional_keys : field = key + ": " if line . startswith ( field ) : metadata [ key ] = line [ len ( field ) : ] # Check that all expected metadata is present. for key , value in metadata . iteritems ( ) : if not value : raise LicenseError ( "couldn't find '" + key + "' line " "in README.chromium or licences.py " "SPECIAL_CASES" ) # Check that the license file exists. for filename in ( metadata [ "License File" ] , "COPYING" ) : license_path = AbsolutePath ( path , filename ) if license_path is not None : metadata [ "License File" ] = license_path break if not license_path : raise LicenseError ( "License file not found. " "Either add a file named LICENSE, " "import upstream's COPYING if available, " "or add a 'License File:' line to README.chromium " "with the appropriate path." ) if "Required Text" in metadata : required_path = AbsolutePath ( path , metadata [ "Required Text" ] ) if required_path is not None : metadata [ "Required Text" ] = required_path else : raise LicenseError ( "Required text file listed but not found." ) return metadata