def __init__(self, data, twitterSession, fromCache=False): Timestamped.__init__(self) Hashable.__init__(self) if twitterSession is not None: assert isinstance(twitterSession, TwitterSession) self.data = Tree.make(data) if not fromCache: self.data.applyFunctionInTree(reverse_list, ['coordinates', 'coordinates']) # for use with leaflet. self.isDataNew = not fromCache twitterPlaceData = self.data.getFromTree(['place']) if twitterPlaceData is not None: self.twitter_place = Place(twitterPlaceData) else: self.twitter_place = None userJson = self.data.getFromTree(['user']) if userJson is None: self._user = None else: self._user = User(userJson, twitterSession=twitterSession, isAssociatedWithTweet=True, twitterPlace=self.twitter_place, currentLocationCoordinate=self.coordinate) if twitterSession is not None: self.instance_key = twitterSession.instance_key else: self.instance_key = None self.twitter_session = twitterSession
def __init__(self, userJson, twitterSession, fromCache=False, isFollowee=False, isAssociatedWithTweet=False, twitterPlace=None, currentLocationCoordinate=None, geocodeBias=None, knownFollowees=None): Hashable.__init__(self) Timestamped.__init__(self) if twitterSession is not None: assert isinstance(twitterSession, TwitterSession) if twitterPlace is not None: assert isinstance(twitterPlace, Place) if knownFollowees is None: knownFollowees = set() self.allow_geocode_external = True if userJson is None: self.data = Tree.make() else: self.data = Tree.make(userJson) # If false indicates that self.data is already in the cache, # so no point readding. self.isDataNew = not fromCache self.is_followee = isFollowee # This does not contain all followees, only followees known to our application # through follower enrichment. self.known_followees = knownFollowees self.is_associated_with_tweet = isAssociatedWithTweet self.twitter_session = twitterSession if twitterSession is not None: self.instance_key = twitterSession.instance_key else: self.instance_key = None self.queued_for_follower_enrichment = False self.current_location_coordinate = currentLocationCoordinate self.twitter_place = twitterPlace self.last_follower_enrichment_error = None self.follower_enrichment_progress = UserFollowerEnrichmentProgress(self) if self.num_followers is not None: self.twitter_calls_to_retrieve_follower_ids = math.ceil(float(self.num_followers) / float(TwitterSession.GET_FOLLOWER_IDS_QUANTITY_PER_TWITTER_CALL)) else: self.twitter_calls_to_retrieve_follower_ids = 1 self.geocoded_from = None self.geocode_bias = None self.analysers = None