Create a new plugin class for Import plugins.
svn: r11142
This commit is contained in:
@@ -43,13 +43,6 @@ import cStringIO
|
||||
import logging
|
||||
log = logging.getLogger(".ImportCSV")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/GNOME Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
@@ -58,7 +51,7 @@ import gtk
|
||||
import gen.lib
|
||||
from QuestionDialog import ErrorDialog
|
||||
from DateHandler import parser as _dp
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug import PluginManager, ImportPlugin
|
||||
from Utils import gender as gender_map
|
||||
from Utils import ProgressMeter
|
||||
|
||||
@@ -798,12 +791,10 @@ class CSVParser:
|
||||
#-------------------------------------------------------------------------
|
||||
_mime_type = "text/x-comma-separated-values" # CSV Document
|
||||
_mime_type_rfc_4180 = "text/csv" # CSV Document See rfc4180 for mime type
|
||||
_filter = gtk.FileFilter()
|
||||
_filter.set_name(_('CSV spreadsheet files'))
|
||||
_filter.add_mime_type(_mime_type)
|
||||
_filter.add_mime_type(_mime_type_rfc_4180)
|
||||
_format_name = _('CSV Spreadheet')
|
||||
|
||||
pmgr = PluginManager.get_instance()
|
||||
pmgr.register_import(importData, _filter, [_mime_type, _mime_type_rfc_4180],
|
||||
0, _format_name)
|
||||
plugin = ImportPlugin(name = _('CSV Spreadheet'),
|
||||
description = _("Import data from CSV files"),
|
||||
import_function = importData,
|
||||
mime_types = [_mime_type, _mime_type_rfc_4180])
|
||||
pmgr.register_plugin(plugin)
|
||||
@@ -40,13 +40,6 @@ from gettext import gettext as _
|
||||
import logging
|
||||
log = logging.getLogger(".ImportGeneWeb")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/GNOME Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
@@ -56,7 +49,7 @@ import Errors
|
||||
import gen.lib
|
||||
import const
|
||||
from QuestionDialog import ErrorDialog
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug import PluginManager, ImportPlugin
|
||||
from htmlentitydefs import name2codepoint
|
||||
|
||||
_date_parse = re.compile('([kmes~?<>]+)?([0-9/]+)([J|H|F])?(\.\.)?([0-9/]+)?([J|H|F])?')
|
||||
@@ -926,14 +919,12 @@ class GeneWebParser:
|
||||
print txt
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
# Register with the plugin system
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_mime_type = const.APP_GENEWEB
|
||||
_filter = gtk.FileFilter()
|
||||
_filter.set_name(_('GeneWeb files'))
|
||||
_filter.add_mime_type(_mime_type)
|
||||
_format_name = _('GeneWeb')
|
||||
|
||||
pmgr = PluginManager.get_instance()
|
||||
pmgr.register_import(importData, _filter, [_mime_type], 0, _format_name)
|
||||
plugin = ImportPlugin(name = _('GeneWeb'),
|
||||
description = _("Import data from GeneWeb files"),
|
||||
import_function = importData,
|
||||
mime_types = [const.APP_GENEWEB])
|
||||
pmgr.register_plugin(plugin)
|
||||
|
||||
@@ -34,8 +34,6 @@ from gettext import gettext as _
|
||||
import os
|
||||
import struct
|
||||
|
||||
import time
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
# Set up logging
|
||||
@@ -49,12 +47,10 @@ log = logging.getLogger('.ImportProGen')
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import Errors
|
||||
import Utils
|
||||
import gen.lib
|
||||
import const
|
||||
from QuestionDialog import ErrorDialog
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug import PluginManager, ImportPlugin
|
||||
|
||||
|
||||
class ProgenError(Exception):
|
||||
@@ -1214,13 +1210,14 @@ class ProgenParser:
|
||||
self.db.commit_person(person, self.trans)
|
||||
self.progress.step()
|
||||
|
||||
|
||||
_mime_type = "application/x-progen"
|
||||
import gtk
|
||||
_filter = gtk.FileFilter()
|
||||
_filter.set_name(_('Pro-Gen files'))
|
||||
_filter.add_mime_type(_mime_type)
|
||||
_format_name = _('Pro-Gen')
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Register with the plugin system
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
pmgr = PluginManager.get_instance()
|
||||
pmgr.register_import(_importData, _filter, [_mime_type], 0, _format_name)
|
||||
plugin = ImportPlugin(name = _('Pro-Gen'),
|
||||
description = _("Import data from Pro-Gen files"),
|
||||
import_function = _importData,
|
||||
mime_types = ["application/x-progen"])
|
||||
pmgr.register_plugin(plugin)
|
||||
|
||||
@@ -40,13 +40,6 @@ from gettext import gettext as _
|
||||
import logging
|
||||
log = logging.getLogger(".ImportVCard")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK/GNOME Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
@@ -54,9 +47,8 @@ import gtk
|
||||
#-------------------------------------------------------------------------
|
||||
import Errors
|
||||
import gen.lib
|
||||
import const
|
||||
from QuestionDialog import ErrorDialog
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug import PluginManager, ImportPlugin
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -217,14 +209,12 @@ class VCardParser:
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
#
|
||||
# Register with the plugin system
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
_mime_type = const.APP_VCARD
|
||||
_filter = gtk.FileFilter()
|
||||
_filter.set_name(_('vCard files'))
|
||||
for mime in _mime_type:
|
||||
_filter.add_mime_type(mime)
|
||||
|
||||
pmgr = PluginManager.get_instance()
|
||||
pmgr.register_import(importData, _filter, _mime_type, 1)
|
||||
plugin = ImportPlugin(name = _('vCard'),
|
||||
description = _("Import data from vCard files"),
|
||||
import_function = importData,
|
||||
mime_types = ["text/x-vcard", "text/x-vcalendar"])
|
||||
pmgr.register_plugin(plugin)
|
||||
|
||||
@@ -34,13 +34,6 @@ import shutil
|
||||
import tempfile
|
||||
from gettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GTK+ Modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps Modules
|
||||
@@ -51,7 +44,7 @@ from QuestionDialog import ErrorDialog
|
||||
from Errors import HandleError
|
||||
from BasicUtils import UpdateCallback
|
||||
from BasicUtils import name_displayer
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug import PluginManager, ImportPlugin
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -321,11 +314,10 @@ def make_peron_name_remapper(other_database, formats_map):
|
||||
# Register with the plugin system
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_mime_type = 'application/x-gramps'
|
||||
_filter = gtk.FileFilter()
|
||||
_filter.set_name(_('GRAMPS 2.x database'))
|
||||
_filter.add_mime_type(_mime_type)
|
||||
_format_name = _('GRAMPS 2.x database')
|
||||
|
||||
pmgr = PluginManager.get_instance()
|
||||
pmgr.register_import(importData, _filter, [_mime_type], 0, _format_name)
|
||||
plugin = ImportPlugin(name = _('GRAMPS 2.x database'),
|
||||
description = _("Import data from GRAMPS 2.x "
|
||||
"database files"),
|
||||
import_function = importData,
|
||||
mime_types = ['application/x-gramps'])
|
||||
pmgr.register_plugin(plugin)
|
||||
|
||||
@@ -41,13 +41,6 @@ from gettext import gettext as _
|
||||
import logging
|
||||
log = logging.getLogger(".ReadPkg")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GNOME/GTK+ modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
@@ -57,7 +50,7 @@ import const
|
||||
from GrampsDbUtils import gramps_db_reader_factory
|
||||
from QuestionDialog import ErrorDialog, WarningDialog
|
||||
import Utils
|
||||
from gen.plug import PluginManager
|
||||
from gen.plug import PluginManager, ImportPlugin
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@@ -149,11 +142,9 @@ def impData(database, name, cb=None, cl=0):
|
||||
# Register with the plugin system
|
||||
#
|
||||
#------------------------------------------------------------------------
|
||||
_mime_type = 'application/x-gramps-package'
|
||||
_filter = gtk.FileFilter()
|
||||
_filter.set_name(_('GRAMPS packages'))
|
||||
_filter.add_mime_type(_mime_type)
|
||||
_format_name = _('GRAMPS package')
|
||||
|
||||
pmgr = PluginManager.get_instance()
|
||||
pmgr.register_import(impData, _filter, [_mime_type], 0, _format_name)
|
||||
plugin = ImportPlugin(name = _('GRAMPS package'),
|
||||
description = _("Import data from GRAMPS packages"),
|
||||
import_function = impData,
|
||||
mime_types = ['application/x-gramps-package'])
|
||||
pmgr.register_plugin(plugin)
|
||||
|
||||
Reference in New Issue
Block a user