def _check_rule(rule, _rule):
 if (_rule.get('from_port') is None):
  _rule['from_port'] = (-1)
 if (_rule.get('to_port') is None):
  _rule['to_port'] = (-1)
 if ((rule['ip_protocol'] == _rule['ip_protocol']) and (str(rule['from_port']) == str(_rule['from_port'])) and (str(rule['to_port']) == str(_rule['to_port']))):
  _cidr_ip = _rule.get('cidr_ip')
  if (_cidr_ip and (_cidr_ip == rule.get('cidr_ip'))):
   return True
  _owner_id = _rule.get('source_group_owner_id')
  if (_owner_id and (_owner_id == rule.get('source_group_owner_id'))):
   return True
  _group_id = _rule.get('source_group_group_id')
  if (_group_id and (_group_id == rule.get('source_group_group_id'))):
   return True
  _group_name = _rule.get('source_group_name')
  if (_group_name and (_group_id == rule.get('source_group_name'))):
   return True
 return False

def _check_rule ( rule , _rule ) : if ( _rule . get ( 'from_port' ) is None ) : _rule [ 'from_port' ] = ( - 1 ) if ( _rule . get ( 'to_port' ) is None ) : _rule [ 'to_port' ] = ( - 1 ) if ( ( rule [ 'ip_protocol' ] == _rule [ 'ip_protocol' ] ) and ( str ( rule [ 'from_port' ] ) == str ( _rule [ 'from_port' ] ) ) and ( str ( rule [ 'to_port' ] ) == str ( _rule [ 'to_port' ] ) ) ) : _cidr_ip = _rule . get ( 'cidr_ip' ) if ( _cidr_ip and ( _cidr_ip == rule . get ( 'cidr_ip' ) ) ) : return True _owner_id = _rule . get ( 'source_group_owner_id' ) if ( _owner_id and ( _owner_id == rule . get ( 'source_group_owner_id' ) ) ) : return True _group_id = _rule . get ( 'source_group_group_id' ) if ( _group_id and ( _group_id == rule . get ( 'source_group_group_id' ) ) ) : return True _group_name = _rule . get ( 'source_group_name' ) if ( _group_name and ( _group_id == rule . get ( 'source_group_name' ) ) ) : return True return False
check to see if two rules are the same .