def select(self): out = TOfficeTableInMemory() for web_domain in self.get_url_list(): site_info: TDeclarationWebSite site_info = self.web_sites.get_web_site(web_domain) out.add_office(site_info.parent_office) self.web_sites.offices = out
def split(self): parts_count = self.args.split_parts chunk_size = int(len(self.web_sites.offices.offices) / parts_count) offices = list(self.web_sites.offices.offices.values()) chunk_id = 0 cnt = 0 for l in range(0, len(offices), chunk_size): chunk_id += 1 o = TOfficeTableInMemory() for i in offices[l:l + chunk_size]: o.add_office(i) file_path = "chunk_offices_{}.txt".format(chunk_id) o.write_to_local_file(file_path) cnt += len(o.offices) assert cnt == len(offices)