예제 #1
0
파일: nbt.py 프로젝트: 0x3bfc9a1/pymclevel
    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)
예제 #2
0
파일: nbt.py 프로젝트: lulzbackup/cura
    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)
예제 #3
0
파일: nbt.py 프로젝트: pancho-bo/pymclevel
    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)
예제 #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)