6878: CLI import/export plugins broken w/o DISPLAY
Replace a hardwired ProgressMeter with proper calls to User Tested with impex.sh with and without DISPLAY env svn: r22901
This commit is contained in:
parent
09d16526e9
commit
1524c0b7e5
@ -56,7 +56,6 @@ from gramps.gen.plug.utils import OpenFileOrStdin
|
|||||||
from gramps.gen.datehandler import parser as _dp
|
from gramps.gen.datehandler import parser as _dp
|
||||||
from gramps.gen.utils.string import gender as gender_map
|
from gramps.gen.utils.string import gender as gender_map
|
||||||
from gramps.gen.utils.id import create_id
|
from gramps.gen.utils.id import create_id
|
||||||
from gramps.gui.utils import ProgressMeter
|
|
||||||
from gramps.gen.lib.eventroletype import EventRoleType
|
from gramps.gen.lib.eventroletype import EventRoleType
|
||||||
from gramps.gen.constfunc import cuni, conv_to_unicode, STRTYPE
|
from gramps.gen.constfunc import cuni, conv_to_unicode, STRTYPE
|
||||||
from gramps.gen.config import config
|
from gramps.gen.config import config
|
||||||
@ -323,15 +322,18 @@ class CSVParser(object):
|
|||||||
:param filehandle: open file handle positioned at start of the file
|
:param filehandle: open file handle positioned at start of the file
|
||||||
"""
|
"""
|
||||||
data = self.read_csv(filehandle)
|
data = self.read_csv(filehandle)
|
||||||
progress = ProgressMeter(_('CSV Import'))
|
progress_title = _('CSV Import')
|
||||||
progress.set_pass(_('Reading data...'), 1)
|
self.user.begin_progress(progress_title,
|
||||||
progress.set_pass(_('Importing data...'), len(data))
|
_('Reading data...'), 1)
|
||||||
|
self.user.end_progress()
|
||||||
|
self.user.begin_progress(progress_title,
|
||||||
|
_('Importing data...'), len(data))
|
||||||
tym = time.time()
|
tym = time.time()
|
||||||
self.db.disable_signals()
|
self.db.disable_signals()
|
||||||
with DbTxn(_("CSV import"), self.db, batch=True) as self.trans:
|
with DbTxn(_("CSV import"), self.db, batch=True) as self.trans:
|
||||||
if self.default_tag and self.default_tag.handle is None:
|
if self.default_tag and self.default_tag.handle is None:
|
||||||
self.db.add_tag(self.default_tag, self.trans)
|
self.db.add_tag(self.default_tag, self.trans)
|
||||||
self._parse_csv_data(data, progress)
|
self._parse_csv_data(data)
|
||||||
self.db.enable_signals()
|
self.db.enable_signals()
|
||||||
self.db.request_rebuild()
|
self.db.request_rebuild()
|
||||||
tym = time.time() - tym
|
tym = time.time() - tym
|
||||||
@ -340,9 +342,9 @@ class CSVParser(object):
|
|||||||
LOG.debug(msg)
|
LOG.debug(msg)
|
||||||
LOG.debug("New Families: %d" % self.fam_count)
|
LOG.debug("New Families: %d" % self.fam_count)
|
||||||
LOG.debug("New Individuals: %d" % self.indi_count)
|
LOG.debug("New Individuals: %d" % self.indi_count)
|
||||||
progress.close()
|
self.user.end_progress()
|
||||||
|
|
||||||
def _parse_csv_data(self, data, progress=None):
|
def _parse_csv_data(self, data):
|
||||||
"""Parse each line of the input data and act accordingly."""
|
"""Parse each line of the input data and act accordingly."""
|
||||||
self.lineno = 0
|
self.lineno = 0
|
||||||
self.index = 0
|
self.index = 0
|
||||||
@ -353,8 +355,7 @@ class CSVParser(object):
|
|||||||
header = None
|
header = None
|
||||||
line_number = 0
|
line_number = 0
|
||||||
for row in data:
|
for row in data:
|
||||||
if progress is not None:
|
self.user.step_progress()
|
||||||
progress.step()
|
|
||||||
line_number += 1
|
line_number += 1
|
||||||
if "".join(row) == "": # no blanks are allowed inside a table
|
if "".join(row) == "": # no blanks are allowed inside a table
|
||||||
header = None # clear headers, ready for next "table"
|
header = None # clear headers, ready for next "table"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user