def read(self): fname = 'config.pkl' """ Read config file """ self.logger.debug(f'config read {self.cache_dir} {fname}') # Verify main directory exists if not os.path.exists(self.cache_dir): self.logger.warning(f"{self.cache_dir} folder not found.") TKHelper.fatal_error( f"{self.cache_dir} folder not found. Please use Config button to correct" ) self.config_cd = CachedDictionary.CachedDictionary( self.cache_dir, fname) self.config_cd.read() if self.config_cd.error: self.logger.error( f'Config {os.path.join(self.cache_dir, fname)} not found') # Create empty config file path = os.path.join(self.cache_dir, "config.pkl") self.set("gedcom_path", "GEDCOM filename: <empty>") with open(path, 'wb') as file: pickle.dump(self.config_cd.dict, file) return True else: return False
def load_handler(self): """ User pressed LOAD button to load an Ancestry file. Switch app display to the Review Widgets Load in file name and loop through file and find every PLACE entry and verify the entry against the geoname data """ self.w.original_entry.set_text("") self.w.remove_initialization_widgets() # Remove old widgets self.w.create_review_widgets( ) # Switch display from Initial widgets to main review widgets self.load_data() ged_path = self.cfg.get( "gedcom_path") # Get saved config setting for file # Load appropriate handler based on file type if ged_path is not None: if '.ged' in ged_path: self.out_suffix = "import.ged" self.ancestry_file_handler = Gedcom.Gedcom( in_path=ged_path, out_suffix=temp_suffix, cache_d=self.cache_dir, progress=None, geodata=self.geodata ) # Routines to open and parse GEDCOM file elif '.gramps' in ged_path: self.out_suffix = "import.gramps" # self.out_suffix = "csv" self.ancestry_file_handler = GrampsXml.GrampsXml( in_path=ged_path, out_suffix=temp_suffix, cache_d=self.cache_dir, progress=None, geodata=self.geodata ) # Routines to open and parse Gramps file else: self.out_suffix = 'unk.new.ged' messagebox.showwarning( f'UNKNOWN File type. Not .gramps and not .ged. \n\n{ged_path}') self.out_diag_file = open(ged_path + '.output.txt', 'w') self.in_diag_file = open(ged_path + '.input.txt', 'w') if self.ancestry_file_handler.error: TKHelper.fatal_error(f"File {ged_path} not found.") self.w.root.update() self.place: Loc.Loc = Loc.Loc( ) # Create an object to store info for the current Place # Add filename to Title path_parts = os.path.split(ged_path) # Extract filename from full path self.w.title.set_text(f'GEO FINDER - {path_parts[1]}') # Read file, find each place entry and handle it. self.w.user_entry.set_text("Scanning to previous position...") self.handle_place_entry()
def load_data(self): # Read in Skiplist, Replace list list self.skiplist = CachedDictionary(self.cache_dir, "skiplist.pkl") self.skiplist.read() self.global_replace = CachedDictionary(self.cache_dir, "global_replace.pkl") self.global_replace.read() # self.user_accepted = CachedDictionary(self.cache_dir, "accepted.pkl") # List of items that have been accepted # self.user_accepted.read() # Initialize geodata self.geodata = Geodata.Geodata(directory_name=self.directory, progress_bar=self.w.prog) error = self.geodata.read() if error: TKHelper.fatal_error(MISSING_FILES) # If the list of supported countries is unusually short, display note to user num = self.display_country_note() self.logger.info('{} countries will be loaded'.format(num)) # Read in Geoname Gazeteer file - city names, lat/long, etc. error = self.geodata.read_geonames() if error: TKHelper.fatal_error(MISSING_FILES) self.w.root.update() self.w.prog.update_progress(100, " ")
def display_country_note(self) -> int: """ display warning if only a small number of countries are enabled """ country_list, supported_countries = self.geodata.geo_files.get_supported_countries( ) self.w.root.update() if supported_countries == 0: TKHelper.fatal_error( "No countries enabled.\n\nUse Config Country Tab to change country list\n" ) # if supported_countries < 3: # messagebox.showinfo("Info", f"Loading geocode data for the following ISO country codes:" # f"\n\n{country_list}\n\nUse Config Country Tab to change country list\n") return supported_countries