Don't reimport a file that has already been imported
svn: r556
This commit is contained in:
parent
d0aed7c56a
commit
4e7d469701
@ -130,25 +130,37 @@ class ImageSelect:
|
|||||||
GnomeErrorDialog(_("That is not a valid file name."));
|
GnomeErrorDialog(_("That is not a valid file name."));
|
||||||
return
|
return
|
||||||
|
|
||||||
type = utils.get_mime_type(filename)
|
already_imported = None
|
||||||
mobj = Photo()
|
for o in self.db.getObjectMap().values():
|
||||||
if description == "":
|
if o.getPath() == filename:
|
||||||
description = os.path.basename(filename)
|
already_imported = o
|
||||||
mobj.setDescription(description)
|
break
|
||||||
mobj.setMimeType(type)
|
|
||||||
self.savephoto(mobj)
|
|
||||||
|
|
||||||
if type[0:5] == "image":
|
if (already_imported):
|
||||||
if self.external.get_active() == 0:
|
oref = ObjectRef()
|
||||||
name = RelImage.import_media_object(filename,self.path,mobj.getId())
|
oref.setReference(already_imported)
|
||||||
|
self.dataobj.addPhoto(oref)
|
||||||
|
self.add_thumbnail(oref)
|
||||||
else:
|
else:
|
||||||
if self.external.get_active() == 1:
|
type = utils.get_mime_type(filename)
|
||||||
name = filename
|
mobj = Photo()
|
||||||
RelImage.mk_thumb(filename,self.path,mobj.getId())
|
if description == "":
|
||||||
else:
|
description = os.path.basename(filename)
|
||||||
name = RelImage.import_media_object(filename,self.path,mobj.getId())
|
mobj.setDescription(description)
|
||||||
|
mobj.setMimeType(type)
|
||||||
|
self.savephoto(mobj)
|
||||||
|
|
||||||
mobj.setPath(name)
|
if type[0:5] == "image":
|
||||||
|
if self.external.get_active() == 0:
|
||||||
|
name = RelImage.import_media_object(filename,self.path,mobj.getId())
|
||||||
|
else:
|
||||||
|
if self.external.get_active() == 1:
|
||||||
|
name = filename
|
||||||
|
RelImage.mk_thumb(filename,self.path,mobj.getId())
|
||||||
|
else:
|
||||||
|
name = RelImage.import_media_object(filename,self.path,mobj.getId())
|
||||||
|
|
||||||
|
mobj.setPath(name)
|
||||||
|
|
||||||
utils.modified()
|
utils.modified()
|
||||||
utils.destroy_passed_object(obj)
|
utils.destroy_passed_object(obj)
|
||||||
@ -211,8 +223,6 @@ class Gallery(ImageSelect):
|
|||||||
oref = ObjectRef()
|
oref = ObjectRef()
|
||||||
oref.setReference(photo)
|
oref.setReference(photo)
|
||||||
self.dataobj.addPhoto(oref)
|
self.dataobj.addPhoto(oref)
|
||||||
dest = "%s/.thumb/%s.jpg" % (self.db.getSavePath(),photo.getId())
|
|
||||||
RelImage.mk_thumb(photo.getPath(),dest,const.thumbScale)
|
|
||||||
self.add_thumbnail(oref)
|
self.add_thumbnail(oref)
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
@ -55,17 +55,17 @@ class PlaceView:
|
|||||||
self.place_list.set_column_visibility(10,0)
|
self.place_list.set_column_visibility(10,0)
|
||||||
self.place_list.set_column_visibility(11,0)
|
self.place_list.set_column_visibility(11,0)
|
||||||
self.place_list.set_column_visibility(12,0)
|
self.place_list.set_column_visibility(12,0)
|
||||||
self.place_list.set_column_visibility(13,0)
|
|
||||||
self.place_list.connect('button-press-event',self.on_button_press_event)
|
self.place_list.connect('button-press-event',self.on_button_press_event)
|
||||||
self.place_list.connect('select-row',self.select_row)
|
self.place_list.connect('select-row',self.select_row)
|
||||||
self.active = None
|
self.active = None
|
||||||
|
self.sort_map = [7,1,8,9,10,11,12]
|
||||||
|
|
||||||
# Restore the previous sort column
|
# Restore the previous sort column
|
||||||
|
|
||||||
self.sort_col,self.sort_dir = Config.get_sort_cols("place",0,GTK.SORT_ASCENDING)
|
self.sort_col,self.sort_dir = Config.get_sort_cols("place",0,GTK.SORT_ASCENDING)
|
||||||
self.place_list.set_sort_column(self.sort_col+7)
|
|
||||||
self.place_list.set_sort_type(self.sort_dir)
|
|
||||||
self.set_arrow(self.sort_col)
|
self.set_arrow(self.sort_col)
|
||||||
|
self.place_list.set_sort_column(self.sort_map[self.sort_col])
|
||||||
|
self.place_list.set_sort_type(self.sort_dir)
|
||||||
|
|
||||||
def load_places(self):
|
def load_places(self):
|
||||||
if len(self.place_list.selection) == 0:
|
if len(self.place_list.selection) == 0:
|
||||||
@ -92,7 +92,7 @@ class PlaceView:
|
|||||||
parish = mloc.get_parish()
|
parish = mloc.get_parish()
|
||||||
country = mloc.get_country()
|
country = mloc.get_country()
|
||||||
self.place_list.append([title,id,parish,city,county,state,country,
|
self.place_list.append([title,id,parish,city,county,state,country,
|
||||||
u(title), u(id), u(parish), u(city),
|
u(title), u(parish), u(city),
|
||||||
u(county),u(state), u(country)])
|
u(county),u(state), u(country)])
|
||||||
self.place_list.set_row_data(index,src)
|
self.place_list.set_row_data(index,src)
|
||||||
index = index + 1
|
index = index + 1
|
||||||
@ -159,7 +159,7 @@ class PlaceView:
|
|||||||
self.sort_col = column
|
self.sort_col = column
|
||||||
self.set_arrow(column)
|
self.set_arrow(column)
|
||||||
self.place_list.set_sort_type(self.sort_direct)
|
self.place_list.set_sort_type(self.sort_direct)
|
||||||
self.place_list.set_sort_column(self.sort_col + 7)
|
self.place_list.set_sort_column(self.sort_map[self.sort_col])
|
||||||
Config.save_sort_cols("place",self.sort_col,self.sort_direct)
|
Config.save_sort_cols("place",self.sort_col,self.sort_direct)
|
||||||
|
|
||||||
self.place_list.sort()
|
self.place_list.sort()
|
||||||
|
@ -80,6 +80,7 @@ def import_media_object(filename,path,base):
|
|||||||
try:
|
try:
|
||||||
path = "%s/%s" % (thumb,base)
|
path = "%s/%s" % (thumb,base)
|
||||||
|
|
||||||
|
print filename,path,const.thumbScale
|
||||||
mk_thumb(filename,path,const.thumbScale)
|
mk_thumb(filename,path,const.thumbScale)
|
||||||
shutil.copy(filename,name)
|
shutil.copy(filename,name)
|
||||||
except:
|
except:
|
||||||
|
@ -69,16 +69,20 @@ class SourceView:
|
|||||||
self.sort_arrow = [self.title_arrow, self.id_arrow, self.author_arrow]
|
self.sort_arrow = [self.title_arrow, self.id_arrow, self.author_arrow]
|
||||||
self.source_list.connect('click-column',self.click_column)
|
self.source_list.connect('click-column',self.click_column)
|
||||||
|
|
||||||
|
|
||||||
self.sort_col,self.sort_dir = Config.get_sort_cols("source",3,GTK.SORT_ASCENDING)
|
self.sort_col,self.sort_dir = Config.get_sort_cols("source",3,GTK.SORT_ASCENDING)
|
||||||
|
if self.sort_col >= len(self.sort_arrow):
|
||||||
|
self.sort_col = 0
|
||||||
|
|
||||||
self.source_list.set_sort_type(self.sort_dir)
|
self.source_list.set_sort_type(self.sort_dir)
|
||||||
self.source_list.set_sort_column(self.sort_map[self.sort_col])
|
self.source_list.set_sort_column(self.sort_map[self.sort_col])
|
||||||
self.set_arrow(self.sort_col)
|
self.set_arrow(self.sort_col)
|
||||||
|
|
||||||
def set_arrow(self,column):
|
def set_arrow(self,column):
|
||||||
|
|
||||||
for a in self.sort_arrow:
|
for a in self.sort_arrow:
|
||||||
a.hide()
|
a.hide()
|
||||||
|
|
||||||
|
print column
|
||||||
a = self.sort_arrow[column]
|
a = self.sort_arrow[column]
|
||||||
a.show()
|
a.show()
|
||||||
if self.sort_dir == GTK.SORT_ASCENDING:
|
if self.sort_dir == GTK.SORT_ASCENDING:
|
||||||
|
@ -1275,6 +1275,45 @@
|
|||||||
<ypad>0</ypad>
|
<ypad>0</ypad>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
|
<widget>
|
||||||
|
<class>GtkScrolledWindow</class>
|
||||||
|
<name>scrolledwindow28</name>
|
||||||
|
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
|
||||||
|
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
|
||||||
|
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
|
||||||
|
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
|
||||||
|
|
||||||
|
<widget>
|
||||||
|
<class>GnomeCanvas</class>
|
||||||
|
<name>canvas1</name>
|
||||||
|
<can_focus>True</can_focus>
|
||||||
|
<signal>
|
||||||
|
<name>event</name>
|
||||||
|
<handler>on_canvas1_event</handler>
|
||||||
|
<last_modification_time>Sun, 02 Sep 2001 21:58:31 GMT</last_modification_time>
|
||||||
|
</signal>
|
||||||
|
<anti_aliased>False</anti_aliased>
|
||||||
|
<scroll_x1>0</scroll_x1>
|
||||||
|
<scroll_y1>0</scroll_y1>
|
||||||
|
<scroll_x2>100</scroll_x2>
|
||||||
|
<scroll_y2>100</scroll_y2>
|
||||||
|
<pixels_per_unit>1</pixels_per_unit>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
|
||||||
|
<widget>
|
||||||
|
<class>GtkLabel</class>
|
||||||
|
<child_name>Notebook:tab</child_name>
|
||||||
|
<name>label237</name>
|
||||||
|
<label>Pedigree</label>
|
||||||
|
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||||
|
<wrap>False</wrap>
|
||||||
|
<xalign>0.5</xalign>
|
||||||
|
<yalign>0.5</yalign>
|
||||||
|
<xpad>0</xpad>
|
||||||
|
<ypad>0</ypad>
|
||||||
|
</widget>
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkVBox</class>
|
<class>GtkVBox</class>
|
||||||
<name>vbox2</name>
|
<name>vbox2</name>
|
||||||
@ -2306,45 +2345,6 @@
|
|||||||
<ypad>0</ypad>
|
<ypad>0</ypad>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget>
|
|
||||||
<class>GtkScrolledWindow</class>
|
|
||||||
<name>scrolledwindow28</name>
|
|
||||||
<hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy>
|
|
||||||
<vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy>
|
|
||||||
<hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy>
|
|
||||||
<vupdate_policy>GTK_UPDATE_CONTINUOUS</vupdate_policy>
|
|
||||||
|
|
||||||
<widget>
|
|
||||||
<class>GnomeCanvas</class>
|
|
||||||
<name>canvas1</name>
|
|
||||||
<can_focus>True</can_focus>
|
|
||||||
<signal>
|
|
||||||
<name>event</name>
|
|
||||||
<handler>on_canvas1_event</handler>
|
|
||||||
<last_modification_time>Sun, 02 Sep 2001 21:58:31 GMT</last_modification_time>
|
|
||||||
</signal>
|
|
||||||
<anti_aliased>False</anti_aliased>
|
|
||||||
<scroll_x1>0</scroll_x1>
|
|
||||||
<scroll_y1>0</scroll_y1>
|
|
||||||
<scroll_x2>100</scroll_x2>
|
|
||||||
<scroll_y2>100</scroll_y2>
|
|
||||||
<pixels_per_unit>1</pixels_per_unit>
|
|
||||||
</widget>
|
|
||||||
</widget>
|
|
||||||
|
|
||||||
<widget>
|
|
||||||
<class>GtkLabel</class>
|
|
||||||
<child_name>Notebook:tab</child_name>
|
|
||||||
<name>label237</name>
|
|
||||||
<label>Pedigree</label>
|
|
||||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
|
||||||
<wrap>False</wrap>
|
|
||||||
<xalign>0.5</xalign>
|
|
||||||
<yalign>0.5</yalign>
|
|
||||||
<xpad>0</xpad>
|
|
||||||
<ypad>0</ypad>
|
|
||||||
</widget>
|
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkVBox</class>
|
<class>GtkVBox</class>
|
||||||
<name>vbox33</name>
|
<name>vbox33</name>
|
||||||
@ -2379,7 +2379,7 @@
|
|||||||
<last_modification_time>Thu, 31 May 2001 17:22:45 GMT</last_modification_time>
|
<last_modification_time>Thu, 31 May 2001 17:22:45 GMT</last_modification_time>
|
||||||
</signal>
|
</signal>
|
||||||
<columns>5</columns>
|
<columns>5</columns>
|
||||||
<column_widths>293,60,344,5,5</column_widths>
|
<column_widths>293,61,306,5,5</column_widths>
|
||||||
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
|
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
|
||||||
<show_titles>True</show_titles>
|
<show_titles>True</show_titles>
|
||||||
<shadow_type>GTK_SHADOW_IN</shadow_type>
|
<shadow_type>GTK_SHADOW_IN</shadow_type>
|
||||||
@ -2683,8 +2683,8 @@
|
|||||||
<handler>on_place_list_click_column</handler>
|
<handler>on_place_list_click_column</handler>
|
||||||
<last_modification_time>Tue, 30 Oct 2001 18:18:53 GMT</last_modification_time>
|
<last_modification_time>Tue, 30 Oct 2001 18:18:53 GMT</last_modification_time>
|
||||||
</signal>
|
</signal>
|
||||||
<columns>14</columns>
|
<columns>13</columns>
|
||||||
<column_widths>222,47,102,88,77,80,5,5,5,5,5,5,5,5</column_widths>
|
<column_widths>213,47,107,88,77,80,29,1,1,1,1,1,1</column_widths>
|
||||||
<selection_mode>GTK_SELECTION_EXTENDED</selection_mode>
|
<selection_mode>GTK_SELECTION_EXTENDED</selection_mode>
|
||||||
<show_titles>True</show_titles>
|
<show_titles>True</show_titles>
|
||||||
<shadow_type>GTK_SHADOW_IN</shadow_type>
|
<shadow_type>GTK_SHADOW_IN</shadow_type>
|
||||||
@ -3087,19 +3087,6 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
<widget>
|
|
||||||
<class>GtkLabel</class>
|
|
||||||
<child_name>CList:title</child_name>
|
|
||||||
<name>label276</name>
|
|
||||||
<label></label>
|
|
||||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
|
||||||
<wrap>False</wrap>
|
|
||||||
<xalign>0.5</xalign>
|
|
||||||
<yalign>0.5</yalign>
|
|
||||||
<xpad>0</xpad>
|
|
||||||
<ypad>0</ypad>
|
|
||||||
</widget>
|
|
||||||
|
|
||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GtkLabel</class>
|
||||||
<child_name>CList:title</child_name>
|
<child_name>CList:title</child_name>
|
||||||
@ -3628,7 +3615,7 @@
|
|||||||
<widget>
|
<widget>
|
||||||
<class>GtkLabel</class>
|
<class>GtkLabel</class>
|
||||||
<name>label266</name>
|
<name>label266</name>
|
||||||
<label>Description</label>
|
<label>Title</label>
|
||||||
<justify>GTK_JUSTIFY_CENTER</justify>
|
<justify>GTK_JUSTIFY_CENTER</justify>
|
||||||
<wrap>False</wrap>
|
<wrap>False</wrap>
|
||||||
<xalign>1</xalign>
|
<xalign>1</xalign>
|
||||||
|
@ -184,6 +184,12 @@ class GedcomParser:
|
|||||||
self.error_count = 0
|
self.error_count = 0
|
||||||
self.error_text_obj.set_point(0)
|
self.error_text_obj.set_point(0)
|
||||||
self.error_text_obj.set_word_wrap(0)
|
self.error_text_obj.set_word_wrap(0)
|
||||||
|
|
||||||
|
map = const.personalConstantAttributes
|
||||||
|
self.attrs = map.values()
|
||||||
|
self.gedattr = {}
|
||||||
|
for val in map.keys():
|
||||||
|
self.gedattr[map[val]] = val
|
||||||
|
|
||||||
self.update(self.file_obj,file)
|
self.update(self.file_obj,file)
|
||||||
self.code = 0
|
self.code = 0
|
||||||
@ -563,23 +569,33 @@ class GedcomParser:
|
|||||||
elif matches[1] == "EVEN":
|
elif matches[1] == "EVEN":
|
||||||
event = Event()
|
event = Event()
|
||||||
self.parse_person_event(event,2)
|
self.parse_person_event(event,2)
|
||||||
if string.strip(event.getName()) == "SSN":
|
n = string.strip(event.getName())
|
||||||
|
if n in self.attrs:
|
||||||
attr = Attribute()
|
attr = Attribute()
|
||||||
attr.setType("Social Security Number")
|
attr.setType(self.gedattr[n])
|
||||||
attr.setValue(event.getDescription())
|
attr.setValue(event.getDescription())
|
||||||
self.person.addAttribute(attr)
|
self.person.addAttribute(attr)
|
||||||
else:
|
else:
|
||||||
self.person.addEvent(event)
|
self.person.addEvent(event)
|
||||||
else:
|
else:
|
||||||
event = Event()
|
event = Event()
|
||||||
try:
|
n = string.strip(matches[1])
|
||||||
event.setName(ged2gramps[matches[1]])
|
if ged2gramps.has_key(n):
|
||||||
except:
|
event.setName(ged2gramps[n])
|
||||||
|
elif self.gedattr.has_key(n):
|
||||||
|
attr = Attribute()
|
||||||
|
attr.setType(self.gedattr[n])
|
||||||
|
attr.setValue(event.getDescription())
|
||||||
|
self.person.addAttribute(attr)
|
||||||
|
self.parse_person_attr(attr,2)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
event.setName(matches[1])
|
event.setName(matches[1])
|
||||||
|
|
||||||
|
self.parse_person_event(event,2)
|
||||||
if matches[2] != None:
|
if matches[2] != None:
|
||||||
event.setDescription(matches[2])
|
event.setDescription(matches[2])
|
||||||
self.person.addEvent(event)
|
self.person.addEvent(event)
|
||||||
self.parse_person_event(event,2)
|
|
||||||
|
|
||||||
def parse_optional_note(self,level):
|
def parse_optional_note(self,level):
|
||||||
note = ""
|
note = ""
|
||||||
@ -882,6 +898,54 @@ class GedcomParser:
|
|||||||
else:
|
else:
|
||||||
self.barf(level+1)
|
self.barf(level+1)
|
||||||
|
|
||||||
|
def parse_person_attr(self,attr,level):
|
||||||
|
note = ""
|
||||||
|
while 1:
|
||||||
|
matches = self.get_next()
|
||||||
|
if int(matches[0]) < level:
|
||||||
|
self.backup()
|
||||||
|
break
|
||||||
|
elif matches[1] == "TYPE":
|
||||||
|
if attr.getType() == "":
|
||||||
|
if ged2gramps.has_key(matches[2]):
|
||||||
|
name = ged2gramps[matches[2]]
|
||||||
|
else:
|
||||||
|
name = matches[2]
|
||||||
|
attr.setName(name)
|
||||||
|
elif matches[1] == ["CAUS", "DATE","TIME","ADDR","AGE","AGNC","STAT","TEMP","OBJE"]:
|
||||||
|
self.ignore_sub_junk(level+1)
|
||||||
|
elif matches[1] == "SOUR":
|
||||||
|
source_ref = SourceRef()
|
||||||
|
if matches[2] and matches[2][0] != "@":
|
||||||
|
self.localref = self.localref + 1
|
||||||
|
ref = "gsr%d" % self.localref
|
||||||
|
s = self.db.findSource(ref,self.smap)
|
||||||
|
source_ref.setBase(s)
|
||||||
|
s.setTitle('Imported Source #%d' % self.localref)
|
||||||
|
s.setNote(matches[2] + self.parse_continue_data(1))
|
||||||
|
self.ignore_sub_junk(2)
|
||||||
|
else:
|
||||||
|
source_ref.setBase(self.db.findSource(matches[2],self.smap))
|
||||||
|
self.parse_source_reference(source_ref,level+1)
|
||||||
|
attr.addSourceRef(source_ref)
|
||||||
|
elif matches[1] == "PLAC":
|
||||||
|
val = matches[2]
|
||||||
|
if attr.getValue() == "":
|
||||||
|
attr.setValue(val)
|
||||||
|
self.ignore_sub_junk(level+1)
|
||||||
|
elif matches[1] == "NOTE":
|
||||||
|
info = matches[2] + self.parse_continue_data(level+1)
|
||||||
|
if note == "":
|
||||||
|
note = info
|
||||||
|
else:
|
||||||
|
note = "\n%s" % info
|
||||||
|
elif matches[1] == "CONC":
|
||||||
|
attr.setValue( "%s %s" % (attr.getValue(), matches[2]))
|
||||||
|
elif matches[1] == "CONT":
|
||||||
|
attr.setValue("%s\n%s" % (attr.getValue(),matches[2]))
|
||||||
|
else:
|
||||||
|
self.barf(level+1)
|
||||||
|
|
||||||
def parse_family_event(self,event,level):
|
def parse_family_event(self,event,level):
|
||||||
global ged2fam
|
global ged2fam
|
||||||
global ged2gramps
|
global ged2gramps
|
||||||
|
Loading…
Reference in New Issue
Block a user