Changes to imports - part 6

svn: r20491
This commit is contained in:
Nick Hall 2012-10-02 20:49:07 +00:00
parent 80fbfd4d8c
commit e96d4dd43f
10 changed files with 59 additions and 52 deletions

View File

@ -52,7 +52,7 @@ LOG = logging.getLogger(".clidbman")
# gramps modules
#
#-------------------------------------------------------------------------
import gen.db
from gramps.gen.db import DbBsddb
from gen.plug import BasePluginManager
from gen.config import config
from gen.constfunc import win
@ -266,7 +266,7 @@ class CLIDbManager(object):
name_file.close()
# write the version number into metadata
newdb = gen.db.DbBsddb()
newdb = DbBsddb()
newdb.write_version(new_path)
(tval, last) = time_val(new_path)
@ -325,7 +325,7 @@ class CLIDbManager(object):
# Create a new database
self.__start_cursor(_("Importing data..."))
dbclass = gen.db.DbBsddb
dbclass = DbBsddb
dbase = dbclass()
dbase.load(new_path, user.callback)

View File

@ -51,7 +51,8 @@ from gen.const import PLUGINS_DIR, USER_PLUGINS
from gen.errors import DbError
from gen.dbstate import DbState
from gen.db import DbBsddb
import gen.db.exceptions
from gramps.gen.db.exceptions import (DbUpgradeRequiredError,
DbVersionError)
from gen.plug import BasePluginManager
from gen.utils.config import get_researcher
from gen.recentfiles import recent_files
@ -153,10 +154,10 @@ class CLIDbLoader(object):
dbclass.load(filename, self._pulse_progress, mode)
dbclass.set_save_path(filename)
self.dbstate.change_database(dbclass())
except gen.db.exceptions.DbUpgradeRequiredError, msg:
except DbUpgradeRequiredError, msg:
self.dbstate.no_database()
self._errordialog( _("Cannot open database"), str(msg))
except gen.db.exceptions.DbVersionError, msg:
except DbVersionError, msg:
self.dbstate.no_database()
self._errordialog( _("Cannot open database"), str(msg))
except OSError, msg:

View File

@ -36,7 +36,7 @@ import sys
# Gramps Modules
#
#------------------------------------------------------------------------
import gen.user
import gramps.gen.user
#------------------------------------------------------------------------
#
@ -50,10 +50,10 @@ _SPINNER = ['|', '/', '-', '\\']
# User class
#
#-------------------------------------------------------------------------
class User(gen.user.User):
class User(gramps.gen.user.User):
"""
This class provides a means to interact with the user via CLI.
It implements the interface in gen.user.User()
It implements the interface in gramps.gen.user.User()
"""
def __init__(self, callback=None, error=None):
self.steps = 0;

View File

