Ejemplo n.º 1
0
    def __setitem__(self, key, item):
        """Automatically wraps lists and tuples in a TAG_List, and wraps strings
        and unicodes in a TAG_String."""
        if isinstance(item, (list, tuple)):
            item = TAG_List(item)
        elif isinstance(item, basestring):
            item = TAG_String(item)

        item.name = key
        self.check_value(item)

        # remove any items already named "key".
        if not self.ALLOW_DUPLICATE_KEYS:
            self._value = filter(lambda x: x.name != key, self._value)

        self._value.append(item)
Ejemplo n.º 2
0
    def __setitem__(self, key, item):
        """Automatically wraps lists and tuples in a TAG_List, and wraps strings
        and unicodes in a TAG_String."""
        if isinstance(item, (list, tuple)):
            item = TAG_List(item)
        elif isinstance(item, basestring):
            item = TAG_String(item)

        item.name = key
        self.check_value(item)

        # remove any items already named "key".
        if not self.ALLOW_DUPLICATE_KEYS:
            self._value = filter(lambda x: x.name != key, self._value)

        self._value.append(item)
Ejemplo n.º 3
0
    def __setitem__(self, key, item):
        '''Automatically wraps lists and tuples in a TAG_List, and wraps strings
        and unicodes in a TAG_String.'''
        if isinstance(item, (list, tuple)):
            item = TAG_List(item)
        elif isinstance(item, str):
            item = TAG_String(item)

        item.name = key
        self.check_value(item)

        # remove any items already named 'key'.
        if not self.ALLOW_DUPLICATE_KEYS:
            self._value = [x for x in self._value if x.name != key]

        self._value.append(item)
Ejemplo n.º 4
0
    def __setitem__(self, key, item):
        '''Automatically wraps lists and tuples in a TAG_List, and wraps strings
        and unicodes in a TAG_String.'''
        if isinstance(item, (list, tuple)):
            item = TAG_List(item)
        elif isinstance(item, str):
            item = TAG_String(item)

        item.name = key
        self.check_value(item)

        # remove any items already named 'key'.
        if not self.ALLOW_DUPLICATE_KEYS:
            self._value = [x for x in self._value if x.name != key]

        self._value.append(item)