def check_and_download(hubname,company_flag): if hubname is None: return None hubs = HubAnalyzer.get_hub_names() companies = HubAnalyzer.get_company_names() if not company_flag: if hubname in hubs and hubname in companies: print("Name is ambiguous, there is a company and a hub with this name; assuming hub by default.") prefix = "hubs/" elif hubname in hubs: prefix = "hubs/" elif hubname in companies: prefix = "companies/" else: print("There is no name record for *" + hubname + "*, assuming it is a hub, not a company.") else: prefix = "companies/" datafile = "data/"+prefix+hubname if os.path.isfile(datafile): return Reader.read_list_of_users(datafile) else: print("Data for *" +hubname+ "* is not in the local dataset, downloading it now... ") HubAnalyzer.report_downloading_progress = True if company_flag: HubAnalyzer.getCompanyUsers(hubname) else: HubAnalyzer.getUsers(hubname) return Reader.read_list_of_users(datafile)
def updatehub(hubname): print("Updating: " + hubname) HubAnalyzer.report_downloading_progress = True HubAnalyzer.enforce_download_in_presence_of_data = True HubAnalyzer.getUsers(hubname) HubAnalyzer.enforce_download_in_presence_of_data = False