def load_rules_from_file(filename):
  """Load list of TargetCfgRules from txt file."""
  rules = []
  with gfile.GFile(filename, "r") as rule_file:
    for line in rule_file:
      # Allow blank lines and comment lines in grammar files starting with '#'.
      if line and not line.startswith("#"):
        line = line.rstrip()
        rule = TargetCfgRule.from_string(line)
        rules.append(rule)
  print("Loaded %s rules from %s." % (len(rules), filename))
  return rules
Load list of TargetCfgRules from txt file.
language/compgen/nqg/model/parser/inference/targets/target_grammar.py