@ -56,7 +56,11 @@ from gi.repository import GObject
#-------------------------------------------------------------------------
from cli.grampscli import CLIDbLoader
from gen.config import config
import gen.db
from gramps.gen.db import DbBsddb
from gramps.gen.db.exceptions import (DbUpgradeRequiredError,
BsddbDowngradeError,
DbVersionError,
DbEnvironmentError)
from gen.utils.file import get_unicode_path_from_file_chooser
from gui.pluginmanager import GuiPluginManager
from gui.dialog import (DBErrorDialog, ErrorDialog, QuestionDialog2,
@ -291,7 +295,7 @@ class DbLoader(CLIDbLoader):
else:
mode = 'w'
db = gen.db.DbBsddb()
db = DbBsddb()
db.disable_signals()
self.dbstate.no_database()
@ -302,7 +306,7 @@ class DbLoader(CLIDbLoader):
db.load(filename, self._pulse_progress,
mode, upgrade=False)
self.dbstate.change_database(db)
except gen.db.exceptions.DbUpgradeRequiredError, msg:
except DbUpgradeRequiredError, msg:
if QuestionDialog2(_("Need to upgrade database!"),
str(msg),
_("Upgrade now"),
@ -315,13 +319,13 @@ class DbLoader(CLIDbLoader):
self.dbstate.change_database(db)
else:
self.dbstate.no_database()
except gen.db.exceptions.BsddbDowngradeError, msg:
except BsddbDowngradeError, msg:
self.dbstate.no_database()
self._errordialog( _("Cannot open database"), str(msg))
except gen.db.exceptions.DbVersionError, msg:
except DbVersionError, msg:
self.dbstate.no_database()
self._errordialog( _("Cannot open database"), str(msg))
except gen.db.exceptions.DbEnvironmentError, msg:
except DbEnvironmentError, msg:
self.dbstate.no_database()
self._errordialog( _("Cannot open database"), str(msg))
except OSError, msg:

View File

@ -21,10 +21,10 @@
# $Id$
import time
import gen.filters
from gui.editors import EditFilter
from gen.const import CUSTOM_FILTERS
from gen.filters import reload_custom_filters
from gramps.gen.filters import (rules, FilterList, GenericFilterFactory,
reload_custom_filters)
from gen.ggettext import sgettext as _
def make_filter(dbstate, uistate, objclass, gramps_ids, title=None):
@ -34,8 +34,8 @@ def make_filter(dbstate, uistate, objclass, gramps_ids, title=None):
>>> make_filter(dbstate, uistate, 'Person', ['I0003', ...])
"""
FilterClass = gen.filters.GenericFilterFactory(objclass)
rule = getattr(getattr(gen.filters.rules, objclass),'RegExpIdOf')
FilterClass = GenericFilterFactory(objclass)
rule = getattr(getattr(rules, objclass),'RegExpIdOf')
filter = FilterClass()
if title is None:
title = _("Filter %s from Clipboard") % objclass
@ -49,7 +49,7 @@ def make_filter(dbstate, uistate, objclass, gramps_ids, title=None):
'day': struct_time.tm_mday})
re = "|".join(["^%s$" % gid for gid in sorted(gramps_ids)])
filter.add_rule(rule([re]))
filterdb = gen.filters.FilterList(CUSTOM_FILTERS)
filterdb = FilterList(CUSTOM_FILTERS)
filterdb.load()
EditFilter(objclass, dbstate, uistate, [],
filter, filterdb,

View File

@ -41,6 +41,10 @@ from gen.config import config
from gen.display.name import displayer as name_displayer
from gen.filters import GenericFilter, rules
from gui.utils import ProgressMeter
from gramps.gen.proxy import (PrivateProxyDb,
LivingProxyDb,
FilterProxyDb,
ReferencedBySelectionProxyDb)
class Progress(object):
"""
@ -553,14 +557,13 @@ class WriterOptionBox(object):
["person", "note", "privacy", "living", "reference"]
"""
# If the private flag is set, apply the PrivateProxyDb
import gen.proxy
if proxy_name == "privacy":
if self.private:
if progress:
progress.reset(_("Filtering private data"))
progress.progress_cnt += 1
progress.update(progress.progress_cnt)
dbase = gen.proxy.PrivateProxyDb(dbase)
dbase = PrivateProxyDb(dbase)
# If the restrict flag is set, apply the LivingProxyDb
elif proxy_name == "living":
@ -570,10 +573,10 @@ class WriterOptionBox(object):
progress.progress_cnt += 1
progress.update(progress.progress_cnt)
mode = [None, # include living
gen.proxy.LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY,
gen.proxy.LivingProxyDb.MODE_EXCLUDE_ALL,
LivingProxyDb.MODE_INCLUDE_LAST_NAME_ONLY,
LivingProxyDb.MODE_EXCLUDE_ALL,
][self.restrict_num]
dbase = gen.proxy.LivingProxyDb(
dbase = LivingProxyDb(
dbase,
mode) #
@ -585,7 +588,7 @@ class WriterOptionBox(object):
progress.reset(_("Applying selected person filter"))
progress.progress_cnt += 1
progress.update(progress.progress_cnt)
dbase = gen.proxy.FilterProxyDb(
dbase = FilterProxyDb(
dbase, self.cfilter)
# Apply the Note Filter
@ -595,7 +598,7 @@ class WriterOptionBox(object):
progress.reset(_("Applying selected note filter"))
progress.progress_cnt += 1
progress.update(progress.progress_cnt)
dbase = gen.proxy.FilterProxyDb(
dbase = FilterProxyDb(
dbase, note_filter=self.nfilter)
# Apply the ReferencedBySelection
@ -607,7 +610,7 @@ class WriterOptionBox(object):
if self.reference_num == 0:
pass
elif self.reference_num == 1:
dbase = gen.proxy.ReferencedBySelectionProxyDb(dbase,
dbase = ReferencedBySelectionProxyDb(dbase,
all_people=True)
else:
raise AttributeError("no such proxy '%s'" % proxy_name)

View File

@ -50,8 +50,8 @@ from gen.config import config
from gen.plug.report import CATEGORY_GRAPHVIZ
from _reportdialog import ReportDialog
from _papermenu import PaperFrame
import gen.plug.docgen.graphdoc as graphdoc
import gen.plug
import gramps.gen.plug.docgen.graphdoc as graphdoc
from gramps.gen.plug.menu import Menu
#-------------------------------------------------------------------------------
#
@ -128,7 +128,7 @@ class GraphvizReportDialog(ReportDialog):
except TypeError:
self.options = option_class
menu = gen.plug.menu.Menu()
menu = Menu()
self.__gvoptions.add_menu_options(menu)
for category in menu.get_categories():

View File

@ -36,7 +36,7 @@ import sys
# Gramps modules
#
#-------------------------------------------------------------------------
import gen.user
import gramps.gen.user
from gui.utils import ProgressMeter
from gui.dialog import (WarningDialog, ErrorDialog, DBErrorDialog,
InfoDialog)
@ -45,10 +45,10 @@ from gui.dialog import (WarningDialog, ErrorDialog, DBErrorDialog,
# User class
#
#-------------------------------------------------------------------------
class User(gen.user.User):
class User(gramps.gen.user.User):
"""
This class provides a means to interact with the user via GTK.
It implements the interface in gen.user.User()
It implements the interface in gramps.gen.user.User()
"""
def __init__(self, callback=None, error=None):
self.progress = None

View File

@ -57,7 +57,7 @@ LOG = logging.getLogger(".WriteXML")
# load Gramps libraries
#
#-------------------------------------------------------------------------
import gen.lib
from gramps.gen.lib import Date, Person
from gen.updatecallback import UpdateCallback
from gen.db.exceptions import DbWriteFailure
from gen.const import VERSION
@ -501,9 +501,9 @@ class GrampsXmlWriter(UpdateCallback):
def write_person(self,person,index=1):
sp = " "*index
self.write_primary_tag("person",person,index)
if person.get_gender() == gen.lib.Person.MALE:
if person.get_gender() == Person.MALE:
self.write_line("gender","M",index+1)
elif person.get_gender() == gen.lib.Person.FEMALE:
elif person.get_gender() == Person.FEMALE:
self.write_line("gender","F",index+1)
else:
self.write_line("gender","U",index+1)
@ -862,15 +862,15 @@ class GrampsXmlWriter(UpdateCallback):
sp = ' '*indent
cal= date.get_calendar()
if cal != gen.lib.Date.CAL_GREGORIAN:
calstr = ' cformat="%s"' % gen.lib.Date.calendar_names[cal]
if cal != Date.CAL_GREGORIAN:
calstr = ' cformat="%s"' % Date.calendar_names[cal]
else:
calstr = ''
qual = date.get_quality()
if qual == gen.lib.Date.QUAL_ESTIMATED:
if qual == Date.QUAL_ESTIMATED:
qual_str = ' quality="estimated"'
elif qual == gen.lib.Date.QUAL_CALCULATED:
elif qual == Date.QUAL_CALCULATED:
qual_str = ' quality="calculated"'
else:
qual_str = ""
@ -890,7 +890,7 @@ class GrampsXmlWriter(UpdateCallback):
mode = date.get_modifier()
if date.is_compound():
if mode == gen.lib.Date.MOD_RANGE:
if mode == Date.MOD_RANGE:
tagname = 'daterange'
else:
tagname = 'datespan'
@ -901,16 +901,16 @@ class GrampsXmlWriter(UpdateCallback):
self.g.write('%s<%s start="%s" stop="%s"%s%s%s%s/>\n'
% (sp,tagname,d1,d2,qual_str,calstr,
dualdated_str, newyear_str))
elif mode != gen.lib.Date.MOD_TEXTONLY:
elif mode != Date.MOD_TEXTONLY:
date_str = self.get_iso_date(date.get_start_date())
if date_str == "":
return
if mode == gen.lib.Date.MOD_BEFORE:
if mode == Date.MOD_BEFORE:
mode_str = ' type="before"'
elif mode == gen.lib.Date.MOD_AFTER:
elif mode == Date.MOD_AFTER:
mode_str = ' type="after"'
elif mode == gen.lib.Date.MOD_ABOUT:
elif mode == Date.MOD_ABOUT:
mode_str = ' type="about"'
else:
mode_str = ""

View File

@ -59,8 +59,7 @@ from webapp.utils import _, build_args
from webapp.grampsdb.models import *
from webapp.grampsdb.view import *
from webapp.dbdjango import DbDjango
import cli.user
import gen.proxy
from gramps.cli.user import User
from gen.const import VERSION_TUPLE
from gen.utils.svn import get_svn_revision
@ -216,7 +215,7 @@ def process_report_run(request, handle):
mimetype = 'application/%s' % args["off"]
elif report.report_type == "export":
filename = "/tmp/%s-%s.%s" % (str(profile.user.username), str(handle), args["off"])
export_file(db, filename, cli.user.User()) # callback
export_file(db, filename, User()) # callback
mimetype = 'text/plain'
elif report.report_type == "import":
filename = download(args["i"], "/tmp/%s-%s.%s" % (str(profile.user.username),
@ -227,14 +226,14 @@ def process_report_run(request, handle):
import threading
def background():
try:
import_file(db, filename, cli.user.User()) # callback
import_file(db, filename, User()) # callback
except:
make_message(request, "import_file failed: " + traceback.format_exc())
threading.Thread(target=background).start()
make_message(request, "Your data is now being imported...")
return redirect("/report/")
else:
success = import_file(db, filename, cli.user.User()) # callback
success = import_file(db, filename, User()) # callback
if not success:
make_message(request, "Failed to load imported.")
return redirect("/report/")