diff src/plugins/plugin_misc_tarot.py @ 1409:3265a2639182

massive (preventive) addition of 'u' (unicode) before the strings passed to logging functions
author souliane <souliane@mailoo.org>
date Thu, 16 Apr 2015 14:57:57 +0200
parents 069ad98b360d
children d17772b0fe22
line wrap: on
line diff
--- a/src/plugins/plugin_misc_tarot.py	Thu Apr 16 13:31:14 2015 +0200
+++ b/src/plugins/plugin_misc_tarot.py	Thu Apr 16 14:57:57 2015 +0200
@@ -198,7 +198,7 @@
                             pl_waiting = players_data[player]['wait_for_low']
                             played.remove(card)
                             players_data[pl_waiting]['levees'].append(card)
-                            log.debug(_('Player %(excuse_owner)s give %(card_waited)s to %(player_waiting)s for Excuse compensation') % {"excuse_owner": player, "card_waited": card, "player_waiting": pl_waiting})
+                            log.debug(_(u'Player %(excuse_owner)s give %(card_waited)s to %(player_waiting)s for Excuse compensation') % {"excuse_owner": player, "card_waited": card, "player_waiting": pl_waiting})
                             return
                 return
 
@@ -229,12 +229,12 @@
                 low_card = owner_levees[card_idx]
                 del owner_levees[card_idx]
                 players_data[winner]['levees'].append(low_card)
-                log.debug(_('Player %(excuse_owner)s give %(card_waited)s to %(player_waiting)s for Excuse compensation') % {"excuse_owner": excuse_player, "card_waited": low_card, "player_waiting": winner})
+                log.debug(_(u'Player %(excuse_owner)s give %(card_waited)s to %(player_waiting)s for Excuse compensation') % {"excuse_owner": excuse_player, "card_waited": low_card, "player_waiting": winner})
                 break
         if not low_card:  # The player has no low card yet
             # TODO: manage case when player never win a trick with low card
             players_data[excuse_player]['wait_for_low'] = winner
-            log.debug(_("%(excuse_owner)s keep the Excuse but has not card to give, %(winner)s is waiting for one") % {'excuse_owner': excuse_player, 'winner': winner})
+            log.debug(_(u"%(excuse_owner)s keep the Excuse but has not card to give, %(winner)s is waiting for one") % {'excuse_owner': excuse_player, 'winner': winner})
 
     def __draw_game(self, game_data):
         """The game is draw, no score change
@@ -244,7 +244,7 @@
         scores_str = _('Draw game')
         scores_str += '\n'
         for player in game_data['players']:
-            scores_str += _("\n--\n%(player)s:\nscore for this game ==> %(score_game)i\ntotal score ==> %(total_score)i") % {'player': player, 'score_game': 0, 'total_score': players_data[player]['score']}
+            scores_str += _(u"\n--\n%(player)s:\nscore for this game ==> %(score_game)i\ntotal score ==> %(total_score)i") % {'player': player, 'score_game': 0, 'total_score': players_data[player]['score']}
         log.debug(scores_str)
 
         return (scores_str, [], [])
@@ -313,10 +313,10 @@
             else:
                 loosers.append(player)
 
-        scores_str = _('The attacker (%(attaquant)s) makes %(points)i and needs to make %(point_limit)i (%(nb_bouts)s oulder%(plural)s%(separator)s%(bouts)s): (s)he %(victory)s') % {'attaquant': game_data['attaquant'], 'points': score, 'point_limit': point_limit, 'nb_bouts': nb_bouts, 'plural': 's' if nb_bouts > 1 else '', 'separator': ': ' if nb_bouts != 0 else '', 'bouts': ','.join(map(str, bouts)), 'victory': 'wins' if victory else 'looses'}
+        scores_str = _(u'The attacker (%(attaquant)s) makes %(points)i and needs to make %(point_limit)i (%(nb_bouts)s oulder%(plural)s%(separator)s%(bouts)s): (s)he %(victory)s') % {'attaquant': game_data['attaquant'], 'points': score, 'point_limit': point_limit, 'nb_bouts': nb_bouts, 'plural': 's' if nb_bouts > 1 else '', 'separator': ': ' if nb_bouts != 0 else '', 'bouts': ','.join(map(str, bouts)), 'victory': 'wins' if victory else 'looses'}
         scores_str += '\n'
         for player in game_data['players']:
-            scores_str += _("\n--\n%(player)s:\nscore for this game ==> %(score_game)i\ntotal score ==> %(total_score)i") % {'player': player, 'score_game': player_score[player], 'total_score': players_data[player]['score']}
+            scores_str += _(u"\n--\n%(player)s:\nscore for this game ==> %(score_game)i\ntotal score ==> %(total_score)i") % {'player': player, 'score_game': player_score[player], 'total_score': players_data[player]['score']}
         log.debug(scores_str)
 
         return (scores_str, winners, loosers)
@@ -402,7 +402,7 @@
         player = self.host.plugins["XEP-0045"].getRoomNick(room_jid, profile)
         data = xml_tools.XMLUIResult2DataFormResult(raw_data)
         contrat = data['contrat']
-        log.debug(_('contrat [%(contrat)s] choosed by %(profile)s') % {'contrat': contrat, 'profile': profile})
+        log.debug(_(u'contrat [%(contrat)s] choosed by %(profile)s') % {'contrat': contrat, 'profile': profile})
         d = self.send(referee_jid, ('', 'contrat_choosed'), {'player': player}, content=contrat, profile=profile)
         d.addCallback(lambda ignore: {})
         del self._sessions[raw_data["session_id"]]
@@ -435,9 +435,9 @@
         """
         profile = self.host.memory.getProfileName(profile_key)
         if not profile:
