parameters: (rule, targets)
return_statement: return False
docstring: Is this rule a simple rule?  A simple rule rewrites a single hostname,
      perhaps with an optional leading www\., to itself or to itself plus www.,
      at the top level with no other effects.
docstring_summary: Is this rule a simple rule?  A simple rule rewrites a single hostname,
      perhaps with an optional leading www\., to itself or to itself plus www.,
      at the top level with no other effects.
docstring_tokens: Is this rule a simple rule? A simple rule rewrites a single hostname perhaps with an optional leading www \ . to itself or to itself plus www . at the top level with no other effects .
function: def simple_rule(rule, targets):
      """Is this rule a simple rule?  A simple rule rewrites a single hostname,
      perhaps with an optional leading www\., to itself or to itself plus www.,
      at the top level with no other effects."""
      rule_from = rule.attrib["from"]
      rule_to = rule.attrib["to"]
      # Simple rule with no capture
      if regex.match(r"^\^http://[-A-Za-z0-9.\\]+/$", rule_from):
          applicable_host = unescape(regex.search(r"^\^http://([-A-Za-z0-9.\\])+/$", rule_from).groups()[0])
          if regex.match(r"^https://%s/" % applicable_host, rule_to) or regex.match("r^https://%s/" % applicable_host, rule_to):
              return True
          else:
              return False
      # Optional www
      if regex.match(r"^\^http://\(www\\\.\)\?[-A-Za-z0-9.\\]+/$", rule_from):
          applicable_host = unescape(regex.search(r"^\^http://\(www\\\.\)\?([-A-Za-z0-9.\\]+)/$", rule_from).groups()[0])
          if regex.match(r"^https://www\.%s/" % applicable_host, rule_to) or regex.match(r"^https://%s/" % applicable_host, rule_to):
              return True
          else:
              return False
      return False
function_tokens: def simple_rule ( rule , targets ) : rule_from = rule . attrib [ "from" ] rule_to = rule . attrib [ "to" ] # Simple rule with no capture if regex . match ( r"^\^http://[-A-Za-z0-9.\\]+/$" , rule_from ) : applicable_host = unescape ( regex . search ( r"^\^http://([-A-Za-z0-9.\\])+/$" , rule_from ) . groups ( ) [ 0 ] ) if regex . match ( r"^https://%s/" % applicable_host , rule_to ) or regex . match ( "r^https://%s/" % applicable_host , rule_to ) : return True else : return False # Optional www if regex . match ( r"^\^http://\(www\\\.\)\?[-A-Za-z0-9.\\]+/$" , rule_from ) : applicable_host = unescape ( regex . search ( r"^\^http://\(www\\\.\)\?([-A-Za-z0-9.\\]+)/$" , rule_from ) . groups ( ) [ 0 ] ) if regex . match ( r"^https://www\.%s/" % applicable_host , rule_to ) or regex . match ( r"^https://%s/" % applicable_host , rule_to ) : return True else : return False return False