[foundation-web] get_renewees: added __str__ and __repr__ to have nice output on screen



commit e9c889e58b45f20cd582aa122803e2de4cb8dc0c
Author: Tobias Mueller <tobiasmue gnome org>
Date:   Thu May 3 13:45:00 2012 +0000

    get_renewees: added __str__ and __repr__ to have nice output on screen

 bin/get_renewees.py |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/bin/get_renewees.py b/bin/get_renewees.py
index 9190f66..bcffd76 100755
--- a/bin/get_renewees.py
+++ b/bin/get_renewees.py
@@ -113,7 +113,17 @@ class Member(object):
     def from_csv(cls, csvstring):
         firstname, lastname, email, token_or_last_renewed_on = csvstring.strip().split(';')
         return Member(firstname, lastname, email, token_or_last_renewed_on)
+    
+    def __str__(self):
+        if False: # string.format is too recent Python
+            fmt = "{firstname} {lastname} <{email}> (token_or_last_renewed_on)"
+            return fmt.format(self)
+        fmt = "%(firstname)s %(lastname)s <%(email)s> (%(token_or_last_renewed_on)s)"
+        return fmt % self.__dict__
 
+    def __repr__(self):
+        fmt = "<Member <%(email)s> (%(token_or_last_renewed_on)s)>"
+        return fmt % self.__dict__
 
 
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]