コード例 #1
0
 def parse_other(self, other):
     """Disassemble the other field into a dict of Rule fields."""
     if utils.parse_cidr(other):
         return {"OtherCidrIp": other}
     else:
         before, sep, after = other.rpartition("/")
         if before and before != self.account:
             return {
                 'OtherUserId': before,
                 'OtherGroupId': after,
             }
         else:
             return {'OtherGroupId': after}
コード例 #2
0
 def __init__(self, value):
     addr_info = parse_cidr(value)
     if not addr_info:
         raise ValueError("Invalid CIDR: '{}'".format(value))
     for field, value in addr_info.items():
         setattr(self, field, value)