From d486052378dc3e24e808146dfd148a4c40d7a1d4 Mon Sep 17 00:00:00 2001 From: prculley Date: Mon, 29 May 2017 16:23:53 -0500 Subject: [PATCH] Gedcom import with OBJE/FORM URL on event Fixes #7593. --- data/tests/imp_MediaTest.ged | 9 ++ data/tests/imp_MediaTest.gramps | 169 ++++++++++++++++++-------------- gramps/plugins/lib/libgedcom.py | 21 +++- 3 files changed, 120 insertions(+), 79 deletions(-) diff --git a/data/tests/imp_MediaTest.ged b/data/tests/imp_MediaTest.ged index c2ce7029d..1bde200f5 100644 --- a/data/tests/imp_MediaTest.ged +++ b/data/tests/imp_MediaTest.ged @@ -43,6 +43,15 @@ 2 NOTE @N0018@ 1 OBJE @M7@ 1 OBJE @M8@ +1 OBJE +2 FORM URL +2 FILE http:\\obje.form.on_person.org +1 BIRT +2 TYPE Birth of the Tester +2 DATE 2 OCT 1864 +2 OBJE +3 FORM URL +3 FILE http:\\obje.form.on_event.org 0 @M1@ OBJE 1 FORM jpeg 1 TITL Multimedia link to linked form v5.5 blob diff --git a/data/tests/imp_MediaTest.gramps b/data/tests/imp_MediaTest.gramps index 2674b4e01..22b6f1083 100644 --- a/data/tests/imp_MediaTest.gramps +++ b/data/tests/imp_MediaTest.gramps @@ -3,17 +3,26 @@ "http://gramps-project.org/xml/1.7.1/grampsxml.dtd">
- +
+ + + Birth + + Birth of the Tester + + + - + U The Tester + @@ -25,106 +34,107 @@ - + + - + 0 - - + + - + 77, 78 discussion of multimedia link with two files 4 - - + + - + A Great Photographer - + The Testers personal files The Tester Name: Tester Publishing Operations, Inc.; Location: OSF world - + - + - - + + - - + + - + - - - + + + - + - + - - - + + + - + - - - + + + - + - + - + - + - + - + - + Media note test: Multimedia link embedded form v5.5 n OBJE {1:1} p.55 +1 FORM <MULTIMEDIA_FORMAT> {1:1} p.48 @@ -132,7 +142,7 @@ n OBJE {1:1} p.55 +1 FILE <MULTIMEDIA_FILE_REFERENCE> {1:1} p.47 +1 <<NOTE_STRUCTURE>> {0:M} p.33 - + Media note test: Multimedia link embedded form v5.5.1 This note is not in the 5.5.1 spec, but is an obvious extrapolation from 5.5. n OBJE @@ -141,23 +151,27 @@ n OBJE +3 MEDI <SOURCE_MEDIA_TYPE> {0:1} p.62 +1 TITL <DESCRIPTIVE_TITLE> {0:1} p.48 - + Multimedia embedded 2nd copy v5.5 - + + http:\\obje.form.on_event.org + + Records not imported into INDI (individual) Gramps ID I0001: Could not import test_emb_55.jpg Line 18: 1 OBJE Could not import test_emb_551.jpg Line 26: 1 OBJE -Could not import test_emb_55.jpg Line 34: 1 OBJE +Could not import test_emb_55.jpg Line 34: 1 OBJE + - + SOMETEXT - + Media note test: Multimedia link to linked form v5.5 blob n @XREF:OBJE@ OBJE {1:1} +1 FORM <MULTIMEDIA_FORMAT> {1:1} p.48 @@ -171,10 +185,10 @@ n @XREF:OBJE@ OBJE {1:1} +1 RIN <AUTOMATED_RECORD_ID> {0:1} p.38 +1 <<CHANGE_DATE>> {0:1} p.29 - + Records not imported into OBJE (multi-media object) Gramps ID M1: -Tag recognized but not supported Line 49: 1 BLOB +Tag recognized but not supported Line 58: 1 BLOB .HM.......k.1..F.jwA.Dzzzzw............A....1.........0U.66..E.8 .......A..k.a6.A.......A..k.........../6....G.......0../..U..... .w1/m........HC0..../...zzzzzzzz..5zzk..AnA..U..W6U....2rRrRrRrR @@ -182,23 +196,25 @@ Tag recognized but not supported Line 49: /Dw/.Tvz.E5zzUE9/kHz.Tw2/DzzzEEA.kE2zk5yzk2/zzs21.U2/Dw/.Tw/.Tzy /.fy/.HzzkHzzzo21Ds00.E2.UE2.U62/.k./Ds0.UE0/Do0..E8/UE2.U62.U9w /.Tx/.20.jg2/jo2..9u/.0U.6A.zk -Line ignored as not understood Line 57: 1 OBJE @M2@ -Filename omitted Line 46: 0 M1 OBJE +Line ignored as not understood Line 66: 1 OBJE @M2@ +Filename omitted Line 55: 0 M1 OBJE + - + Records not imported into OBJE (multi-media object) Gramps ID M2: -Tag recognized but not supported Line 68: 1 BLOB +Tag recognized but not supported Line 77: 1 BLOB 67890gramps doesn't do this anyway, so don't bother doing it right. -Filename omitted Line 65: 0 M2 OBJE +Filename omitted Line 74: 0 M2 OBJE + - + Media note test: Multimedia link to linked form Gramps style v5.5ish file n @XREF:OBJE@ OBJE {1:1} +1 FORM <MULTIMEDIA_FORMAT> {1:1} p.48 @@ -206,18 +222,19 @@ n @XREF:OBJE@ OBJE {1:1} +1 FILE <MULTIMEDIA_FILE_REFERENCE> {1:1} p.47 +1 <<NOTE_STRUCTURE>> {0:M} p.33 - + Records not imported into OBJE (multi-media object) Gramps ID M3: -Could not import test.jpg Line 73: 1 FILE test.jpg +Could not import test.jpg Line 82: 1 FILE test.jpg + - + SOMETEXT - + Media note test: Multimedia link to linked form v5.5.1 file n @XREF:OBJE@ OBJE {1:1} +1 FILE <MULTIMEDIA_FILE_REFN> {1:M} p.54 @@ -231,25 +248,26 @@ n @XREF:OBJE@ OBJE {1:1} +1 <<SOURCE_CITATION>> {0:M} p.39 +1 <<CHANGE_DATE>> {0:1} p.31 - + who shall remain un-named - + Records not imported into OBJE (multi-media object) Gramps ID M4: -Could not import test.jpg Line 79: 1 FILE test.jpg +Could not import test.jpg Line 88: 1 FILE test.jpg + - + A fine gentelman was he, upstanding in his community and a great believer in the testing of open source software. - + A note on the FTM media, to see how this integrates... The DATE line is bad; it doesnt follow Gedcom standard at all, and includes the time. The TEXT line comes from the FTM media description. This is the media Note. - + Multimedia link to linked form FTM style n @XREF:OBJE@ OBJE {1:1} +1 FILE <MULTIMEDIA_FILE_REFN> {1:M} p.54 @@ -258,39 +276,42 @@ n @XREF:OBJE@ OBJE {1:1} +2 TEXT text string from FTM media description sometimes populated from exif comments +1 <<NOTE_STRUCTURE>> {0:M} p.33 - + Records not imported into OBJE (multi-media object) Gramps ID M5: -Could not import test.jpg Line 94: 1 FILE test.jpg +Could not import test.jpg Line 103: 1 FILE test.jpg + - + SOMETEXT - + Multimedia link to linked form v5.5.1 with two files - + A source who shall remain un-named - + Records not imported into OBJE (multi-media object) Gramps ID M6: -Could not import test.jpg Line 102: 1 FILE test.jpg -Multiple FILE in a single OBJE ignored Line 106: 1 FILE test1.jpg -Skipped subordinate line Line 107: 2 FORM jpeg -Skipped subordinate line Line 108: 3 TYPE photo -Skipped subordinate line Line 109: 2 TITL Multimedia link to linked form v5.5.1 with two files(2) +Could not import test.jpg Line 111: 1 FILE test.jpg +Multiple FILE in a single OBJE ignored Line 115: 1 FILE test1.jpg +Skipped subordinate line Line 116: 2 FORM jpeg +Skipped subordinate line Line 117: 3 TYPE photo +Skipped subordinate line Line 118: 2 TITL Multimedia link to linked form v5.5.1 with two files(2) + - + Records not imported into OBJE (multi-media object) Gramps ID M8: -Could not import No_path_No_Title_NoForm.jpg Line 129: 1 FILE No_path_No_Title_NoForm.jpg +Could not import No_path_No_Title_NoForm.jpg Line 138: 1 FILE No_path_No_Title_NoForm.jpg + diff --git a/gramps/plugins/lib/libgedcom.py b/gramps/plugins/lib/libgedcom.py index d488f90ba..fa84585e4 100644 --- a/gramps/plugins/lib/libgedcom.py +++ b/gramps/plugins/lib/libgedcom.py @@ -133,6 +133,7 @@ from gramps.gen.db.dbconst import EVENT_KEY from gramps.gui.dialog import WarningDialog from gramps.gen.lib.const import IDENTICAL, DIFFERENT from gramps.gen.lib import (StyledText, StyledTextTag, StyledTextTagType) +from gramps.gen.lib.urlbase import UrlBase from gramps.plugins.lib.libplaceimport import PlaceImport from gramps.gen.display.place import displayer as _pd from gramps.gen.utils.grampslocale import GrampsLocale @@ -5181,11 +5182,21 @@ class GedcomParser(UpdateCallback): # The following code that detects URL is an older v5.5 usage; the # modern option is to use the EMAIL tag. if isinstance(sub_state.form, str) and sub_state.form == "url": - url = Url() - url.set_path(sub_state.filename) - url.set_description(sub_state.title) - url.set_type(UrlType.WEB_HOME) - pri_obj.add_url(url) + if isinstance(pri_obj, UrlBase): + url = Url() + url.set_path(sub_state.filename) + url.set_description(sub_state.title) + url.set_type(UrlType.WEB_HOME) + pri_obj.add_url(url) + else: # some primary objects (Event) son't have spot for URL + new_note = Note(sub_state.filename) + new_note.set_gramps_id(self.nid_map[""]) + new_note.set_handle(create_id()) + new_note.set_type(OBJ_NOTETYPE.get(type(pri_obj).__name__, + NoteType.GENERAL)) + self.dbase.commit_note(new_note, self.trans, new_note.change) + pri_obj.add_note(new_note.get_handle()) + else: # to allow import of references to URLs (especially for import from # geni.com), do not try to find the file if it is blatently a URL