def import_jsonl_to_traced_data_iterable(f): """ Imports a JSONL file to TracedData objects. Note that the JSONL file must be a serialized representation of TracedData objects in the format as produced by TracedDataJsonIO.export_traced_data_iterable_to_json. :param f: File to import JSONL from. :type f: file-like :return: TracedData objects deserialized from the JSONL file. :rtype: generator of TracedData """ data = [] for line in f: data.append(TracedData.deserialize(json.loads(line))) return data
bossaso_output_path = args.bossaso_output_path baidoa_output_path = args.baidoa_output_path # Load the phone number <-> uuid table log.info( f"Loading the phone number <-> uuid table from file '{phone_number_uuid_table_path}'..." ) with open(phone_number_uuid_table_path, "r") as f: phone_number_uuid_table = PhoneNumberUuidTable.load(f) log.info(f"Loaded {len(phone_number_uuid_table.numbers())} contacts") # Load the ADSS traced data log.info(f"Loading ADSS traced data from file '{traced_data_path}'...") with open(traced_data_path, "r") as f: # Manually deserialise the traced data because ADSS used an older serialiser data = [TracedData.deserialize(d) for d in json.load(f)] log.info(f"Loaded {len(data)} traced data objects") # Search the TracedData for the bossaso/baidoa contacts bossaso_uuids = set() baidoa_uuids = set() log.info("Searching for participants from Bossaso or Baidoa") for td in data: if td["district_coded"] == "STOP": continue if td["district_coded"][ "CodeID"] == CodeSchemes.SOMALIA_DISTRICT.get_code_with_match_value( "bossaso").code_id: bossaso_uuids.add(td["uid"]) elif td["district_coded"][