From 87badc8907ae9890983e38914c1271754a0cc331 Mon Sep 17 00:00:00 2001 From: Vassilii Khachaturov Date: Fri, 23 Aug 2013 08:48:02 +0000 Subject: [PATCH] 6878: CLI import/export plugins broken w/o DISPLAY Reapply from gramps40. commit b2977abeab0be3c9edd85f26f9c151d82198921c Author: Vassilii Khachaturov 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 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 --- gramps/plugins/importer/importcsv.py | 19 ++++++++++--------- gramps/plugins/importer/importvcard.py | 4 ++-- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gramps/plugins/importer/importcsv.py b/gramps/plugins/importer/importcsv.py index 4932e19c2..3a32ca9b4 100644 --- a/gramps/plugins/importer/importcsv.py +++ b/gramps/plugins/importer/importcsv.py @@ -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" diff --git a/gramps/plugins/importer/importvcard.py b/gramps/plugins/importer/importvcard.py index 74daa3084..eb4bef452 100644 --- a/gramps/plugins/importer/importvcard.py +++ b/gramps/plugins/importer/importvcard.py @@ -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)