Beispiel #1
0
 def __on_get_person_accounts(self, person, xml_str):
     doc = xml.dom.minidom.parseString(xml_str) 
     accts = []
     for child in xml_query(doc.documentElement, 'externalAccount*'):
         attrs = xml_get_attrs(child, ['type', 
                                       'sentiment', 
                                       'icon'])
         accttype = attrs['type']
         if attrs['sentiment'] == 'love':
             attrs['link'] = child.getAttribute('link')
         thumbnails = []            
         try:
             thumbnails_node = xml_query(child, 'thumbnails')
         except KeyError:
             thumbnails_node = None
         if thumbnails_node:
             for thumbnail in xml_query(thumbnails_node, 'thumbnail*'):
                 subattrs = xml_get_attrs(thumbnail, ['src', ('title', True), 'href'])
                 thumbnails.append(ExternalAccountThumbnail(subattrs)) 
             self._logger.debug("%d thumbnails found for account %s (user %s)" % (len(thumbnails), accttype, person)) 
             attrs['thumbnails'] = thumbnails
         feeds = []
         try:
             feeds_node = xml_query(child, 'feeds')
         except KeyError:
             feeds_node = None
         if feeds_node:
             for feed in xml_query(feeds_node, 'feed*'):
                 feeds.append(feed.getAttribute('src'))   
             attrs['feeds'] = feeds          
         acct = ExternalAccount(attrs)
         accts.append(acct)
     self._logger.debug("setting %d accounts for user %s" % (len(accts), person))
     person.set_external_accounts(accts)
Beispiel #2
0
 def __load_app_from_xml(self, node):
     id = node.getAttribute("id")
     self._logger.debug("parsing application id=%s", id)
     attrs = xml_get_attrs(node, ['id', 'rank', 'usageCount', 
                                  'iconUrl', 
                                  'category',
                                  'name', 'desktopNames',
                                  ('tooltip', True),
                                  ('genericName', True)
                                 ])
     description = xml_query(node, 'description#')
     if description:
         attrs['description'] = description
     app = None
     if not self.__applications.has_key(attrs['id']):
         app = Application(attrs)
         self.__applications[attrs['id']] = app
     else:
         app = self.__applications[attrs['id']]    
     app.update(attrs)            
     return app