Gedcom fixes for mime and finding media (#795)

* Fix Gedcom import/export for more comprehensive mime types

Fixes #11041

* Fix Gedcom import to better find media files

Issue #11041

* Fix Gedcom test files for media mime and error location message
This commit is contained in:
Paul Culley 2019-03-16 22:44:42 -05:00 committed by Sam Manzi
parent d96b6d19b8
commit 100d6d0672
6 changed files with 124 additions and 98 deletions

View File

@ -1,12 +1,12 @@
0 HEAD 0 HEAD
1 SOUR Gramps 1 SOUR Gramps
2 VERS 5.0.1 2 VERS 5.0.2
2 NAME Gramps 2 NAME Gramps
1 DATE 7 NOV 2018 1 DATE 5 MAR 2019
2 TIME 16:03:33 2 TIME 09:11:15
1 SUBM @SUBM@ 1 SUBM @SUBM@
1 FILE C:\Users\prc\AppData\Roaming\gramps\temp\exp_sample_ged.ged 1 FILE C:\Users\prc\AppData\Roaming\gramps\temp\exp_sample_ged.ged
1 COPR Copyright (c) 2018 Alex Roitman,,,. 1 COPR Copyright (c) 2019 Alex Roitman,,,.
1 GEDC 1 GEDC
2 VERS 5.5.1 2 VERS 5.5.1
2 FORM LINEAGE-LINKED 2 FORM LINEAGE-LINKED
@ -1420,8 +1420,8 @@
0 @N0018@ NOTE Another Citation Note 0 @N0018@ NOTE Another Citation Note
0 @N0019@ NOTE A bad photo for sure 0 @N0019@ NOTE A bad photo for sure
0 @O0000@ OBJE 0 @O0000@ OBJE
1 FILE c:\users\prc\workspace\grampsm\main\data\tests\O0.jpg 1 FILE c:\msys64\mingw64\share\gramps\tests\O0.jpg
2 FORM jpeg 2 FORM jpg
2 TITL Michael O'Toole 2015-11 2 TITL Michael O'Toole 2015-11
1 NOTE @N0019@ 1 NOTE @N0019@
1 CHAN 1 CHAN

View File

@ -3,41 +3,41 @@
"http://gramps-project.org/xml/1.7.1/grampsxml.dtd"> "http://gramps-project.org/xml/1.7.1/grampsxml.dtd">
<database xmlns="http://gramps-project.org/xml/1.7.1/"> <database xmlns="http://gramps-project.org/xml/1.7.1/">
<header> <header>
<created date="2016-08-29" version="5.0.0-alpha1"/> <created date="2019-03-13" version="5.0.2"/>
<researcher> <researcher>
</researcher> </researcher>
</header> </header>
<events> <events>
<event handle="_0000000500000005" change="1472500305" id="E0000"> <event handle="_0000000500000005" change="1" id="E0000">
<type>Birth</type> <type>Birth</type>
<dateval val="1816"/> <dateval val="1816"/>
<place hlink="_0000000700000007"/> <place hlink="_0000000700000007"/>
<citationref hlink="_0000000600000006"/> <citationref hlink="_0000000600000006"/>
</event> </event>
<event handle="_0000000800000008" change="1472500305" id="E0001"> <event handle="_0000000800000008" change="1" id="E0001">
<type>Residence</type> <type>Residence</type>
<dateval val="1850"/> <dateval val="1850"/>
<place hlink="_0000000a0000000a"/> <place hlink="_0000000a0000000a"/>
<citationref hlink="_0000000900000009"/> <citationref hlink="_0000000900000009"/>
</event> </event>
<event handle="_0000000b0000000b" change="1472500305" id="E0002"> <event handle="_0000000b0000000b" change="1" id="E0002">
<type>Death</type> <type>Death</type>
<datestr val="1850/1860"/> <datestr val="1850/1860"/>
<place hlink="_0000000c0000000c"/> <place hlink="_0000000c0000000c"/>
</event> </event>
<event handle="_0000000f0000000f" change="1472500305" id="E0003"> <event handle="_0000000f0000000f" change="1" id="E0003">
<type>Marriage</type> <type>Marriage</type>
<dateval val="1841" type="about"/> <dateval val="1841" type="about"/>
<place hlink="_0000001000000010"/> <place hlink="_0000001000000010"/>
</event> </event>
<event handle="_0000001100000011" change="1472500305" id="E0004"> <event handle="_0000001100000011" change="1" id="E0004">
<type>Marriage</type> <type>Marriage</type>
<dateval val="1847-08"/> <dateval val="1847-08"/>
<place hlink="_0000001200000012"/> <place hlink="_0000001200000012"/>
</event> </event>
</events> </events>
<people> <people>
<person handle="_0000000100000001" change="1472500305" id="I0278"> <person handle="_0000000100000001" change="1" id="I0278">
<gender>M</gender> <gender>M</gender>
<name type="Birth Name"> <name type="Birth Name">
<first>Andrew</first> <first>Andrew</first>
@ -54,13 +54,13 @@
</person> </person>
</people> </people>
<families> <families>
<family handle="_0000000d0000000d" change="1472500305" id="F0073"> <family handle="_0000000d0000000d" change="1" id="F0073">
<rel type="Married"/> <rel type="Married"/>
<father hlink="_0000000100000001"/> <father hlink="_0000000100000001"/>
<eventref hlink="_0000000f0000000f" role="Family"/> <eventref hlink="_0000000f0000000f" role="Family"/>
<childref hlink="_0000000100000001"/> <childref hlink="_0000000100000001"/>
</family> </family>
<family handle="_0000000e0000000e" change="1472500305" id="F0074"> <family handle="_0000000e0000000e" change="1" id="F0074">
<rel type="Married"/> <rel type="Married"/>
<father hlink="_0000000100000001"/> <father hlink="_0000000100000001"/>
<eventref hlink="_0000001100000011" role="Family"/> <eventref hlink="_0000001100000011" role="Family"/>
@ -68,19 +68,19 @@
</family> </family>
</families> </families>
<citations> <citations>
<citation handle="_0000000400000004" change="1472500305" id="C0000"> <citation handle="_0000000400000004" change="1" id="C0000">
<page>Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248</page> <page>Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248</page>
<confidence>2</confidence> <confidence>2</confidence>
<objref hlink="_0000000300000003"/> <objref hlink="_0000000300000003"/>
<sourceref hlink="_0000000200000002"/> <sourceref hlink="_0000000200000002"/>
</citation> </citation>
<citation handle="_0000000600000006" change="1472500305" id="C0001"> <citation handle="_0000000600000006" change="1" id="C0001">
<page>Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248</page> <page>Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248</page>
<confidence>2</confidence> <confidence>2</confidence>
<objref hlink="_0000000300000003"/> <objref hlink="_0000000300000003"/>
<sourceref hlink="_0000000200000002"/> <sourceref hlink="_0000000200000002"/>
</citation> </citation>
<citation handle="_0000000900000009" change="1472500305" id="C0002"> <citation handle="_0000000900000009" change="1" id="C0002">
<page>Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248</page> <page>Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248</page>
<confidence>2</confidence> <confidence>2</confidence>
<objref hlink="_0000000300000003"/> <objref hlink="_0000000300000003"/>
@ -88,7 +88,7 @@
</citation> </citation>
</citations> </citations>
<sources> <sources>
<source handle="_0000000200000002" change="1472500305" id="S0029"> <source handle="_0000000200000002" change="1" id="S0029">
<stitle>1850 United States Federal Census</stitle> <stitle>1850 United States Federal Census</stitle>
<sauthor>Ancestry.com</sauthor> <sauthor>Ancestry.com</sauthor>
<spubinfo>Name: Ancestry.com Operations, Inc.; Location: Provo, UT, USA; Date: 2009;</spubinfo> <spubinfo>Name: Ancestry.com Operations, Inc.; Location: Provo, UT, USA; Date: 2009;</spubinfo>
@ -96,42 +96,43 @@
</source> </source>
</sources> </sources>
<places> <places>
<placeobj handle="_0000000700000007" change="1472500305" id="P0000" type="Unknown"> <placeobj handle="_0000000700000007" change="1" id="P0000" type="Unknown">
<ptitle>Tennessee, USA</ptitle> <ptitle>Tennessee, USA</ptitle>
<pname value="Tennessee, USA"/> <pname value="Tennessee, USA"/>
</placeobj> </placeobj>
<placeobj handle="_0000000a0000000a" change="1472500305" id="P0001" type="Unknown"> <placeobj handle="_0000000a0000000a" change="1" id="P0001" type="Unknown">
<ptitle>District 14, Cape Girardeau, Missouri, USA</ptitle> <ptitle>District 14, Cape Girardeau, Missouri, USA</ptitle>
<pname value="District 14, Cape Girardeau, Missouri, USA"/> <pname value="District 14, Cape Girardeau, Missouri, USA"/>
</placeobj> </placeobj>
<placeobj handle="_0000000c0000000c" change="1472500305" id="P0002" type="Unknown"> <placeobj handle="_0000000c0000000c" change="1" id="P0002" type="Unknown">
<ptitle>Bollinger Co. MO</ptitle> <ptitle>Bollinger Co. MO</ptitle>
<pname value="Bollinger Co. MO"/> <pname value="Bollinger Co. MO"/>
</placeobj> </placeobj>
<placeobj handle="_0000001000000010" change="1472500305" id="P0003" type="Unknown"> <placeobj handle="_0000001000000010" change="1" id="P0003" type="Unknown">
<ptitle>Union Co.?, IL</ptitle> <ptitle>Union Co.?, IL</ptitle>
<pname value="Union Co.?, IL"/> <pname value="Union Co.?, IL"/>
</placeobj> </placeobj>
<placeobj handle="_0000001200000012" change="1472500305" id="P0004" type="Unknown"> <placeobj handle="_0000001200000012" change="1" id="P0004" type="Unknown">
<ptitle>Wayne, Missouri, United States</ptitle> <ptitle>Wayne, Missouri, United States</ptitle>
<pname value="Wayne, Missouri, United States"/> <pname value="Wayne, Missouri, United States"/>
</placeobj> </placeobj>
</places> </places>
<objects> <objects>
<object handle="_0000000300000003" change="1472500305" id="M159"> <object handle="_0000000300000003" change="1" id="M159">
<file src="1850 United States Federal Census(11)-1.jpg" mime="image/jpeg" description="1850 United States Federal Census"/> <file src="1850 United States Federal Census(11)-1.jpg" mime="image/jpeg" description="1850 United States Federal Census"/>
<noteref hlink="_0000001400000014"/> <noteref hlink="_0000001400000014"/>
<noteref hlink="_0000001500000015"/> <noteref hlink="_0000001500000015"/>
</object> </object>
<object handle="_0000001600000016" change="1472500305" id="M158"> <object handle="_0000001600000016" change="1" id="M158">
<file src="D:/Users/PRC/Downloads/1850 United States Federal Census(11)-1.jpg" mime="image/jpeg" description="D:\Users\PRC\Downloads\1850 United States Federal Census(11)-1.jpg"/> <file src="/Users/PRC/Downloads/1850 United States Federal Census(11)-1.jpg" mime="image/jpeg" description="/Users/PRC/Downloads/1850 United States Federal Census(11)-1.jpg"/>
<noteref hlink="_0000001700000017"/>
</object> </object>
<object handle="_0000001700000017" change="1472500305" id="M157"> <object handle="_0000001800000018" change="1" id="M157">
<file src="http://1.gravatar.com/avatar/77e02a3c8c665155ad1acaac8c2742e0?s=120&amp;d=mm&amp;r=pg" mime="unknown" description="http://1.gravatar.com/avatar/77e02a3c8c665155ad1acaac8c2742e0?s=120&amp;d=mm&amp;r=pg"/> <file src="http://1.gravatar.com/avatar/77e02a3c8c665155ad1acaac8c2742e0?s=120&amp;d=mm&amp;r=pg" mime="unknown" description="http://1.gravatar.com/avatar/77e02a3c8c665155ad1acaac8c2742e0?s=120&amp;d=mm&amp;r=pg"/>
</object> </object>
</objects> </objects>
<repositories> <repositories>
<repository handle="_0000001300000013" change="1472500305" id="R0001"> <repository handle="_0000001300000013" change="1" id="R0001">
<rname>Ancestry.com</rname> <rname>Ancestry.com</rname>
<type>Library</type> <type>Library</type>
<address> <address>
@ -140,16 +141,26 @@
</repository> </repository>
</repositories> </repositories>
<notes> <notes>
<note handle="_0000001400000014" change="1472500305" id="N0000" type="Media Note"> <note handle="_0000001400000014" change="1" id="N0000" type="Media Note">
<text>Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248</text> <text>Year: 1850; Census Place: District 14, Cape Girardeau, Missouri; Roll: M432_394; Page: 435B; Image: 248 </text>
</note> </note>
<note handle="_0000001500000015" change="1472500305" id="N0001" type="GEDCOM import"> <note handle="_0000001500000015" change="1" id="N0001" type="GEDCOM import">
<text>Records not imported into OBJE (multi-media object) Gramps ID M159: <text>Records not imported into OBJE (multi-media object) Gramps ID M159:
Could not import 1850 United States Federal Census(11)-1.jpg Line 70: 1 FILE 1850 United States Federal Census(11)-1.jpg</text> Could not import 1850 United States Federal Census(11)-1.jpg Line 70: 1 FILE 1850 United States Federal Census(11)-1.jpg
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="200"/> <range start="0" end="200"/>
</style> </style>
</note> </note>
<note handle="_0000001700000017" change="1" id="N0002" type="GEDCOM import">
<text>Records not imported into OBJE (multi-media object) Gramps ID M158:
Could not import D:\Users\PRC\Downloads\1850 United States Federa Line 75: 1 FILE D:\Users\PRC\Downloads\1850 United States Federal Census(11)-1.jpg
</text>
<style name="fontface" value="Monospace">
<range start="0" end="223"/>
</style>
</note>
</notes> </notes>
</database> </database>

View File

@ -3,7 +3,7 @@
"http://gramps-project.org/xml/1.7.1/grampsxml.dtd"> "http://gramps-project.org/xml/1.7.1/grampsxml.dtd">
<database xmlns="http://gramps-project.org/xml/1.7.1/"> <database xmlns="http://gramps-project.org/xml/1.7.1/">
<header> <header>
<created date="2019-02-01" version="5.0.2"/> <created date="2019-03-05" version="5.0.2"/>
<researcher> <researcher>
</researcher> </researcher>
</header> </header>
@ -69,7 +69,7 @@
<noteref hlink="_0000000b0000000b"/> <noteref hlink="_0000000b0000000b"/>
</object> </object>
<object handle="_0000000400000004" change="548708291" id="M1"> <object handle="_0000000400000004" change="548708291" id="M1">
<file src="" mime="" description="Multimedia link to linked form v5.5 blob"/> <file src="" mime="image/jpeg" description="Multimedia link to linked form v5.5 blob"/>
<attribute type="REFN" value="Ref12345M1"> <attribute type="REFN" value="Ref12345M1">
<noteref hlink="_0000001200000012"/> <noteref hlink="_0000001200000012"/>
</attribute> </attribute>
@ -118,7 +118,7 @@
<citationref hlink="_0000002700000027"/> <citationref hlink="_0000002700000027"/>
</object> </object>
<object handle="_0000000c0000000c" change="1" id="O0002"> <object handle="_0000000c0000000c" change="1" id="O0002">
<file src="http://www.geni.com/photo/view?photo_id=6000000001341319061" mime="unknown" description="Multimedia link embedded form v5.5 URL"/> <file src="http://www.geni.com/photo/view?photo_id=6000000001341319061" mime="text/html" description="Multimedia link embedded form v5.5 URL"/>
<noteref hlink="_0000000b0000000b"/> <noteref hlink="_0000000b0000000b"/>
</object> </object>
<object handle="_0000000d0000000d" change="1" id="M7"> <object handle="_0000000d0000000d" change="1" id="M7">
@ -130,7 +130,7 @@
<noteref hlink="_0000002900000029"/> <noteref hlink="_0000002900000029"/>
</object> </object>
<object handle="_0000001500000015" change="1" id="M2"> <object handle="_0000001500000015" change="1" id="M2">
<file src="" mime="" description="2nd blob Multimedia link to linked form v5.5 blob"/> <file src="" mime="image/jpeg" description="2nd blob Multimedia link to linked form v5.5 blob"/>
<noteref hlink="_0000001600000016"/> <noteref hlink="_0000001600000016"/>
</object> </object>
</objects> </objects>

View File

@ -3,7 +3,7 @@
"http://gramps-project.org/xml/1.7.1/grampsxml.dtd"> "http://gramps-project.org/xml/1.7.1/grampsxml.dtd">
<database xmlns="http://gramps-project.org/xml/1.7.1/"> <database xmlns="http://gramps-project.org/xml/1.7.1/">
<header> <header>
<created date="2016-10-24" version="5.0.0-alpha1"/> <created date="2019-03-05" version="5.0.2"/>
<researcher> <researcher>
<resname>Alex Roitman,,,</resname> <resname>Alex Roitman,,,</resname>
<resaddr>Not Provided</resaddr> <resaddr>Not Provided</resaddr>
@ -1456,13 +1456,13 @@
<noteref hlink="_000000f9000000f9"/> <noteref hlink="_000000f9000000f9"/>
</object> </object>
<object handle="_000000d1000000d1" change="1" id="O0001"> <object handle="_000000d1000000d1" change="1" id="O0001">
<file src="Magnes&amp;Anna_smiths_marr_cert.jpg" mime="unknown" description="Magnes&amp;Anna_smiths_marr_cert.jpg"/> <file src="Magnes&amp;Anna_smiths_marr_cert.jpg" mime="image/jpeg" description="Magnes&amp;Anna_smiths_marr_cert.jpg"/>
</object> </object>
<object handle="_000000d8000000d8" change="1" id="O0002"> <object handle="_000000d8000000d8" change="1" id="O0002">
<file src="John&amp;Alice_smiths_marr_cert.jpg" mime="unknown" description="John&amp;Alice_smiths_marr_cert.jpg"/> <file src="John&amp;Alice_smiths_marr_cert.jpg" mime="image/jpeg" description="John&amp;Alice_smiths_marr_cert.jpg"/>
</object> </object>
<object handle="_000000f1000000f1" change="1" id="O0003"> <object handle="_000000f1000000f1" change="1" id="O0003">
<file src="Attic_photo.jpg" mime="unknown" description="Attic_photo.jpg"/> <file src="Attic_photo.jpg" mime="image/jpeg" description="Attic_photo.jpg"/>
</object> </object>
</objects> </objects>
<repositories> <repositories>
@ -1506,7 +1506,8 @@
<note handle="_0000000100000001" change="1" id="N0000" type="GEDCOM import"> <note handle="_0000000100000001" change="1" id="N0000" type="GEDCOM import">
<text>Records not imported into HEAD (header): <text>Records not imported into HEAD (header):
GEDCOM FORM not supported Line 14: 2 FORM NOT LINEAGE-LINKED</text> GEDCOM FORM not supported Line 14: 2 FORM NOT LINEAGE-LINKED
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="148"/> <range start="0" end="148"/>
</style> </style>
@ -1514,7 +1515,8 @@ GEDCOM FORM not supported Line 14:
<note handle="_0000000200000002" change="1" id="N0001" type="GEDCOM import"> <note handle="_0000000200000002" change="1" id="N0001" type="GEDCOM import">
<text>Records not imported into SUBM (Submitter): (@SUBM@) Alex Roitman,,,: <text>Records not imported into SUBM (Submitter): (@SUBM@) Alex Roitman,,,:
Line ignored as not understood Line 23: 2 NOTE No address provided (note not supported)</text> Line ignored as not understood Line 23: 2 NOTE No address provided (note not supported)
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="199"/> <range start="0" end="199"/>
</style> </style>
@ -1523,7 +1525,8 @@ Line ignored as not understood Line 23:
<text>Records not imported into FAM (family) Gramps ID F0003: <text>Records not imported into FAM (family) Gramps ID F0003:
Line ignored as not understood Line 46: 2 SOUR Not really allowed here Line ignored as not understood Line 46: 2 SOUR Not really allowed here
Filename omitted Line 48: 1 OBJE</text> Filename omitted Line 48: 1 OBJE
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="256"/> <range start="0" end="256"/>
</style> </style>
@ -1562,7 +1565,8 @@ Filename omitted Line 48:
<text>Records not imported into INDI (individual) Gramps ID I0016: <text>Records not imported into INDI (individual) Gramps ID I0016:
Warn: ADDR overwritten Line 204: 3 ADR1 456 Main St again Warn: ADDR overwritten Line 204: 3 ADR1 456 Main St again
ADDR element ignored '459 Main St.' Line 202: 2 ADDR 459 Main St., The Village, San Francisco, CA, USA</text> ADDR element ignored '459 Main St.' Line 202: 2 ADDR 459 Main St., The Village, San Francisco, CA, USA
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="304"/> <range start="0" end="304"/>
</style> </style>
@ -1573,7 +1577,8 @@ ADDR element ignored '459 Main St.' Line 202:
<note handle="_0000004700000047" change="1" id="N0014" type="GEDCOM import"> <note handle="_0000004700000047" change="1" id="N0014" type="GEDCOM import">
<text>Records not imported into INDI (individual) Gramps ID I0018: <text>Records not imported into INDI (individual) Gramps ID I0018:
Tag recognized but not supported Line 245: 2 TYPE first generaton</text> Tag recognized but not supported Line 245: 2 TYPE first generaton
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="165"/> <range start="0" end="165"/>
</style> </style>
@ -1604,7 +1609,8 @@ Company. He enlisted in the army at Sparks 7 December 1917 and served as a Corpo
<note handle="_000000cf000000cf" change="1" id="N0021" type="GEDCOM import"> <note handle="_000000cf000000cf" change="1" id="N0021" type="GEDCOM import">
<text>Records not imported into FAM (family) Gramps ID F0010: <text>Records not imported into FAM (family) Gramps ID F0010:
Tag recognized but not supported Line 863: 2 _STAT</text> Tag recognized but not supported Line 863: 2 _STAT
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="146"/> <range start="0" end="146"/>
</style> </style>
@ -1613,7 +1619,8 @@ Tag recognized but not supported Line 863:
<text>Records not imported into FAM (family) Gramps ID F0011: <text>Records not imported into FAM (family) Gramps ID F0011:
Could not import Magnes&amp;Anna_smiths_marr_cert.jpg Line 878: 3 OBJE Could not import Magnes&amp;Anna_smiths_marr_cert.jpg Line 878: 3 OBJE
Could not import Magnes&amp;Anna_smiths_marr_cert.jpg Line 881: 2 OBJE</text> Could not import Magnes&amp;Anna_smiths_marr_cert.jpg Line 881: 2 OBJE
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="233"/> <range start="0" end="233"/>
</style> </style>
@ -1621,7 +1628,8 @@ Could not import Magnes&amp;Anna_smiths_marr_cert.jpg Line 8
<note handle="_000000d9000000d9" change="1" id="N0023" type="GEDCOM import"> <note handle="_000000d9000000d9" change="1" id="N0023" type="GEDCOM import">
<text>Records not imported into FAM (family) Gramps ID F0012: <text>Records not imported into FAM (family) Gramps ID F0012:
Could not import John&amp;Alice_smiths_marr_cert.jpg Line 905: 1 OBJE</text> Could not import John&amp;Alice_smiths_marr_cert.jpg Line 905: 1 OBJE
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="145"/> <range start="0" end="145"/>
</style> </style>
@ -1629,7 +1637,8 @@ Could not import John&amp;Alice_smiths_marr_cert.jpg Line 9
<note handle="_000000e4000000e4" change="1" id="N0024" type="GEDCOM import"> <note handle="_000000e4000000e4" change="1" id="N0024" type="GEDCOM import">
<text>Records not imported into FAM (family) Gramps ID F0008: <text>Records not imported into FAM (family) Gramps ID F0008:
Tag recognized but not supported Line 1005: 1 ADDR 123 Main st, Grantville, Virginia, USA</text> Tag recognized but not supported Line 1005: 1 ADDR 123 Main st, Grantville, Virginia, USA
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="183"/> <range start="0" end="183"/>
</style> </style>
@ -1653,7 +1662,8 @@ Tag recognized but not supported Line 1005:
<text>Records not imported into SOUR (source) Gramps ID S0003: <text>Records not imported into SOUR (source) Gramps ID S0003:
Tag recognized but not supported Line 1045: 1 DATA Tag recognized but not supported Line 1045: 1 DATA
Skipped subordinate line Line 1046: 2 AGNC NYC Public Library</text> Skipped subordinate line Line 1046: 2 AGNC NYC Public Library
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="252"/> <range start="0" end="252"/>
</style> </style>
@ -1669,7 +1679,8 @@ Skipped subordinate line Line 1046:
REFN ignored Line 1075: 3 REFN blah blah REFN ignored Line 1075: 3 REFN blah blah
Skipped subordinate line Line 1076: 4 TYPE who knows Skipped subordinate line Line 1076: 4 TYPE who knows
Could not import Attic_photo.jpg Line 1079: 3 OBJE</text> Could not import Attic_photo.jpg Line 1079: 3 OBJE
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="344"/> <range start="0" end="344"/>
</style> </style>
@ -1677,7 +1688,8 @@ Could not import Attic_photo.jpg Line 1079:
<note handle="_000000f6000000f6" change="1" id="N0034" type="GEDCOM import"> <note handle="_000000f6000000f6" change="1" id="N0034" type="GEDCOM import">
<text>Records not imported into Top Level: <text>Records not imported into Top Level:
Unknown tag Line 1106: 0 XXX an unknown token at level 0</text> Unknown tag Line 1106: 0 XXX an unknown token at level 0
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="152"/> <range start="0" end="152"/>
</style> </style>
@ -1685,12 +1697,13 @@ Unknown tag Line 1106:
<note handle="_000000f8000000f8" change="1" id="N0035" type="GEDCOM import"> <note handle="_000000f8000000f8" change="1" id="N0035" type="GEDCOM import">
<text>Records not imported into Top Level: <text>Records not imported into Top Level:
Unknown tag Line 1109: 1 @X1@ XXX and unknown token xref definition</text> Unknown tag Line 1109: 1 @X1@ XXX and unknown token xref definition
</text>
<style name="fontface" value="Monospace"> <style name="fontface" value="Monospace">
<range start="0" end="163"/> <range start="0" end="163"/>
</style> </style>
</note> </note>
<note handle="_000000f9000000f9" change="1477325896" id="N0036" type="General"> <note handle="_000000f9000000f9" change="1551799781" id="N0036" type="General">
<text>Objects referenced by this note were missing in a file imported on 12/25/1999 12:00:00 AM.</text> <text>Objects referenced by this note were missing in a file imported on 12/25/1999 12:00:00 AM.</text>
</note> </note>
</notes> </notes>

View File

@ -104,15 +104,6 @@ LANGUAGES = {
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
MIME2GED = {
"image/bmp" : "bmp",
"image/gif" : "gif",
"image/jpeg" : "jpeg",
"image/x-pcx" : "pcx",
"image/tiff" : "tiff",
"audio/x-wav" : "wav"
}
QUALITY_MAP = { QUALITY_MAP = {
Citation.CONF_VERY_HIGH : "3", Citation.CONF_VERY_HIGH : "3",
Citation.CONF_HIGH : "2", Citation.CONF_HIGH : "2",
@ -1467,8 +1458,7 @@ class GedcomWriter(UpdateCallback):
gramps_id = media.get_gramps_id() gramps_id = media.get_gramps_id()
self._writeln(0, '@%s@' % gramps_id, 'OBJE') self._writeln(0, '@%s@' % gramps_id, 'OBJE')
mime = media.get_mime_type() form = os.path.splitext(media.get_path())[1][1:]
form = MIME2GED.get(mime, mime)
path = media_path_full(self.dbase, media.get_path()) path = media_path_full(self.dbase, media.get_path())
self._writeln(1, 'FILE', path, limit=255) self._writeln(1, 'FILE', path, limit=255)
if form: if form:

View File

@ -94,6 +94,7 @@ import time
# from xml.parsers.expat import ParserCreate # from xml.parsers.expat import ParserCreate
from collections import defaultdict, OrderedDict from collections import defaultdict, OrderedDict
import string import string
import mimetypes
from io import StringIO, TextIOWrapper from io import StringIO, TextIOWrapper
from urllib.parse import urlparse from urllib.parse import urlparse
@ -123,7 +124,7 @@ from gramps.gen.lib import (
Surname, Tag, Url, UrlType, PlaceType, PlaceRef, PlaceName) Surname, Tag, Url, UrlType, PlaceType, PlaceRef, PlaceName)
from gramps.gen.db import DbTxn from gramps.gen.db import DbTxn
from gramps.gen.updatecallback import UpdateCallback from gramps.gen.updatecallback import UpdateCallback
from gramps.gen.mime import get_type from gramps.gen.utils.file import media_path
from gramps.gen.utils.id import create_id from gramps.gen.utils.id import create_id
from gramps.gen.utils.lds import TEMPLES from gramps.gen.utils.lds import TEMPLES
from gramps.gen.utils.unknown import make_unknown, create_explanation_note from gramps.gen.utils.unknown import make_unknown, create_explanation_note
@ -531,15 +532,6 @@ PEDIGREE_TYPES = {
'adopted': TYPE_ADOPT, 'adopted': TYPE_ADOPT,
'foster' : TYPE_FOSTER, } 'foster' : TYPE_FOSTER, }
MIME_MAP = {
'jpeg' : 'image/jpeg', 'rtf' : 'text/rtf',
'jpg' : 'image/jpeg', 'pdf' : 'application/pdf',
'mpeg' : 'video/mpeg', 'gif' : 'image/gif',
'mpg' : 'video/mpeg', 'bmp' : 'image/x-ms-bmp',
'tiff' : 'image/tiff', 'aif' : 'audio/x-aiff',
'text' : 'text/plain', 'w8bn' : 'application/msword',
'wav' : 'audio/x-wav', 'mov' : 'video/quicktime', }
FTW_BAD_PLACE = [ FTW_BAD_PLACE = [
EventType.OCCUPATION, EventType.OCCUPATION,
EventType.RELIGION, EventType.RELIGION,
@ -2728,7 +2720,6 @@ class GedcomParser(UpdateCallback):
self.attrs = list(amap.values()) self.attrs = list(amap.values())
self.gedattr = dict([key, val] for val, key in amap.items()) self.gedattr = dict([key, val] for val, key in amap.items())
self.search_paths = []
def parse_gedcom_file(self, use_trans=False): def parse_gedcom_file(self, use_trans=False):
""" """
@ -3021,6 +3012,9 @@ class GedcomParser(UpdateCallback):
# FIXME: problem possibly caused by umlaut/accented character # FIXME: problem possibly caused by umlaut/accented character
# in filename # in filename
return (0, fullname) return (0, fullname)
# strip off Windows drive letter, if present
if len(fullname) > 3 and fullname[1] == ':':
fullname = fullname[2:]
# look where we found the '.ged', using the full path in fullname # look where we found the '.ged', using the full path in fullname
other = os.path.join(altpath, fullname) other = os.path.join(altpath, fullname)
if os.path.isfile(other): if os.path.isfile(other):
@ -3029,15 +3023,15 @@ class GedcomParser(UpdateCallback):
other = os.path.join(altpath, os.path.basename(fullname)) other = os.path.join(altpath, os.path.basename(fullname))
if os.path.isfile(other): if os.path.isfile(other):
return (1, other) return (1, other)
# I don't think the following code does anything because search_paths # lets try using the base path for relative media paths
# is never initialized... other = os.path.join(media_path(self.dbase), fullname)
if len(fullname) > 3: if os.path.isfile(other):
if fullname[1] == ':': return (1, fullname)
fullname = fullname[2:] # lets try using the base path for relative media paths with base name
for path in self.search_paths: other = os.path.join(media_path(self.dbase),
other = os.path.normpath("%s/%s" % (path, fullname)) os.path.basename(fullname))
if os.path.isfile(other): if os.path.isfile(other):
return (1, other) return (1, os.path.basename(fullname))
return (0, fullname) return (0, fullname)
def __get_next_line(self): def __get_next_line(self):
@ -5366,8 +5360,9 @@ class GedcomParser(UpdateCallback):
# to allow import of references to URLs (especially for import from # 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 # geni.com), do not try to find the file if it is blatently a URL
res = urlparse(sub_state.filename) res = urlparse(sub_state.filename)
if sub_state.filename != '' and \ if sub_state.filename != '' and (res.scheme == '' or
(res.scheme == '' or res.scheme == 'file'): len(res.scheme) == 1 or
res.scheme == 'file'):
(valid, path) = self.__find_file(sub_state.filename, (valid, path) = self.__find_file(sub_state.filename,
self.dir_path) self.dir_path)
if not valid: if not valid:
@ -5384,13 +5379,19 @@ class GedcomParser(UpdateCallback):
if sub_state.title: if sub_state.title:
photo.set_description(sub_state.title) photo.set_description(sub_state.title)
else: else:
photo.set_description(path) photo.set_description(path.replace('\\', '/'))
full_path = os.path.abspath(path) full_path = os.path.abspath(path)
if os.path.isfile(full_path): # deal with mime types
photo.set_mime_type(get_type(full_path)) value = mimetypes.guess_type(full_path)
else: if value and value[0]: # found from filename
photo.set_mime_type(MIME_MAP.get(sub_state.form, photo.set_mime_type(value[0])
'unknown')) else: # get from OBJE.FILE.FORM
if '/' in sub_state.form: # already has expanded mime type
photo.set_mime_type(sub_state.form)
else:
value = mimetypes.types_map.get('.' + sub_state.form,
_('unknown'))
photo.set_mime_type(value)
if sub_state.attr: if sub_state.attr:
photo.attribute_list.append(sub_state.attr) photo.attribute_list.append(sub_state.attr)
self.dbase.add_media(photo, self.trans) self.dbase.add_media(photo, self.trans)
@ -6691,6 +6692,17 @@ class GedcomParser(UpdateCallback):
if state.media.get_path() == "": if state.media.get_path() == "":
self.__add_msg(_("Filename omitted"), line, state) self.__add_msg(_("Filename omitted"), line, state)
# deal with mime types
value = mimetypes.guess_type(state.media.get_path())
if value and value[0]: # found from filename
state.media.set_mime_type(value[0])
else: # get from OBJE.FILE.FORM
if '/' in state.form: # already has expanded mime type
state.media.set_mime_type(state.form)
else:
value = mimetypes.types_map.get('.' + state.form,
_('unknown'))
state.media.set_mime_type(value)
# Add the default reference if no source has found # Add the default reference if no source has found
self.__add_default_source(media) self.__add_default_source(media)
@ -6726,21 +6738,21 @@ class GedcomParser(UpdateCallback):
self.__skip_subordinate_levels(state.level + 1, state) self.__skip_subordinate_levels(state.level + 1, state)
return return
res = urlparse(line.data) res = urlparse(line.data)
if line.data != '' and (res.scheme == '' or res.scheme == 'file'): if line.data != '' and (res.scheme == '' or
len(res.scheme) == 1 or res.scheme == 'file'):
(file_ok, filename) = self.__find_file(line.data, self.dir_path) (file_ok, filename) = self.__find_file(line.data, self.dir_path)
if state.form != "url": if state.form != "url":
# Might not work if FORM doesn't precede FILE # Might not work if FORM doesn't precede FILE
if not file_ok: if not file_ok:
self.__add_msg(_("Could not import %s") % filename, line, self.__add_msg(_("Could not import %s") % line.data, line,
state) state)
path = filename path = filename
else: else:
path = line.data path = line.data
state.media.set_path(path) state.media.set_path(path)
state.media.set_mime_type(get_type(path))
if not state.media.get_description(): if not state.media.get_description():
state.media.set_description(path) state.media.set_description(path.replace('\\', '/'))
def __obje_title(self, line, state): def __obje_title(self, line, state):
""" """