def on_import_preferences(self, event=None): """ Imports a preference file. Backs up the user's current preference file into a directory, with a timestamp on the filename """ logger.debug("Prompting to import preferences") wildcard = _("Whyteboard Preference Files") + u" (*.pref)|*.pref" filename = file_dialog(self, _("Import Preferences From..."), wx.OPEN, wildcard, get_home_dir()) if filename: Config().init(filename) _dir = os.path.join(get_home_dir(), u"pref-bkup") if not os.path.isdir(_dir): os.makedirs(_dir) home = os.path.join(get_home_dir(), u"user.pref") if os.path.exists(home): stamp = time.strftime(u"%d-%m-%Y_%H-%M_%S") logger.debug("Renaming old preferences file to [%s]", stamp) os.rename(home, os.path.join(_dir, stamp + u".user.pref")) config = Config().clone() config.init(filename) self.update_config(config.config)