예제 #1
0
파일: alias.py 프로젝트: nervatura/nerva2py
    def applyAttributes(self, obj, attrs, codec=None):
        """
        Applies the collection of attributes C{attrs} to aliased object C{obj}.
        Called when decoding reading aliased objects from an AMF byte stream.

        Override this to provide fine grain control of application of
        attributes to C{obj}.

        @param codec: An optional argument that will contain the en/decoder
            instance calling this function.
        """
        if not self._compiled:
            self.compile()

        if not self.shortcut_decode:
            attrs = self.getDecodableAttributes(obj, attrs, codec=codec)
        else:
            if self.is_dict:
                obj.update(attrs)

                return

            if not self.sealed:
                obj.__dict__.update(attrs)

                return

        util.set_attrs(obj, attrs)
예제 #2
0
    def applyAttributes(self, obj, attrs, codec=None):
        """
        Applies the collection of attributes C{attrs} to aliased object C{obj}.
        Called when decoding reading aliased objects from an AMF byte stream.

        Override this to provide fine grain control of application of
        attributes to C{obj}.

        @param codec: An optional argument that will contain the en/decoder
            instance calling this function.
        """
        if not self._compiled:
            self.compile()

        if not self.shortcut_decode:
            attrs = self.getDecodableAttributes(obj, attrs, codec=codec)
        else:
            if self.is_dict:
                obj.update(attrs)

                return

            if not self.sealed:
                obj.__dict__.update(attrs)

                return

        util.set_attrs(obj, attrs)
예제 #3
0
    def applyAttributes(self, obj, attrs, codec=None):
        """
        Applies the collection of attributes C{attrs} to aliased object C{obj}.
        Called when decoding reading aliased objects from an AMF byte stream.

        Override this to provide fine grain control of application of
        attributes to C{obj}.

        @param codec: An optional argument that will contain the en/decoder
            instance calling this function.
        """
        attrs = self.getDecodableAttributes(obj, attrs, codec=codec)

        util.set_attrs(obj, attrs)
예제 #4
0
    def applyAttributes(self, obj, attrs, codec=None):
        """
        Applies the collection of attributes C{attrs} to aliased object C{obj}.
        Called when decoding reading aliased objects from an AMF byte stream.

        Override this to provide fine grain control of application of
        attributes to C{obj}.

        @param codec: An optional argument that will contain the en/decoder
            instance calling this function.
        """
        attrs = self.getDecodableAttributes(obj, attrs, codec=codec)

        util.set_attrs(obj, attrs)
예제 #5
0
파일: __init__.py 프로젝트: Hamid-K/deblaze
    def applyAttributes(self, obj, attrs):
        """
        Applies the collection of attributes C{attrs} to aliased object C{obj}.
        It is mainly used when reading aliased objects from an AMF byte stream.
        """
        if 'static' in self.metadata:
            s, d = self.getAttrs(obj)

            if s is not None:
                for k in attrs.keys():
                    if k not in s:
                        del attrs[k]

        util.set_attrs(obj, attrs)
예제 #6
0
    def applyAttributes(self, obj, attrs):
        """
        Applies the collection of attributes C{attrs} to aliased object C{obj}.
        It is mainly used when reading aliased objects from an AMF byte stream.
        """
        if 'static' in self.metadata:
            s, d = self.getAttrs(obj)

            if s is not None:
                for k in attrs.keys():
                    if k not in s:
                        del attrs[k]

        util.set_attrs(obj, attrs)
예제 #7
0
    def _readObject(self, obj, alias=None):
        obj_attrs = dict()

        key = self.readString().encode('utf8')

        while self.stream.peek() != TYPE_OBJECTTERM:
            obj_attrs[key] = self.readElement()
            key = self.readString().encode('utf8')

        # discard the end marker (TYPE_OBJECTTERM)
        self.stream.read(1)

        if alias:
            alias.applyAttributes(obj, obj_attrs, codec=self)
        else:
            util.set_attrs(obj, obj_attrs)
예제 #8
0
    def _readObject(self, obj, alias=None):
        obj_attrs = dict()

        key = self.readString().encode('utf8')

        while self.stream.peek() != TYPE_OBJECTTERM:
            obj_attrs[key] = self.readElement()
            key = self.readString().encode('utf8')

        # discard the end marker (TYPE_OBJECTTERM)
        self.stream.read(1)

        if alias:
            alias.applyAttributes(obj, obj_attrs, codec=self)
        else:
            util.set_attrs(obj, obj_attrs)
예제 #9
0
    def applyAttributes(self, obj, attrs, codec=None):
        """
        Applies the collection of attributes C{attrs} to aliased object C{obj}.
        It is mainly used when reading aliased objects from an AMF byte stream.

        @param codec: An optional argument that will contain the en/decoder
            instance calling this function.
        """
        if 'static' in self.metadata:
            s, d = self.getAttrs(obj, codec=codec)

            if s is not None:
                for k in attrs.keys():
                    if k not in s:
                        del attrs[k]

        util.set_attrs(obj, attrs)
예제 #10
0
    def _readObject(self, obj, alias=None):
        ot = chr(ASTypes.OBJECTTERM)
        obj_attrs = dict()

        key = self.readString().encode("utf8")

        while self.stream.peek() != ot:
            obj_attrs[key] = self.readElement()
            key = self.readString().encode("utf8")

        # discard the end marker (ASTypes.OBJECTTERM)
        self.stream.read(len(ot))

        if alias:
            alias.applyAttributes(obj, obj_attrs, codec=self)
        else:
            util.set_attrs(obj, obj_attrs)
예제 #11
0
파일: amf0.py 프로젝트: sasqwatch/deblaze
    def _readObject(self, obj, alias=None):
        ot = chr(ASTypes.OBJECTTERM)
        obj_attrs = dict()

        key = self.readString()

        while self.stream.peek() != ot:
            obj_attrs[key] = self.readElement()
            key = self.readString()

        # discard the end marker (ASTypes.OBJECTTERM)
        self.stream.read(len(ot))

        if alias:
            alias.applyAttributes(obj, obj_attrs)
        else:
            util.set_attrs(obj, obj_attrs)