Esempio n. 1
0
    def to_dict(self):
        d = {}
        # print the object as an xml string, parse the string to a dict
        # good times!
        # this hack brought to you by the letters: X, M, L and by the
        # words: Bad, and Design
        d = xmltodict.parse(self.product.to_string())
        d = json.loads(json.dumps(d))

        # filter our the top level crap which includes AWS keys etc
        d = {'Item': d['Item']}

        # add the python properties
        d.update({
            k: getattr(self.product, k)
            for k in dir(self.product) if dict_acceptable(
                self.product, k, blacklist=['browse_nodes', 'api'])
        })

        # add our own properties
        d.update({
            k: getattr(self, k)
            for k in dir(self)
            if dict_acceptable(self, k, blacklist=['soup', 'api', 'ratings'])
        })
        return d
Esempio n. 2
0
    def to_dict(self):
        d = {}
        # print the object as an xml string, parse the string to a dict
        # good times!
        # this hack brought to you by the letters: X, M, L and by the
        # words: Bad, and Design
        d = xmltodict.parse(self.product.to_string())
        d = json.loads(json.dumps(d))

        # filter our the top level crap which includes AWS keys etc
        d = {'Item':d['Item']}

        # add the python properties
        d.update({
            k:getattr(self.product, k)
            for k in dir(self.product)
            if dict_acceptable(self.product, k, blacklist=['browse_nodes', 'api'])
        })

        # add our own properties
        d.update({
            k:getattr(self, k)
            for k in dir(self)
            if dict_acceptable(self, k, blacklist=['soup', 'api', 'ratings'])
        })
        return d
Esempio n. 3
0
 def to_dict(self):
     d = {
         k: getattr(self, k)
         for k in dir(self)
         if dict_acceptable(self, k, blacklist=['soup', '_URL', '_soup'])
     }
     return d