-            log.error(_("profile %s is unknown") % profile_key)
+            log.error(_(u"profile %s is unknown") % profile_key)
             return
-        log.debug(_('Cards played by %(profile)s: [%(cards)s]') % {'profile': profile, 'cards': cards})
+        log.debug(_(u'Cards played by %(profile)s: [%(cards)s]') % {'profile': profile, 'cards': cards})
         elem = self.__card_list_to_xml(TarotCard.from_tuples(cards), 'cards_played')
         self.send(jid.JID(referee), elem, {'player': player}, profile=profile)
 
@@ -503,7 +503,7 @@
                 status = self.games[room_jid]['status']
                 nb_players = len(self.games[room_jid]['players'])
                 status[player] = 'ready'
-                log.debug(_('Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status})
+                log.debug(_(u'Player %(player)s is ready to start [status: %(status)s]') % {'player': player, 'status': status})
                 if status.values().count('ready') == nb_players:  # everybody is ready, we can start the game
                     self.newRound(room_jid, profile)
 
@@ -545,7 +545,7 @@
                         for player in game_data['players']:
                             game_data['status'][player] = "init"
                         return
-                    log.debug(_("%(player)s win the bid with %(contrat)s") % {'player': best_contrat[0], 'contrat': best_contrat[1]})
+                    log.debug(_(u"%(player)s win the bid with %(contrat)s") % {'player': best_contrat[0], 'contrat': best_contrat[1]})
                     game_data['contrat'] = best_contrat[1]
 
                     if game_data['contrat'] == "Garde Sans" or game_data['contrat'] == "Garde Contre":
@@ -617,7 +617,7 @@
                         if all(played):
                             # everybody has played
                             winner = self.__winner(game_data)
-                            log.debug(_('The winner of this trick is %s') % winner)
+                            log.debug(_(u'The winner of this trick is %s') % winner)
                             # the winner win the trick
                             self.__excuse_hack(game_data, played, winner)
                             players_data[elt['player']]['levees'].extend(played)
@@ -663,9 +663,9 @@
                     invalid_cards = self.__xml_to_list(elt.elements(name='invalid', uri=NS_CG).next())
                     self.host.bridge.tarotGameInvalidCards(room_jid.userhost(), elt['phase'], played_cards, invalid_cards, profile)
                 else:
-                    log.error(_('Unmanaged error type: %s') % elt['type'])
+                    log.error(_(u'Unmanaged error type: %s') % elt['type'])
             else:
-                log.error(_('Unmanaged card game element: %s') % elt.name)
+                log.error(_(u'Unmanaged card game element: %s') % elt.name)
 
     def getSyncDataForPlayer(self, room_jid, nick):
         return []