def make_rule_key(prefix, rule, group_id, cidr_ip):
 if isinstance(rule, dict):
  (proto, from_port, to_port) = [rule.get(x, None) for x in ('proto', 'from_port', 'to_port')]
  if ((proto not in ['icmp', 'tcp', 'udp']) and (from_port == (-1)) and (to_port == (-1))):
   from_port = 'none'
   to_port = 'none'
 else:
  (proto, from_port, to_port) = [getattr(rule, x, None) for x in ('ip_protocol', 'from_port', 'to_port')]
 key = ('%s-%s-%s-%s-%s-%s' % (prefix, proto, from_port, to_port, group_id, cidr_ip))
 return key.lower().replace('-none', '-None')

def make_rule_key ( prefix , rule , group_id , cidr_ip ) : if isinstance ( rule , dict ) : ( proto , from_port , to_port ) = [ rule . get ( x , None ) for x in ( 'proto' , 'from_port' , 'to_port' ) ] if ( ( proto not in [ 'icmp' , 'tcp' , 'udp' ] ) and ( from_port == ( - 1 ) ) and ( to_port == ( - 1 ) ) ) : from_port = 'none' to_port = 'none' else : ( proto , from_port , to_port ) = [ getattr ( rule , x , None ) for x in ( 'ip_protocol' , 'from_port' , 'to_port' ) ] key = ( '%s-%s-%s-%s-%s-%s' % ( prefix , proto , from_port , to_port , group_id , cidr_ip ) ) return key . lower ( ) . replace ( '-none' , '-None' )
creates a unique key for an individual group rule .