parameters: (existing_rules, dir_name)
return_statement: return (ApplyRules(existing_rules, include_rules, dir_name), skip_subdirs)
docstring: Combines rules from the existing rules and the new directory.
  
    Any directory can contain a DEPS file. Toplevel DEPS files can contain
    module dependencies which are used by gclient. We use these, along with
    additional include rules and implicit rules for the given directory, to
    come up with a combined set of rules to apply for the directory.
  
    Args:
      existing_rules: The rules for the parent directory. We'll add-on to these.
      dir_name: The directory name that the deps file may live in (if it exists).
                This will also be used to generate the implicit rules.
  
    Returns: A tuple containing: (1) the combined set of rules to apply to the
             sub-tree, and (2) a list of all subdirectories that should NOT be
             checked, as specified in the DEPS file (if any).
docstring_summary: Combines rules from the existing rules and the new directory.
docstring_tokens: Combines rules from the existing rules and the new directory .
function: def ApplyDirectoryRules(existing_rules, dir_name):
    """Combines rules from the existing rules and the new directory.
  
    Any directory can contain a DEPS file. Toplevel DEPS files can contain
    module dependencies which are used by gclient. We use these, along with
    additional include rules and implicit rules for the given directory, to
    come up with a combined set of rules to apply for the directory.
  
    Args:
      existing_rules: The rules for the parent directory. We'll add-on to these.
      dir_name: The directory name that the deps file may live in (if it exists).
                This will also be used to generate the implicit rules.
  
    Returns: A tuple containing: (1) the combined set of rules to apply to the
             sub-tree, and (2) a list of all subdirectories that should NOT be
             checked, as specified in the DEPS file (if any).
    """
    # Check for a .svn directory in this directory or check this directory is
    # contained in git source direcotries. This will tell us if it's a source
    # directory and should be checked.
    if not (os.path.exists(os.path.join(dir_name, ".svn")) or
            (dir_name.lower() in GIT_SOURCE_DIRECTORY)):
      return (None, [])
  
    # Check the DEPS file in this directory.
    if VERBOSE:
      print "Applying rules from", dir_name
    def FromImpl(unused, unused2):
      pass  # NOP function so "From" doesn't fail.
  
    def FileImpl(unused):
      pass  # NOP function so "File" doesn't fail.
  
    class _VarImpl:
      def __init__(self, local_scope):
        self._local_scope = local_scope
  
      def Lookup(self, var_name):
        """Implements the Var syntax."""
        if var_name in self._local_scope.get("vars", {}):
          return self._local_scope["vars"][var_name]
        raise Error("Var is not defined: %s" % var_name)
  
    local_scope = {}
    global_scope = {
        "File": FileImpl,
        "From": FromImpl,
        "Var": _VarImpl(local_scope).Lookup,
        }
    deps_file = os.path.join(dir_name, "DEPS")
  
    if os.path.isfile(deps_file):
      execfile(deps_file, global_scope, local_scope)
    elif VERBOSE:
      print "  No deps file found in", dir_name
  
    # Even if a DEPS file does not exist we still invoke ApplyRules
    # to apply the implicit "allow" rule for the current directory
    include_rules = local_scope.get(INCLUDE_RULES_VAR_NAME, [])
    skip_subdirs = local_scope.get(SKIP_SUBDIRS_VAR_NAME, [])
  
    return (ApplyRules(existing_rules, include_rules, dir_name), skip_subdirs)
function_tokens: def ApplyDirectoryRules ( existing_rules , dir_name ) : # Check for a .svn directory in this directory or check this directory is # contained in git source direcotries. This will tell us if it's a source # directory and should be checked. if not ( os . path . exists ( os . path . join ( dir_name , ".svn" ) ) or ( dir_name . lower ( ) in GIT_SOURCE_DIRECTORY ) ) : return ( None , [ ] ) # Check the DEPS file in this directory. if VERBOSE : print "Applying rules from" , dir_name def FromImpl ( unused , unused2 ) : pass # NOP function so "From" doesn't fail. def FileImpl ( unused ) : pass # NOP function so "File" doesn't fail. class _VarImpl : def __init__ ( self , local_scope ) : self . _local_scope = local_scope def Lookup ( self , var_name ) : """Implements the Var syntax.""" if var_name in self . _local_scope . get ( "vars" , { } ) : return self . _local_scope [ "vars" ] [ var_name ] raise Error ( "Var is not defined: %s" % var_name ) local_scope = { } global_scope = { "File" : FileImpl , "From" : FromImpl , "Var" : _VarImpl ( local_scope ) . Lookup , } deps_file = os . path . join ( dir_name , "DEPS" ) if os . path . isfile ( deps_file ) : execfile ( deps_file , global_scope , local_scope ) elif VERBOSE : print "  No deps file found in" , dir_name # Even if a DEPS file does not exist we still invoke ApplyRules # to apply the implicit "allow" rule for the current directory include_rules = local_scope . get ( INCLUDE_RULES_VAR_NAME , [ ] ) skip_subdirs = local_scope . get ( SKIP_SUBDIRS_VAR_NAME , [ ] ) return ( ApplyRules ( existing_rules , include_rules , dir_name ) , skip_subdirs )