Better (safer) stringification of users
authorMarek Marecki <marekjm@ozro.pw>
Sun, 23 Apr 2017 13:43:44 +0000 (15:43 +0200)
committerMarek Marecki <marekjm@ozro.pw>
Sun, 23 Apr 2017 13:43:44 +0000 (15:43 +0200)
diaspy/people.py

index 701a02c9f1979f6abb87d067ef0aa66618c31c3e..7ebf2a32f4d721050ed5270df50062016f9bad00 100644 (file)
@@ -76,10 +76,10 @@ class User():
         return self.data[key]
 
     def __str__(self):
-        return self['guid']
+        return self.data.get('guid', '<guid missing>')
 
     def __repr__(self):
-        return '{0} ({1})'.format(self['handle'], self['guid'])
+        return '{0} ({1})'.format(self.handle(), self.guid())
 
     def handle(self):
         return self.data.get('diaspora_id', 'Unknown handle')