for c in [Description]] else False):
                try:
                    list.append(self,
                                child_cls.from_element(child, *args, **kwargs))
                except ValidationError:
                    pass

    def _add_item(self, value):
        if not isinstance(value, (Description)):
            raise TypeError("Servcaps element can't contain %s element" %
                            value.__class__.__name__)
        self._insert_element(value.element)
        return value


Service.register_extension('servcaps', type=Servcaps)


class MobilityFixed(XMLEmptyElement):
    _xml_tag = 'fixed'
    _xml_namespace = caps_namespace
    _xml_application = PIDFApplication


class MobilityMobile(XMLEmptyElement):
    _xml_tag = 'mobile'
    _xml_namespace = caps_namespace
    _xml_application = PIDFApplication


class MobilityElementList(XMLListElement):
Beispiel #2
0
            if value in self.values:
                element = etree.Element('{%s}%s' % (self._xml_namespace, value), nsmap=self._xml_application.xml_nsmap)
            else:
                element = etree.Element('{%s}other' % self._xml_namespace, nsmap=self._xml_application.xml_nsmap)
                element.text = value
            self._insert_element(element)

    value = property(_get_value, _set_value)
    del _get_value, _set_value

    def __repr__(self):
        return '%s(%r, [%s])' % (self.__class__.__name__, self.value, ', '.join('%r' % note for note in self.notes))

    __str__ = __repr__

Service.register_extension('relationship', type=Relationship)


class ServiceClass(XMLElement, ServiceExtension):
    _xml_tag = 'service-class'
    _xml_namespace = rpid_namespace
    _xml_application = PIDFApplication
    
    values = set(('courier', 'electronic', 'freight', 'in person', 'postal', 'unknown'))
    
    notes = NotesAttribute()

    def __init__(self, service_class=None, notes=[]):
        XMLElement.__init__(self)
        self.value = service_class
        for note in notes:
Beispiel #3
0
        for child in element:
            child_cls = self._xml_application.get_element(child.tag)
            if child_cls is not None and (True if child_cls is [c for c in [Description]] else False):
                try:
                    list.append(self, child_cls.from_element(child, *args, **kwargs))
                except ValidationError:
                    pass

    def _add_item(self, value):
        if not isinstance(value, (Description)):
            raise TypeError("Servcaps element can't contain %s element" % value.__class__.__name__)
        self._insert_element(value.element)
        return value

    
Service.register_extension('servcaps', type=Servcaps)


class MobilityFixed(XMLEmptyElement):
    _xml_tag = 'fixed'
    _xml_namespace = caps_namespace
    _xml_application = PIDFApplication

class MobilityMobile(XMLEmptyElement):
    _xml_tag = 'mobile'
    _xml_namespace = caps_namespace
    _xml_application = PIDFApplication

class MobilityElementList(XMLListElement):
    def _parse_element(self, element, *args, **kwargs):
        for child in element:
                element = etree.Element('{%s}other' % self._xml_namespace,
                                        nsmap=self._xml_application.xml_nsmap)
                element.text = value
            self._insert_element(element)

    value = property(_get_value, _set_value)
    del _get_value, _set_value

    def __repr__(self):
        return '%s(%r, [%s])' % (self.__class__.__name__, self.value,
                                 ', '.join('%r' % note for note in self.notes))

    __str__ = __repr__


Service.register_extension('relationship', type=Relationship)


class ServiceClass(XMLElement, ServiceExtension):
    _xml_tag = 'service-class'
    _xml_namespace = rpid_namespace
    _xml_application = PIDFApplication

    values = set(
        ('courier', 'electronic', 'freight', 'in person', 'postal', 'unknown'))

    notes = NotesAttribute()

    def __init__(self, service_class=None, notes=[]):
        XMLElement.__init__(self)
        self.value = service_class
Beispiel #5
0
from sipsimple.payloads import XMLStringElement
from sipsimple.payloads.presdm import PIDFApplication, ServiceExtension, PersonExtension, Service, Person

__all__ = ['cipid_namespace', 'Card', 'DisplayName', 'Homepage', 'Icon', 'Map', 'Sound']

cipid_namespace = "urn:ietf:params:xml:ns:pidf:cipid"
PIDFApplication.register_namespace(cipid_namespace, prefix='c')

class Card(XMLStringElement, PersonExtension, ServiceExtension):
    _xml_tag = 'card'
    _xml_namespace = cipid_namespace
    _xml_application = PIDFApplication

Person.register_extension('card', type=Card)
Service.register_extension('card', type=Card)

class DisplayName(XMLStringElement, PersonExtension, ServiceExtension):
    _xml_tag = 'display-name'
    _xml_namespace = cipid_namespace
    _xml_application = PIDFApplication
    _xml_lang = True

Person.register_extension('display_name', type=DisplayName)
Service.register_extension('display_name', type=DisplayName)

class Homepage(XMLStringElement, PersonExtension, ServiceExtension):
    _xml_tag = 'homepage'
    _xml_namespace = cipid_namespace
    _xml_application = PIDFApplication