6878: CLI import/export plugins broken w/o DISPLAY
Reapply from gramps40. commit b2977abeab0be3c9edd85f26f9c151d82198921c Author: Vassilii Khachaturov <vassilii@tarunz.org> Date: Wed Aug 21 18:54:21 2013 +0000 Replace a hardwired ProgressMeter with proper calls to User Tested with impex.sh with and without DISPLAY env git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps40@22901 4ae1f11a-8b86-4847-b8af-ab372f36d1fd commit d67eda455f4f8c97e34ec7c85fb0bcf3a9c3b940 Author: Vassilii Khachaturov <vassilii@tarunz.org> Date: Wed Aug 21 18:54:05 2013 +0000 6957: support gender in vcard import forgotten merge cleanup git-svn-id: svn+ssh://svn.code.sf.net/p/gramps/code/branches/maintenance/gramps40@22900 4ae1f11a-8b86-4847-b8af-ab372f36d1fd svn: r22911
This commit is contained in:
parent
ffa6b33db8
commit
87badc8907
@ -56,7 +56,6 @@ from gramps.gen.plug.utils import OpenFileOrStdin
|
||||
from gramps.gen.datehandler import parser as _dp
|
||||
from gramps.gen.utils.string import gender as gender_map
|
||||
from gramps.gen.utils.id import create_id
|
||||
from gramps.gui.utils import ProgressMeter
|
||||
from gramps.gen.lib.eventroletype import EventRoleType
|
||||
from gramps.gen.constfunc import cuni, conv_to_unicode, STRTYPE
|
||||
from gramps.gen.config import config
|
||||
@ -326,15 +325,18 @@ class CSVParser(object):
|
||||
:param filehandle: open file handle positioned at start of the file
|
||||
"""
|
||||
data = self.read_csv(filehandle)
|
||||
progress = ProgressMeter(_('CSV Import'))
|
||||
progress.set_pass(_('Reading data...'), 1)
|
||||
progress.set_pass(_('Importing data...'), len(data))
|
||||
progress_title = _('CSV Import')
|
||||
self.user.begin_progress(progress_title,
|
||||
_('Reading data...'), 1)
|
||||
self.user.end_progress()
|
||||
self.user.begin_progress(progress_title,
|
||||
_('Importing data...'), len(data))
|
||||
tym = time.time()
|
||||
self.db.disable_signals()
|
||||
with DbTxn(_("CSV import"), self.db, batch=True) as self.trans:
|
||||
if self.default_tag and self.default_tag.handle is None:
|
||||
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.request_rebuild()
|
||||
tym = time.time() - tym
|
||||
@ -343,9 +345,9 @@ class CSVParser(object):
|
||||
LOG.debug(msg)
|
||||
LOG.debug("New Families: %d" % self.fam_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."""
|
||||
self.lineno = 0
|
||||
self.index = 0
|
||||
@ -356,8 +358,7 @@ class CSVParser(object):
|
||||
header = None
|
||||
line_number = 0
|
||||
for row in data:
|
||||
if progress is not None:
|
||||
progress.step()
|
||||
self.user.step_progress()
|
||||
line_number += 1
|
||||
if "".join(row) == "": # no blanks are allowed inside a table
|
||||
header = None # clear headers, ready for next "table"
|
||||
|
@ -521,9 +521,9 @@ class VCardParser(object):
|
||||
gender_value = gender_value.upper()
|
||||
gender_value = gender_value[0]
|
||||
if gender_value == 'M':
|
||||
gender = gen.lib.Person.MALE
|
||||
gender = Person.MALE
|
||||
elif gender_value == 'F':
|
||||
gender = gen.lib.Person.FEMALE
|
||||
gender = Person.FEMALE
|
||||
else:
|
||||
return
|
||||
self.person.set_gender(gender)
|
||||
|
Loading…
Reference in New Issue
Block a user