Esempio n. 1
0
 def __convert_db(self, name, dirname):
     """
     Actually convert the family tree into the default database backend.
     """
     try:
         db = open_database(name)
     except:
         ErrorDialog(_("Opening the '%s' database") % name,
                     _("An attempt to convert the database failed. "
                       "Perhaps it needs updating."),
                     parent=self.top)
         return
     plugin_manager = GuiPluginManager.get_instance()
     export_function = None
     for plugin in plugin_manager.get_export_plugins():
         if plugin.get_extension() == "gramps":
             export_function = plugin.get_export_function()
             break
     ## Next, get an XML dump:
     if export_function is None:
         ErrorDialog(_("Converting the '%s' database") % name,
                     _("An attempt to export the database failed."),
                     parent=self.top)
         db.close(user=self.user)
         return
     self.__start_cursor(_("Converting data..."))
     xml_file = os.path.join(dirname, "backup.gramps")
     export_function(db, xml_file, self.user)
     db.close(user=self.user)
     count = 1
     new_text = "%s %s" % (name, _("(Converted #%d)") % count)
     while self.existing_name(new_text):
         count += 1
         new_text = "%s %s" % (name, _("(Converted #%d)") % count)
     dbid = config.get('database.backend')
     new_path, newname = self._create_new_db(new_text,
                                             dbid=dbid,
                                             edit_entry=False)
     ## Create a new database of correct type:
     dbase = make_database(dbid)
     dbase.load(new_path)
     ## import from XML
     import_function = None
     for plugin in plugin_manager.get_import_plugins():
         if plugin.get_extension() == "gramps":
             import_function = plugin.get_import_function()
     if import_function is None:
         ErrorDialog(_("Converting the '%s' database") % name,
                     _("An attempt to import into the database failed."),
                     parent=self.top)
     else:
         import_function(dbase, xml_file, self.user)
     self.__end_cursor()
     dbase.close(user=self.user)
     self.__populate()
     self._select_default()
Esempio n. 2
0
 def __convert_db(self, name, dirname):
     """
     Actually convert the family tree into the default database backend.
     """
     try:
         db = open_database(name)
     except:
         ErrorDialog(_("Opening the '%s' database") % name,
                     _("An attempt to convert the database failed. "
                       "Perhaps it needs updating."), parent=self.top)
         return
     plugin_manager = GuiPluginManager.get_instance()
     export_function = None
     for plugin in plugin_manager.get_export_plugins():
         if plugin.get_extension() == "gramps":
             export_function = plugin.get_export_function()
             break
     ## Next, get an XML dump:
     if export_function is None:
         ErrorDialog(_("Converting the '%s' database") % name,
                     _("An attempt to export the database failed."),
                     parent=self.top)
         db.close(user=self.user)
         return
     self.__start_cursor(_("Converting data..."))
     xml_file = os.path.join(dirname, "backup.gramps")
     export_function(db, xml_file, self.user)
     db.close(user=self.user)
     count = 1
     new_text = "%s %s" % (name, _("(Converted #%d)") % count)
     while self.existing_name(new_text):
         count += 1
         new_text = "%s %s" % (name, _("(Converted #%d)") % count)
     dbid = config.get('database.backend')
     new_path, newname = self._create_new_db(new_text, dbid=dbid,
                                             edit_entry=False)
     ## Create a new database of correct type:
     dbase = make_database(dbid)
     dbase.load(new_path)
     ## import from XML
     import_function = None
     for plugin in plugin_manager.get_import_plugins():
         if plugin.get_extension() == "gramps":
             import_function = plugin.get_import_function()
     if import_function is None:
         ErrorDialog(_("Converting the '%s' database") % name,
                     _("An attempt to import into the database failed."),
                     parent=self.top)
     else:
         import_function(dbase, xml_file, self.user)
     self.__end_cursor()
     dbase.close(user=self.user)
     self.__populate()
     self._select_default()