return self is other or (self.id == other.id and self.name == other.name and self.contacts.ids() == other.contacts.ids() and self.attributes == other.attributes)
return NotImplemented
def __ne__(self, other):
equal = self.__eq__(other)
return NotImplemented if equal is NotImplemented else not equal
def __setattr__(self, name, value):
if name == 'contacts' and not isinstance(value, ContactList):
value = ContactList(value)
object.__setattr__(self, name, value)
class ContactURI(object):
def __init__(self, id, uri, type, **attributes):
self.id = id
self.uri = uri
self.type = type
self.attributes = attributes
def __eq__(self, other):
if isinstance(other, ContactURI):
return self is other or (self.id == other.id and self.uri == other.uri and self.type == other.type and self.attributes == other.attributes)
return NotImplemented
def __ne__(self, other):
equal = self.__eq__(other)
return NotImplemented if equal is NotImplemented else not equal
class EventHandling(object):
def __init__(self, policy, subscribe):
self.policy = policy
self.subscribe = subscribe
def __eq__(self, other):
if isinstance(other, EventHandling):
return self is other or (self.policy == other.policy and self.subscribe == other.subscribe)
return NotImplemented
def __ne__(self, other):
equal = self.__eq__(other)
return NotImplemented if equal is NotImplemented else not equal
self.dialog = dialog_handling or EventHandling(policy='default', subscribe=False)
self.presence = presence_handling or EventHandling(policy='default', subscribe=False)
self.attributes = attributes
def __eq__(self, other):
if isinstance(other, Contact):
return self is other or (self.id == other.id and self.name == other.name and self.uris == other.uris and self.dialog == other.dialog and self.presence == other.presence and
self.attributes == other.attributes)
return NotImplemented
def __ne__(self, other):
equal = self.__eq__(other)
return NotImplemented if equal is NotImplemented else not equal
def __setattr__(self, name, value):
if name == 'uris' and not isinstance(value, ContactURIList):
self.dialog = dialog_handling or EventHandling(policy='default', subscribe=False)
self.presence = presence_handling or EventHandling(policy='default', subscribe=False)
self.attributes = attributes
def __eq__(self, other):
if isinstance(other, Policy):
return self is other or (self.id == other.id and self.uri == other.uri and self.name == other.name and self.dialog == other.dialog and self.presence == other.presence and
self.attributes == other.attributes)
return NotImplemented
def __ne__(self, other):
equal = self.__eq__(other)
return NotImplemented if equal is NotImplemented else not equal
class Addressbook(object):
def __init__(self, contacts, groups, policies):
self.contacts = contacts
self.groups = groups
self.policies = policies
def __eq__(self, other):
if isinstance(other, Addressbook):
return self is other or (self.contacts == other.contacts and self.groups == other.groups and self.policies == other.policies)
return NotImplemented
def __ne__(self, other):
equal = self.__eq__(other)
return NotImplemented if equal is NotImplemented else not equal
@classmethod
def from_payload(cls, payload):
def payload_to_contact(payload):
uris = ContactURIList((ContactURI(uri.id, uri.uri, uri.type, **(uri.attributes or {})) for uri in payload.uris), default=payload.uris.default)
elif self.dialog_rules.content.element.nsmap.get('dr') != dialogrules.namespace: # TODO: this elif branch should be removed in a later version as it is
self.dialog_rules.content = dialogrules.DialogRules() # only used to discard documents created with the old namespace. -Dan
def fix_subhandling(rule, valid_values=()):
subhandling_elements = sorted((item for item in rule.actions if isinstance(item, dialogrules.SubHandling)), key=attrgetter('value.priority'))
if not subhandling_elements:
subhandling_elements = [dialogrules.SubHandling('block')] # spec specifies that missing SubHandling means block
rule.actions.update(subhandling_elements)
subhandling = subhandling_elements.pop()
for item in subhandling_elements: # remove any extraneous SubHandling elements
if self.status_icon.supported and self.status_icon.content is not None:
content = self.status_icon.content
if None in (content.encoding, content.mime_type) or content.encoding.value.lower() != 'base64' or content.mime_type.value.lower() not in Icon.__mimetypes__: