AhmedAMohamed / python-twitter

Automatically exported from code.google.com/p/python-twitter
Apache License 2.0
0 stars 0 forks source link

no geo_enabled field in User object #175

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
There is a nice flag in the user json that is not being parsed. Below is a 
quick patch to do that. 

I'd make a patch, but my version is quite far from the current trunk. Here is a 
relevant diff (ignore the line numbers)

Essentially, just add a field in the User object, and everything just works.

@ -625,7 +629,8 @@
                statuses_count=None,
                favourites_count=None,
                url=None,
-               status=None):
+               status=None,
+               geo_enabled=None):
     self.id = id
     self.name = name
     self.screen_name = screen_name
@@ -647,8 +652,8 @@
     self.favourites_count = favourites_count
     self.url = url
     self.status = status
+    self.geo_enabled = geo_enabled

-
   def GetId(self):
     '''Get the unique id of this user.

@@ -977,6 +982,27 @@
   favourites_count = property(GetFavouritesCount, SetFavouritesCount,
                               doc='The number of favourites for this user.')

+  def GetGeoEnabled(self):
+    '''Get the status of geo_enabled field for this user
+    
+    Returns:
+      True/False if Geo tagging is enabled
+    '''
+    return self._geo_enabled;
+
+  
+  def SetGeoEnabled(self,geo_enabled):
+    '''Set the status of geo_enabled field for this user
+    
+    Args:
+      geo_enabled:
+        True/False if Geo tagging is enabled
+    '''
+    self._geo_enabled = geo_enabled;
+
+  geo_enabled = property(GetGeoEnabled,SetGeoEnabled,
+                         doc="The value of geo_enabled for this user.")
+
   def __ne__(self, other):
     return not self.__eq__(other)

@@ -1003,7 +1029,8 @@
              self.followers_count == other.followers_count and \
              self.favourites_count == other.favourites_count and \
              self.friends_count == other.friends_count and \
-             self.status == other.status
+             self.status == other.status and \
+             self.geo_enabled == other.geo_enabled
     except AttributeError:
       return False

@@ -1074,6 +1101,8 @@
       data['statuses_count'] = self.statuses_count
     if self.favourites_count:
       data['favourites_count'] = self.favourites_count
+    if self.geo_enabled:
+      data['geo_enabled'] = self.geo_enabled
     return data

   @staticmethod
@@ -1111,7 +1140,8 @@
                 utc_offset = data.get('utc_offset', None),
                 time_zone = data.get('time_zone', None),
                 url=data.get('url', None),
-                status=status)
+                status=status,
+                geo_enabled=data.get('geo_enabled',None))

Original issue reported on code.google.com by adam.a...@gmail.com on 8 Nov 2010 at 9:45

GoogleCodeExporter commented 9 years ago
change applied in changeset 220:b105d4914738

Original comment by bear42 on 14 Nov 2010 at 6:54