コード例 #1
0
ファイル: main.py プロジェクト: ambrice/ffdraft
 def read_stat_categories(self, statsxml):
     root = ElementTree.fromstring(statsxml)
     models.remove_namespace(root, '{0}/base.rng'.format(YAHOO_URL))
     self.stat_categories = {}
     for stat in root.findall('game/stat_categories/stats/stat'):
         stat_id = stat.findtext('stat_id')
         stat_name = stat.findtext('name')
         self.stat_categories[stat_id] = stat_name
コード例 #2
0
ファイル: main.py プロジェクト: ambrice/ffdraft
 def read_stats(self, player, statsxml):
     statsxml = str(statsxml)
     root = ElementTree.fromstring(statsxml)
     models.remove_namespace(root, '{0}/base.rng'.format(YAHOO_URL))
     self.player_stats[player.id] = []
     try:
         for stat in root.findall('player/player_stats/stats/stat'):
             stat_id = stat.findtext('stat_id')
             stat_value = stat.findtext('value')
             if int(stat_value) != 0:
                 self.player_stats[player.id].append( (stat_id, stat_value) )
         if self.player_image.has_key(player.id):
             self.show_player_data(player)
     except Exception as e:
         print 'Error reading stats ' + str(e)
         del self.player_stats[player.id]