parameters: (target, target_dict, extra_sources_for_rules)
docstring: Ensures that the rules sections in target_dict are valid and consistent,
    and determines which sources they apply to.
  
    Arguments:
      target: string, name of target.
      target_dict: dict, target spec containing "rules" and "sources" lists.
      extra_sources_for_rules: a list of keys to scan for rule matches in
          addition to 'sources'.
docstring_summary: Ensures that the rules sections in target_dict are valid and consistent,
    and determines which sources they apply to.
docstring_tokens: Ensures that the rules sections in target_dict are valid and consistent and determines which sources they apply to .
function: def ValidateRulesInTarget(target, target_dict, extra_sources_for_rules):
      """Ensures that the rules sections in target_dict are valid and consistent,
    and determines which sources they apply to.
  
    Arguments:
      target: string, name of target.
      target_dict: dict, target spec containing "rules" and "sources" lists.
      extra_sources_for_rules: a list of keys to scan for rule matches in
          addition to 'sources'.
    """
  
      # Dicts to map between values found in rules' 'rule_name' and 'extension'
      # keys and the rule dicts themselves.
      rule_names = {}
      rule_extensions = {}
  
      rules = target_dict.get("rules", [])
      for rule in rules:
          # Make sure that there's no conflict among rule names and extensions.
          rule_name = rule["rule_name"]
          if rule_name in rule_names:
              raise GypError(
                  f"rule {rule_name} exists in duplicate, target {target}"
              )
          rule_names[rule_name] = rule
  
          rule_extension = rule["extension"]
          if rule_extension.startswith("."):
              rule_extension = rule_extension[1:]
          if rule_extension in rule_extensions:
              raise GypError(
                  (
                      "extension %s associated with multiple rules, "
                      + "target %s rules %s and %s"
                  )
                  % (
                      rule_extension,
                      target,
                      rule_extensions[rule_extension]["rule_name"],
                      rule_name,
                  )
              )
          rule_extensions[rule_extension] = rule
  
          # Make sure rule_sources isn't already there.  It's going to be
          # created below if needed.
          if "rule_sources" in rule:
              raise GypError(
                  "rule_sources must not exist in input, target %s rule %s"
                  % (target, rule_name)
              )
  
          rule_sources = []
          source_keys = ["sources"]
          source_keys.extend(extra_sources_for_rules)
          for source_key in source_keys:
              for source in target_dict.get(source_key, []):
                  (source_root, source_extension) = os.path.splitext(source)
                  if source_extension.startswith("."):
                      source_extension = source_extension[1:]
                  if source_extension == rule_extension:
                      rule_sources.append(source)
  
          if len(rule_sources) > 0:
              rule["rule_sources"] = rule_sources
function_tokens: def ValidateRulesInTarget ( target , target_dict , extra_sources_for_rules ) : # Dicts to map between values found in rules' 'rule_name' and 'extension' # keys and the rule dicts themselves. rule_names = { } rule_extensions = { } rules = target_dict . get ( "rules" , [ ] ) for rule in rules : # Make sure that there's no conflict among rule names and extensions. rule_name = rule [ "rule_name" ] if rule_name in rule_names : raise GypError ( f"rule {rule_name} exists in duplicate, target {target}" ) rule_names [ rule_name ] = rule rule_extension = rule [ "extension" ] if rule_extension . startswith ( "." ) : rule_extension = rule_extension [ 1 : ] if rule_extension in rule_extensions : raise GypError ( ( "extension %s associated with multiple rules, " + "target %s rules %s and %s" ) % ( rule_extension , target , rule_extensions [ rule_extension ] [ "rule_name" ] , rule_name , ) ) rule_extensions [ rule_extension ] = rule # Make sure rule_sources isn't already there.  It's going to be # created below if needed. if "rule_sources" in rule : raise GypError ( "rule_sources must not exist in input, target %s rule %s" % ( target , rule_name ) ) rule_sources = [ ] source_keys = [ "sources" ] source_keys . extend ( extra_sources_for_rules ) for source_key in source_keys : for source in target_dict . get ( source_key , [ ] ) : ( source_root , source_extension ) = os . path . splitext ( source ) if source_extension . startswith ( "." ) : source_extension = source_extension [ 1 : ] if source_extension == rule_extension : rule_sources . append ( source ) if len ( rule_sources ) > 0 : rule [ "rule_sources" ] = rule_sources