def __init__(self, until=UNTIL_TIME): self.until = until self.api = MixcloudAPI() # set a new whitelist without social connections which I am rebuilding # from the rest of the dataset self.api.set_metaconns_whitelist("cloudcasts", "favorites", "listens") self.collection = MONGO_DB.user self.dead_users = [] self.resurrected = []
class Resurrection: """This class handles the problem of missing users in the dataset. It is initialised with an "until" time which specifies the date that the said dataset was obtained so that only information about the users up to that point in time are obtained.""" def __init__(self, until=UNTIL_TIME): self.until = until self.api = MixcloudAPI() # set a new whitelist without social connections which I am rebuilding # from the rest of the dataset self.api.set_metaconns_whitelist("cloudcasts", "favorites", "listens") self.collection = MONGO_DB.user self.dead_users = [] self.resurrected = [] def resurrect(self): self.dead_users = self.find_dead_users() while self.dead_users: name = self.dead_users.pop() print ":::" + name ### try: current_user = User(self.api, name, self.until) current_user.populate() # Need to repopulate the social links so that they are # consistent with the rest of dataset current_user.data["followers"] = [] current_user.data["following"] = [] self.fix_connections(current_user) print "Social connections fixed ..." self.collection.save(current_user.get_data(), safe=True) self.resurrected.append(current_user.get_user_id()) except Exception, e: print e raise e finally: