parameters: (root, files)
return_statement: return BUILD_FILE_TEMPLATE.substitute(fields=formatted_fields)
docstring: Compute the canonical BUILD contents for an api/ proto directory.
  
    Args:
      root: base path to directory.
      files: a list of files in the directory.
  
    Returns:
      A string containing the canonical BUILD file content for root.
docstring_summary: Compute the canonical BUILD contents for an api/ proto directory.
docstring_tokens: Compute the canonical BUILD contents for an api / proto directory .
function: def BuildFileContents(root, files):
    """Compute the canonical BUILD contents for an api/ proto directory.
  
    Args:
      root: base path to directory.
      files: a list of files in the directory.
  
    Returns:
      A string containing the canonical BUILD file content for root.
    """
    import_deps = set(sum([GetImportDeps(os.path.join(root, f)) for f in files], []))
    history_deps = set(sum([GetPreviousMessageTypeDeps(os.path.join(root, f)) for f in files], []))
    deps = import_deps.union(history_deps)
    has_services = any(HasServices(os.path.join(root, f)) for f in files)
    fields = []
    if has_services:
      fields.append('    has_services = True,')
    if deps:
      if len(deps) == 1:
        formatted_deps = '"%s"' % list(deps)[0]
      else:
        formatted_deps = '\n' + '\n'.join(
            '        "%s",' % dep for dep in sorted(deps, key=BuildOrderKey)) + '\n    '
      fields.append('    deps = [%s],' % formatted_deps)
    formatted_fields = '\n' + '\n'.join(fields) + '\n' if fields else ''
    return BUILD_FILE_TEMPLATE.substitute(fields=formatted_fields)
function_tokens: def BuildFileContents ( root , files ) : import_deps = set ( sum ( [ GetImportDeps ( os . path . join ( root , f ) ) for f in files ] , [ ] ) ) history_deps = set ( sum ( [ GetPreviousMessageTypeDeps ( os . path . join ( root , f ) ) for f in files ] , [ ] ) ) deps = import_deps . union ( history_deps ) has_services = any ( HasServices ( os . path . join ( root , f ) ) for f in files ) fields = [ ] if has_services : fields . append ( '    has_services = True,' ) if deps : if len ( deps ) == 1 : formatted_deps = '"%s"' % list ( deps ) [ 0 ] else : formatted_deps = '\n' + '\n' . join ( '        "%s",' % dep for dep in sorted ( deps , key = BuildOrderKey ) ) + '\n    ' fields . append ( '    deps = [%s],' % formatted_deps ) formatted_fields = '\n' + '\n' . join ( fields ) + '\n' if fields else '' return BUILD_FILE_TEMPLATE . substitute ( fields = formatted_fields )