def apci_contents(self, use_dict=None, as_class=dict):
        """Return the contents of an object as a dict."""
        if _debug: APCI._debug("apci_contents use_dict=%r as_class=%r", use_dict, as_class)

        # make/extend the dictionary of content
        if use_dict is None:
            use_dict = as_class()

        # copy the source and destination to make it easier to search
        if self.pduSource:
            use_dict.__setitem__('source', str(self.pduSource))
        if self.pduDestination:
            use_dict.__setitem__('destination', str(self.pduDestination))

        # loop through the elements
        for attr in APCI._debug_contents:
            value = getattr(self, attr, None)
            if value is None:
                continue

            if attr == 'apduType':
                mapped_value = apdu_types[self.apduType].__name__
            elif attr == 'apduService':
                if self.apduType in (ConfirmedRequestPDU.pduType, SimpleAckPDU.pduType, ComplexAckPDU.pduType):
                    mapped_value = confirmed_request_types[self.apduService].__name__
                elif (self.apduType == UnconfirmedRequestPDU.pduType):
                    mapped_value = unconfirmed_request_types[self.apduService].__name__
                elif (self.apduType == ErrorPDU.pduType):
                    mapped_value = error_types[self.apduService].__name__
            else:
                mapped_value = value

            # save the mapped value
            use_dict.__setitem__(attr, mapped_value)

        # return what we built/updated
        return use_dict
def apci_contents ( self , use_dict = None , as_class = dict ) : if _debug : APCI . _debug ( "apci_contents use_dict=%r as_class=%r" , use_dict , as_class ) if use_dict is None : use_dict = as_class ( ) if self . pduSource : use_dict . __setitem__ ( 'source' , str ( self . pduSource ) ) if self . pduDestination : use_dict . __setitem__ ( 'destination' , str ( self . pduDestination ) ) for attr in APCI . _debug_contents : value = getattr ( self , attr , None ) if value is None : continue if attr == 'apduType' : mapped_value = apdu_types [ self . apduType ] . __name__ elif attr == 'apduService' : if self . apduType in ( ConfirmedRequestPDU . pduType , SimpleAckPDU . pduType , ComplexAckPDU . pduType ) : mapped_value = confirmed_request_types [ self . apduService ] . __name__ elif ( self . apduType == UnconfirmedRequestPDU . pduType ) : mapped_value = unconfirmed_request_types [ self . apduService ] . __name__ elif ( self . apduType == ErrorPDU . pduType ) : mapped_value = error_types [ self . apduService ] . __name__ else : mapped_value = value use_dict . __setitem__ ( attr , mapped_value ) return use_dict
Return the contents of an object as a dict.