def user_ready(username): if username.endswith(".php"): return False uh = UserHistory(username) # First, check to see if the file is fresh uh.load_if_possible() if uh.data_age() < settings.HISTORY_TTL: return uh.num_weeks() # Then, do a quick weeklist fetch to compare try: weeks = list(fetcher.weeks(username)) except AssertionError: # They probably don't exist return None present = True for start, end in weeks: if not uh.has_week(start): present = False break # If all weeks were present, update the timestamp if present: uh.set_timestamp() uh.save_default() return len(weeks) else: return False
def user_ready(username): if username.endswith(".php"): return False uh = UserHistory(username) # First, check to see if the file is fresh uh.load_if_possible() if uh.data_age() < settings.HISTORY_TTL: return uh.num_weeks() # Then, do a quick weeklist fetch to compare try: weeks = list(fetcher.weeks(username)) except AssertionError: # They probably don't exist return None present = True for start, end in weeks: if not uh.has_week(start): present = False break # If all weeks were present, update the timestamp if present: uh.set_timestamp() uh.save_default() return len(weeks) else: return False
def update_user(username): """Returns an up-to-date UserHistory for this username, perhaps creating it on the way or loading from disk.""" uh = UserHistory(username) if uh.has_file(): uh.load_default() try: update_user_history(uh) uh.set_timestamp() # We assume we got all the data for now. except KeyboardInterrupt: pass uh.save_default() return uh
def update_user(username): """Returns an up-to-date UserHistory for this username, perhaps creating it on the way or loading from disk.""" uh = UserHistory(username) if uh.has_file(): uh.load_default() try: update_user_history(uh) uh.set_timestamp() # We assume we got all the data for now. except KeyboardInterrupt: pass uh.save_default() return uh