def importData(database, filename, user): """Function called by Gramps to import data on persons in VCard format.""" parser = VCardParser(database) try: with OpenFileOrStdin(filename) as filehandle: parser.parse(filehandle, user) except EnvironmentError as msg: user.notify_error(_("%s could not be opened\n") % filename, str(msg)) return except GrampsImportError as msg: user.notify_error(_("%s could not be opened\n") % filename, str(msg)) return return ImportInfo({_("Results"): _("done")})
def importData(database, filename, user): """Function called by Gramps to import data on persons in VCard format.""" parser = VCardParser(database) try: with OpenFileOrStdin(filename) as filehandle: parser.parse(filehandle) except EnvironmentError as msg: user.notify_error(_("%s could not be opened\n") % filename, str(msg)) return except GrampsImportError as msg: user.notify_error(_("%s could not be opened\n") % filename, str(msg)) return return None # This module doesn't provide info about what got imported.
def importData(dbase, filename, user): """Function called by Gramps to import data on persons in CSV format.""" if dbase.get_feature("skip-import-additions"): # don't add source or tags parser = CSVParser(dbase, user, None) else: parser = CSVParser(dbase, user, (config.get('preferences.tag-on-import-format') if config.get('preferences.tag-on-import') else None)) try: with OpenFileOrStdin(filename, 'b') as filehandle: parser.parse(filehandle) except EnvironmentError as err: user.notify_error(_("%s could not be opened\n") % filename, str(err)) return return None # This module doesn't provide info about what got imported.
def importData(database, filename, user): """Function called by Gramps to import data on persons in VCard format.""" parser = VCardParser(database) try: with OpenFileOrStdin(filename) as filehandle: parser.parse(filehandle, user) except EnvironmentError as msg: user.notify_error(_("%s could not be opened\n") % filename, str(msg)) return except GrampsImportError as msg: user.notify_error(_("%s could not be opened\n") % filename, str(msg)) return ## a "VCARD import report" happens in VCardParser so this is not needed: ## (but the imports_test.py unittest currently requires it, so here it is) return ImportInfo({_("Results"): _("done")})
def importData(dbase, filename, user): """Function called by Gramps to import data on persons in CSV format.""" dbase.disable_signals() try: with DbTxn(_("JSON import"), dbase, batch=True) as trans: with OpenFileOrStdin(filename, encoding="utf-8") as fp: line = fp.readline() while line: json = ast.literal_eval(line) obj = from_struct(json) if json["_class"] == "Person": dbase.add_person(obj, trans) elif json["_class"] == "Family": dbase.add_family(obj, trans) elif json["_class"] == "Event": dbase.add_event(obj, trans) elif json["_class"] == "MediaObject": dbase.add_object(obj, trans) elif json["_class"] == "Repository": dbase.add_repository(obj, trans) elif json["_class"] == "Tag": dbase.add_tag(obj, trans) elif json["_class"] == "Source": dbase.add_source(obj, trans) elif json["_class"] == "Citation": dbase.add_citation(obj, trans) elif json["_class"] == "Note": dbase.add_note(obj, trans) elif json["_class"] == "Place": dbase.add_place(obj, trans) else: LOG.warn("ignored: " + json) line = fp.readline() except EnvironmentError as err: user.notify_error(_("%s could not be opened\n") % filename, str(err)) dbase.enable_signals() dbase.request_rebuild()
def importData(db, filename, user): """Function called by Gramps to import data on persons in CSV format.""" db.disable_signals() try: with DbTxn(_("JSON import"), db, batch=True) as trans: with OpenFileOrStdin(filename, encoding="utf-8") as fp: line = fp.readline() while line: obj = from_json(line) if isinstance(obj, Person): db.add_person(obj, trans) elif isinstance(obj, Family): db.add_family(obj, trans) elif isinstance(obj, Event): db.add_event(obj, trans) elif isinstance(obj, Media): db.add_media(obj, trans) elif isinstance(obj, Repository): db.add_repository(obj, trans) elif isinstance(obj, Tag): db.add_tag(obj, trans) elif isinstance(obj, Source): db.add_source(obj, trans) elif isinstance(obj, Citation): db.add_citation(obj, trans) elif isinstance(obj, Note): db.add_note(obj, trans) elif isinstance(obj, Place): db.add_place(obj, trans) else: LOG.warn("ignored: " + data) line = fp.readline() except EnvironmentError as err: user.notify_error(_("%s could not be opened\n") % filename, str(err)) db.enable_signals() db.request_rebuild()