Cleanup old logging in field_compare
authorJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sun, 27 May 2012 20:26:00 +0000 (20:26 +0000)
committerJean-Michel Nirgal Vourgère <jmv@nirgal.com>
Sun, 27 May 2012 20:26:00 +0000 (20:26 +0000)
members.py

index 7192c28907cae1cdc9ebe169770fc6cea0a97268..616c4224ba2e3f732b79bd1d9cc967972efbc152 100755 (executable)
@@ -23,7 +23,7 @@ DateTime,Action,Nick1,Grade1,OldField1,NewField1,Nick2,Grade2,OldField2,NewField
 Action is one of: JOIN, QUIT, WIN, LOSS, FLOOD, NOOP, ACT
 
 Exemples:
-NOOP,,,,,,,,,,,No changes
+NOOP,,,,,,,,,,,Pas de changement dans le TdC
 JOIN,Nirgal,Recrue,0,571628,,,,,,,Nirgal a rejoint l'alliance avec 571 628 cm² 
 QUIT,oncleblu,Chasseur,9940181,0,,,,,,,oncleblu a quité l'alliance avec 9 940 181 cm² 
 WIN,Nirgal,Chasseur,200000,257900,,,,,,,Nirgal a gagné 57 900 cm² 
@@ -32,7 +32,7 @@ FLOOD,filoux,Passeur 003,55813865,74225093,yosemite,Passeur 004,51142304,3273107
 FLOOD,Nick1,Grade1,100,102,Nick2,Grade2,100,99,1,1.00,Nick1 a pris 1 cm² à Nick2 (1.00%)
 FLOOD,Nick1,Grade1,100,102,Nick3,Grade3,100,99,1,1.00,Nick1 a pris 1 cm² à Nick3 (1.00%)
 
-ACT,Nick1,Grade1,100,100,,,,,,,Nick1 est en vacances
+ACT,Nick1,Grade1,Actif,En vacances,,,,,,,Nick1 est maintenant en vacances
 
 Note that in last 2 lines exemple, NewField1 is 102 that is different from 100+1 because of multiple floods.
 """
@@ -215,7 +215,6 @@ def field_compare(oldmembers, newmembers, csvfile):
     newfield = members_to_field(newmembers)
 
     changes = {}
-    txtchanges = []
     txtchanges2 = []
 
     for nick in newfield.keys():
@@ -235,7 +234,6 @@ def field_compare(oldmembers, newmembers, csvfile):
     #print
 
     if not len(changes):
-        txtchanges.append('No changes')
         txtchanges2.append('NOOP,,,,,,,,,,,No changes')
  
     for nick in changes.keys():
@@ -248,7 +246,6 @@ def field_compare(oldmembers, newmembers, csvfile):
             if changes[nick2]['delta'] != -delta:
                 continue # not the good one
             percent = float(oldfield[nick2] - newfield[nick2]) / oldfield[nick2] * 100.
-            txtchanges.append('%s a pris %s cm² à %s (%.2f%%)' % (nick, number_format(delta), nick2, percent))
             txtchanges2.append('FLOOD,{nick1},{grade1},{oldfield1},{newfield1},{nick2},{grade2},{oldfield2},{newfield2},{deltafield},{percent},{nick1} a pris {nicedeltafield} cm² à {nick2} ({percent:.2f}%)'.format(
                 nick1=nick,
                 grade1=newmembers[nick].get('grade', ''),
@@ -270,7 +267,6 @@ def field_compare(oldmembers, newmembers, csvfile):
         if delta < 0:
             if nick in newfield:
                 percent = float(-delta) / oldfield[nick] * 100.
-                txtchanges.append('%s a perdu %s cm² (%.2f%%)' % (nick, number_format(-delta), percent))
                 txtchanges2.append('LOSS,{nick1},{grade1},{oldfield1},{newfield1},,,,,{deltafield},{percent},{nick1} a perdu {nicedeltafield} cm² ({percent:.2f}%)'.format(
                     nick1=nick,
                     grade1=newmembers[nick].get('grade', ''),
@@ -281,7 +277,6 @@ def field_compare(oldmembers, newmembers, csvfile):
                     percent=percent,
                     ))
             else:
-                txtchanges.append("%s a quité l'alliance avec %s cm²" % (nick, number_format(-delta)))
                 txtchanges2.append('QUIT,{nick1},{grade1},{oldfield1},0,,,,,{deltafield},,{nick1} a quité l\'alliance avec {nicedeltafield} cm²'.format(
                     nick1=nick,
                     grade1=oldmembers[nick].get('grade', ''),
@@ -291,7 +286,6 @@ def field_compare(oldmembers, newmembers, csvfile):
                     ))
         elif delta > 0:
             if nick in oldfield:
-                txtchanges.append('%s a gagné %s cm²' % (nick, number_format(delta)))
                 txtchanges2.append('WIN,{nick1},{grade1},{oldfield1},{newfield1},,,,,{deltafield},,{nick1} a gagné {nicedeltafield} cm²'.format(
                     nick1=nick,
                     grade1=newmembers[nick].get('grade', ''),
@@ -301,7 +295,6 @@ def field_compare(oldmembers, newmembers, csvfile):
                     nicedeltafield=number_format(delta),
                     ))
             else:
-                txtchanges.append("%s a rejoint l'alliance avec %s cm²" % (nick, number_format(delta)))
                 txtchanges2.append('JOIN,{nick1},{grade1},0,{newfield1},,,,,{deltafield},,{nick1} a rejoint l\'alliance avec {nicedeltafield} cm²'.format(
                     nick1=nick,
                     grade1=newmembers[nick].get('grade', ''),
@@ -310,10 +303,8 @@ def field_compare(oldmembers, newmembers, csvfile):
                     nicedeltafield=number_format(delta),
                     ))
 
-    for txtchange in txtchanges:
-        logging.info(txtchange)
-
     for txtchange in txtchanges2:
+        logging.info(txtchange.split(',')[-1])
         csvfile.write(time.strftime(DATETIME_FORMAT)+','+txtchange+'\n')
 
 def activity_compare(oldmembers, newmembers, csvfile):