* src/Marriage.py: pychecker fixes

* src/RelLib.py: pychecker fixes
* src/SelectChild.py: pychecker fixes
* src/SelectObject: pychecker fixes
* src/SourceView.py: pychecker fixes
* src/Sources.py: pychecker fixes
* src/StyleEditor.py: pychecker fixes
* src/TarFile.py: pychecker fixes
* src/TipOfDay.py: pychecker fixes
* src/Utils.py: pychecker fixes
* src/WriteXML.py: pychecker fixes


svn: r3480
This commit is contained in:
Don Allingham 2004-08-22 23:16:57 +00:00
parent b9c493f2af
commit f8b1715b41
12 changed files with 238 additions and 232 deletions

View File

@ -1,3 +1,16 @@
2004-08-22 Don Allingham <dallingham@users.sourceforge.net>
* src/Marriage.py: pychecker fixes
* src/RelLib.py: pychecker fixes
* src/SelectChild.py: pychecker fixes
* src/SelectObject: pychecker fixes
* src/SourceView.py: pychecker fixes
* src/Sources.py: pychecker fixes
* src/StyleEditor.py: pychecker fixes
* src/TarFile.py: pychecker fixes
* src/TipOfDay.py: pychecker fixes
* src/Utils.py: pychecker fixes
* src/WriteXML.py: pychecker fixes
2004-08-23 Tim Waugh <twaugh@redhat.com>
* src/WriteGedcom.py (GedcomWriter.write_families): Write families

View File

@ -215,17 +215,17 @@ class Marriage:
place_list.sort()
AutoComp.fill_combo(self.lds_place, place_list)
ord = self.family.get_lds_sealing()
if ord:
if ord.get_place_handle():
self.lds_place.child.set_text(ord.get_place_handle().get_title())
self.lds_date.set_text(ord.get_date())
if ord.get_temple() != "":
name = const.lds_temple_to_abrev[ord.get_temple()]
lds_ord = self.family.get_lds_sealing()
if lds_ord:
if lds_ord.get_place_handle():
self.lds_place.child.set_text(lds_ord.get_place_handle().get_title())
self.lds_date.set_text(lds_ord.get_date())
if lds_ord.get_temple() != "":
name = const.lds_temple_to_abrev[lds_ord.get_temple()]
else:
name = ""
self.lds_temple.child.set_text(name)
self.seal_stat = ord.get_status()
self.seal_stat = lds_ord.get_status()
else:
self.lds_temple.child.set_text("")
self.lds_place.child.set_text("")
@ -236,7 +236,7 @@ class Marriage:
self.build_seal_menu()
if ord:
if lds_ord:
Utils.bold_label(self.lds_label)
else:
Utils.unbold_label(self.lds_label)
@ -344,52 +344,52 @@ class Marriage:
self.seal_stat = obj.get_data("val")
def lds_src_clicked(self,obj):
ord = self.family.get_lds_sealing()
if ord == None:
ord = RelLib.LdsOrd()
self.family.set_lds_sealing(ord)
Sources.SourceSelector(ord.get_source_references(),self,self.window)
lds_ord = self.family.get_lds_sealing()
if lds_ord == None:
lds_ord = RelLib.LdsOrd()
self.family.set_lds_sealing(lds_ord)
Sources.SourceSelector(lds_ord.get_source_references(),self,self.window)
def lds_note_clicked(self,obj):
import NoteEdit
ord = self.family.get_lds_sealing()
if ord == None:
ord = RelLib.LdsOrd()
self.family.set_lds_sealing(ord)
NoteEdit.NoteEditor(ord,self,self.window)
lds_ord = self.family.get_lds_sealing()
if lds_ord == None:
lds_ord = RelLib.LdsOrd()
self.family.set_lds_sealing(lds_ord)
NoteEdit.NoteEditor(lds_ord,self,self.window)
def on_up_clicked(self,obj):
model,iter = self.etree.get_selected()
if not iter:
model,node = self.etree.get_selected()
if not node:
return
row = self.etree.get_row(iter)
row = self.etree.get_row(node)
if row != 0:
self.etree.select_row(row-1)
def on_down_clicked(self,obj):
model,iter = self.etree.get_selected()
if not iter:
model,node = self.etree.get_selected()
if not node:
return
row = self.etree.get_row(iter)
row = self.etree.get_row(node)
self.etree.select_row(row+1)
def on_attr_up_clicked(self,obj):
model,iter = self.atree.get_selected()
if not iter:
model,node = self.atree.get_selected()
if not node:
return
row = self.atree.get_row(iter)
row = self.atree.get_row(node)
if row != 0:
self.atree.select_row(row-1)
def on_attr_down_clicked(self,obj):
model,iter = self.atree.get_selected()
if not iter:
model,node = self.atree.get_selected()
if not node:
return
row = self.atree.get_row(iter)
row = self.atree.get_row(node)
self.atree.select_row(row+1)
def ev_dest_drag_data_received(self,widget,context,x,y,selection_data,info,time):
@ -467,8 +467,8 @@ class Marriage:
self.amap = {}
for attr in self.alist:
d = [const.display_fattr(attr.get_type()),attr.get_value()]
iter = self.atree.add(d,attr)
self.amap[str(attr)] = iter
node = self.atree.add(d,attr)
self.amap[str(attr)] = node
if self.alist:
self.atree.select_row(0)
Utils.bold_label(self.attr_label)
@ -488,9 +488,9 @@ class Marriage:
place_name = self.db.get_place_from_handle(place_handle).get_title()
else:
place_name = ""
iter = self.etree.add([const.display_fevent(event.get_name()),
node = self.etree.add([const.display_fevent(event.get_name()),
event.get_quote_date(),place_name],event)
self.emap[str(event)] = iter
self.emap[str(event)] = node
if self.elist:
self.etree.select_row(0)
Utils.bold_label(self.events_label)
@ -533,17 +533,17 @@ class Marriage:
place = self.get_place(0)
ord = self.family.get_lds_sealing()
if not ord:
lds_ord = self.family.get_lds_sealing()
if not lds_ord:
if date or temple or place or self.seal_stat:
changed = 1
else:
d = Date.Date()
d.set(date)
if Date.compare_dates(d,ord.get_date_object()) != 0 or \
ord.get_temple() != temple or \
(place and ord.get_place_handle() != place.get_handle()) or \
ord.get_status() != self.seal_stat:
if Date.compare_dates(d,lds_ord.get_date_object()) != 0 or \
lds_ord.get_temple() != temple or \
(place and lds_ord.get_place_handle() != place.get_handle()) or \
lds_ord.get_status() != self.seal_stat:
changed = 1
return changed
@ -610,26 +610,26 @@ class Marriage:
temple = ""
place = self.get_place(1,trans)
ord = self.family.get_lds_sealing()
if not ord:
lds_ord = self.family.get_lds_sealing()
if not lds_ord:
if date or temple or place or self.seal_stat:
ord = RelLib.LdsOrd()
ord.set_date(date)
ord.set_temple(temple)
ord.set_status(self.seal_stat)
ord.set_place_handle(place)
self.family.set_lds_sealing(ord)
lds_ord = RelLib.LdsOrd()
lds_ord.set_date(date)
lds_ord.set_temple(temple)
lds_ord.set_status(self.seal_stat)
lds_ord.set_place_handle(place)
self.family.set_lds_sealing(lds_ord)
else:
d = Date.Date()
d.set(date)
if Date.compare_dates(d,ord.get_date_object()) != 0:
ord.set_date_object(d)
if ord.get_temple() != temple:
ord.set_temple(temple)
if ord.get_status() != self.seal_stat:
ord.set_status(self.seal_stat)
if ord.get_place_handle() != place.get_handle():
ord.set_place_handle(place.get_handle())
if Date.compare_dates(d,lds_ord.get_date_object()) != 0:
lds_ord.set_date_object(d)
if lds_ord.get_temple() != temple:
lds_ord.set_temple(temple)
if lds_ord.get_status() != self.seal_stat:
lds_ord.set_status(self.seal_stat)
if lds_ord.get_place_handle() != place.get_handle():
lds_ord.set_place_handle(place.get_handle())
if self.lists_changed:
self.family.set_source_reference_list(self.srcreflist)
@ -659,10 +659,10 @@ class Marriage:
def on_event_update_clicked(self,obj):
import EventEdit
model,iter = self.etree.get_selected()
if not iter:
model,node = self.etree.get_selected()
if not node:
return
event = self.etree.get_object(iter)
event = self.etree.get_object(node)
name = Utils.family_name(self.family,self.db)
EventEdit.EventEditor(self,name,const.marriageEvents,
const.family_events,event,
@ -675,10 +675,10 @@ class Marriage:
def on_select_row(self,obj):
model,iter = self.etree.get_selected()
if not iter:
model,node = self.etree.get_selected()
if not node:
return
event = self.etree.get_object(iter)
event = self.etree.get_object(node)
self.date_field.set_text(event.get_date())
place_handle = event.get_place_handle()
@ -701,10 +701,10 @@ class Marriage:
self.descr_field.set_text(event.get_description())
def on_attr_list_select_row(self,obj):
model,iter = self.atree.get_selected()
if not iter:
model,node = self.atree.get_selected()
if not node:
return
attr = self.atree.get_object(iter)
attr = self.atree.get_object(node)
self.attr_type.set_label(const.display_fattr(attr.get_type()))
self.attr_value.set_text(attr.get_value())
@ -720,11 +720,11 @@ class Marriage:
def on_update_attr_clicked(self,obj):
import AttrEdit
model,iter = self.atree.get_selected()
if not iter:
model,node = self.atree.get_selected()
if not node:
return
attr = self.atree.get_object(iter)
attr = self.atree.get_object(node)
father_handle = self.family.get_father_handle()
mother_handle = self.family.get_mother_handle()

View File

@ -529,7 +529,7 @@ class Person(PrimaryObject,SourceNote):
def probably_alive(self,db):
"""Returns true if the person may be alive."""
if self.death_handle:
return 0
return False
if self.birth_handle:
birth = db.get_event_from_handle(self.birth_handle)
if birth.get_date() != "":
@ -549,25 +549,23 @@ class Person(PrimaryObject,SourceNote):
if child.birth_handle:
child_birth = db.get_event_from_handle(child.birth_handle)
if child_birth.get_date() != "":
d = SingleDate (child_birth.get_date_object().
get_start_date())
d = SingleDate (child_birth.get_date_object().get_start_date())
d.set_year (d.get_year() - years)
if not not_too_old (d):
return 1
return True
if child.death_handle:
child_death = db.get_event_from_handle(child.death_handle)
if child_death.get_date() != "":
d = SingleDate (child_death.get_date_object().
get_start_date())
d = SingleDate (child_death.get_date_object().get_start_date())
if not not_too_old (d):
return 1
return True
if descendants_too_old (child, years + min_generation):
return 1
return True
if descendants_too_old (self, min_generation):
return 0
return False
# What about their parents?
def parents_too_old (person, age_difference):
@ -582,12 +580,10 @@ class Person(PrimaryObject,SourceNote):
if parent.birth_handle:
parent_birth = db.get_event_from_handle(parent.birth_handle)
if parent_birth.get_date():
d = SingleDate (parent_birth.get_date_object().
get_start_date())
d.set_year (d.get_year() + max_generation +
age_difference)
d = SingleDate (parent_birth.get_date_object().get_start_date())
d.set_year (d.get_year() + max_generation + age_difference)
if not not_too_old (d):
return 1
return True
if parent.death_handle:
parent_death = db.get_event_from_handle(parent.death_handle)
@ -596,43 +592,40 @@ class Person(PrimaryObject,SourceNote):
get_start_date())
d.set_year (d.get_year() + age_difference)
if not not_too_old (d):
return 1
return True
if parents_too_old (self, 0):
return 0
return False
# As a last resort, trying seeing if their spouse's age gives
# any clue.
for family_handle in self.get_family_handle_list():
family = db.get_family_from_handle(family_handle)
for spouse_id in [family.get_father_handle(), family.get_mother_handle()]:
if not spouse_id:
continue
if spouse_id == self.handle:
if not spouse_id or spouse_id == self.handle:
continue
spouse = db.get_person_from_handle(spouse_id)
if spouse.birth_handle:
spouse_birth = db.get_event_from_handle(spouse.birth_handle)
sp_birth_handle = spouse.get_birth_handle()
sp_death_handle = spouse.get_death_handle()
if sp_birth_handle:
spouse_birth = db.find_event_from_handle(sp_birth_handle)
if spouse_birth.get_date() != "":
d = SingleDate (spouse_birth.get_date_object().
get_start_date())
d = SingleDate (spouse_birth.get_date_object().get_start_date())
d.set_year (d.get_year() + max_age_difference)
if not not_too_old (d):
return 0
return False
if spouse.death_handle:
spouse_death = db.get_event_from_handle(spouse.death_handle)
if sp_death_handle:
spouse_death = db.find_event_from_handle(sp_death_handle)
if spouse_death.get_date() != "":
d = SingleDate (spouse_death.get_date_object().
get_start_date())
d = SingleDate (spouse_birth.get_date_object().get_start_date())
d.set_year (d.get_year() - min_generation)
if not not_too_old (d):
return 0
return False
if parents_too_old (spouse, max_age_difference):
return 0
return 1
return False
return True
class Family(PrimaryObject,SourceNote):
"""

View File

@ -241,27 +241,27 @@ class SelectChild:
person_list.append(person.get_handle())
iter = None
node = None
for idval in person_list:
dinfo = self.db.get_person_from_handle(idval).get_display_info()
rdata = [dinfo[0],dinfo[1],dinfo[3],dinfo[5],dinfo[6]]
new_iter = self.refmodel.add(rdata)
new_node = self.refmodel.add(rdata)
names = dinfo[0].split(',')
if len(names):
ln = names[0].upper()
if self.default_name and ln == self.default_name and not iter:
iter = new_iter
if self.default_name and ln == self.default_name and not node:
node = new_node
self.refmodel.connect_model()
if iter:
self.refmodel.selection.select_iter(iter)
path = self.refmodel.model.get_path(iter)
if node:
self.refmodel.selection.select_iter(node)
path = self.refmodel.model.get_path(node)
col = self.add_child.get_column(0)
self.add_child.scroll_to_cell(path,col,1,0.5,0.0)
def select_function(self,store,path,iter,id_list):
id_list.append(self.refmodel.get_value(iter,PeopleModel.COLUMN_INT_ID))
def select_function(self,store,path,node,id_list):
id_list.append(self.refmodel.get_value(node,PeopleModel.COLUMN_INT_ID))
def get_selected_ids(self):
mlist = []

View File

@ -99,28 +99,28 @@ class SelectObject:
self.object_model.new_model()
for key in self.db.get_media_object_handles():
object = self.db.get_object_from_handle(key)
title = object.get_description()
the_id = object.get_handle()
the_type = Utils.get_mime_description(object.get_mime_type())
path = object.get_path()
self.object_model.add([title,the_id,the_type,path],key)
obj = self.db.get_object_from_handle(key)
title = obj.get_description()
handle = obj.get_handle()
the_type = Utils.get_mime_description(obj.get_mime_type())
path = obj.get_path()
self.object_model.add([title,handle,the_type,path],key)
self.object_model.connect_model()
def on_select_row(self,obj):
fexists = 1
store,iter = self.object_model.get_selected()
if not iter:
store,node = self.object_model.get_selected()
if not node:
return
data = self.object_model.get_data(iter,range(self.ncols))
the_id = data[4]
object = self.db.get_object_from_handle(the_id)
the_type = Utils.get_mime_description(object.get_mime_type())
path = object.get_path()
data = self.object_model.get_data(node,range(self.ncols))
handle = data[4]
obj = self.db.get_object_from_handle(handle)
the_type = Utils.get_mime_description(obj.get_mime_type())
path = obj.get_path()
thumb_path = Utils.thumb_path(self.db.get_save_path(),object)
thumb_path = Utils.thumb_path(self.db.get_save_path(),obj)
pexists = os.path.exists(path)
if pexists and os.path.exists(thumb_path):
self.preview.set_from_pixbuf(gtk.gdk.pixbuf_new_from_file(thumb_path))
@ -130,26 +130,26 @@ class SelectObject:
if not pexists:
fexists = 0
self.object_handle.set_text(object.get_handle())
self.object_handle.set_text(obj.get_handle())
self.object_type.set_text(the_type)
self.object_desc.set_text(object.get_description())
self.object_desc.set_text(obj.get_description())
if len(path) == 0 or fexists == 0:
self.object_path.set_text(_("The file no longer exists"))
elif path[0] == "/":
self.object_path.set_text(path)
else:
self.object_path.set_text("<local>")
self.object_details.set_text(Utils.get_detail_text(object,0))
self.object_details.set_text(Utils.get_detail_text(obj,0))
def run(self):
val = self.top.run()
if val == gtk.RESPONSE_OK:
store,iter = self.object_model.get_selected()
if iter:
data = self.object_model.get_data(iter,range(self.ncols))
the_id = data[4]
return_value = self.db.get_object_from_handle(the_id)
store,node = self.object_model.get_selected()
if node:
data = self.object_model.get_data(node,range(self.ncols))
handle = data[4]
return_value = self.db.get_object_from_handle(handle)
else:
return_value = None
self.top.destroy()

View File

@ -120,9 +120,9 @@ class SourceView:
def button_press(self,obj,event):
if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1:
store,iter = self.selection.get_selected()
id = store.get_value(iter,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(id)
store,node = self.selection.get_selected()
handle = store.get_value(node,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(handle)
EditSource.EditSource(source,self.parent.db,self.parent,
self.topWindow,self.update_display)
return 1
@ -141,8 +141,8 @@ class SourceView:
def build_context_menu(self,event):
"""Builds the menu with editing operations on the source's list"""
store,iter = self.selection.get_selected()
if iter:
store,node = self.selection.get_selected()
if node:
sel_sensitivity = 1
else:
sel_sensitivity = 0
@ -168,12 +168,12 @@ class SourceView:
self.topWindow,self.new_after_edit)
def on_delete_clicked(self,obj):
store,iter = self.selection.get_selected()
if not iter:
store,node = self.selection.get_selected()
if not node:
return
id = store.get_value(iter,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(id)
handle = store.get_value(node,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(handle)
if self.is_used(source):
ans = EditSource.DelSrcQuery(source,self.parent.db,self.build_tree)
@ -237,10 +237,10 @@ class SourceView:
return 0
def on_edit_clicked(self,obj):
list_store, iter = self.selection.get_selected()
if iter:
id = list_store.get_value(iter,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(id)
list_store, node = self.selection.get_selected()
if node:
handle = list_store.get_value(node,_HANDLE_COL)
source = self.parent.db.get_source_from_handle(handle)
EditSource.EditSource(source, self.parent.db, self.parent,
self.topWindow, self.update_display)

View File

@ -150,8 +150,8 @@ class SourceSelector:
gnome.help_display('gramps-manual','gramps-edit-complete')
def selection_changed(self,obj):
(store,iter) = self.selection.get_selected()
if iter:
(store,node) = self.selection.get_selected()
if node:
self.delete.set_sensitive(gtk.TRUE)
self.edit.set_sensitive(gtk.TRUE)
else:
@ -163,8 +163,8 @@ class SourceSelector:
for s in self.list:
base_handle = s.get_base_handle()
base = self.db.get_source_from_handle(base_handle)
iter = self.model.append()
self.model.set(iter,0,base_handle,1,base.get_title())
node = self.model.append()
self.model.set(node,0,base_handle,1,base.get_title())
def src_ok_clicked(self,obj):
del self.orig[:]
@ -175,9 +175,9 @@ class SourceSelector:
self.close(obj)
def edit_src_clicked(self,obj):
store,iter = self.selection.get_selected()
if iter:
col = store.get_path(iter)
store,node = self.selection.get_selected()
if node:
col = store.get_path(node)
src = self.list[col[0]]
SourceEditor(src,self.db,self.update_clist,self)
@ -189,9 +189,9 @@ class SourceSelector:
SourceEditor(src,self.db,self.add_ref,self)
def del_src_clicked(self,obj):
(store,iter) = self.selection.get_selected()
if iter:
path = store.get_path(iter)
(store,node) = self.selection.get_selected()
if node:
path = store.get_path(node)
del self.list[path[0]]
self.redraw()
@ -243,9 +243,9 @@ class SourceTab:
self.model.clear()
for s in self.list:
base_handle = s.get_base_handle()
node = self.model.append()
base = self.db.get_source_from_handle(base_handle)
iter = self.model.append()
self.model.set(iter,0,base.get_gramps_id(),1,base.get_title())
self.model.set(node,0,base_handle,1,base.get_title())
if self.list:
Utils.bold_label(self.parent.sources_label)
else:
@ -256,9 +256,9 @@ class SourceTab:
self.parent.lists_changed = 1
def edit_src_clicked(self,obj):
store,iter = self.selection.get_selected()
if iter:
col = store.get_path(iter)
store,node = self.selection.get_selected()
if node:
col = store.get_path(node)
src = self.list[col[0]]
SourceEditor(src,self.db,self.update_clist,self)
@ -272,9 +272,9 @@ class SourceTab:
inst.redraw()
def del_src_clicked(self,obj):
(store,iter) = self.selection.get_selected()
if iter:
path = store.get_path(iter)
(store,node) = self.selection.get_selected()
if node:
path = store.get_path(node)
del self.list[path[0]]
self.parent.lists_changed = 1
self.redraw()
@ -460,17 +460,17 @@ class SourceEditor:
date = unicode(self.get_widget("sdate").get_text())
conf = self.get_widget("conf").get_menu().get_active().get_data('a')
buffer = self.get_widget("scomment").get_buffer()
comments = unicode(buffer.get_text(buffer.get_start_iter(),
buffer.get_end_iter(),gtk.FALSE))
buf = self.get_widget("scomment").get_buffer()
comments = unicode(buf.get_text(buf.get_start_iter(),
buf.get_end_iter(),gtk.FALSE))
buffer = self.get_widget("stext").get_buffer()
text = unicode(buffer.get_text(buffer.get_start_iter(),
buffer.get_end_iter(),gtk.FALSE))
buf = self.get_widget("stext").get_buffer()
text = unicode(buf.get_text(buf.get_start_iter(),
buf.get_end_iter(),gtk.FALSE))
buffer = self.get_widget('spage').get_buffer()
page = unicode(buffer.get_text(buffer.get_start_iter(),
buffer.get_end_iter(),gtk.FALSE))
buf = self.get_widget('spage').get_buffer()
page = unicode(buf.get_text(buf.get_start_iter(),
buf.get_end_iter(),gtk.FALSE))
self.source_ref.set_page(page)
self.source_ref.get_date().set(date)

View File

@ -128,20 +128,20 @@ class StyleListDisplay:
Called with the EDIT button is clicked. Calls the StyleEditor to edit the
selected style.
"""
store,iter = self.list.selection.get_selected()
if not iter:
store,node = self.list.selection.get_selected()
if not node:
return
name = self.list.model.get_value(iter,0)
name = self.list.model.get_value(node,0)
style = self.sheetlist.get_style_sheet(name)
StyleEditor(name,style,self)
def on_delete_clicked(self,obj):
"""Deletes the selected style."""
store,iter = self.list.selection.get_selected()
if not iter:
store,node = self.list.selection.get_selected()
if not node:
return
name = self.list.model.get_value(iter,0)
name = self.list.model.get_value(node,0)
self.sheetlist.delete_style_sheet(name)
self.redraw()
@ -301,8 +301,8 @@ class StyleEditor:
old paragraph, then draws the newly selected paragraph"""
objs = self.plist.get_selected_objects()
store,iter = self.plist.get_selected()
name = store.get_value(iter,0)
store,node = self.plist.get_selected()
name = store.get_value(node,0)
if self.first == 0:
self.save_paragraph(self.current_p)
else:

View File

@ -92,7 +92,7 @@ class ReadTarFile:
self.pos = 0
def extract_files(self):
map = {}
data = {}
while 1:
buf = self.f.read(100)
if buf == '':
@ -103,11 +103,11 @@ class ReadTarFile:
index = index + 1
else:
if index == 0:
return map
return data
continue
filename = buf[0:index]
if filename == None:
return map
return data
self.f.read(24) # modes
l = string.replace(self.f.read(12),chr(0),' ')
length = int(l,8)
@ -118,10 +118,11 @@ class ReadTarFile:
self.f.read(64)
self.f.read(183)
foo = cStringIO.StringIO()
map[filename] = foo
data[filename] = foo
foo.write(self.f.read(length))
foo.reset()
self.f.read(_BLKSIZE-(length%_BLKSIZE))
return data
def extract(self):
while 1:

View File

@ -63,14 +63,14 @@ class TipParser:
"""
self.mylist = []
file = open(const.tipdata)
xml_file = open(const.tipdata)
self.tlist = []
p = xml.parsers.expat.ParserCreate()
p.StartElementHandler = self.startElement
p.EndElementHandler = self.endElement
p.CharacterDataHandler = self.characters
p.ParseFile(file)
file.close()
p.ParseFile(xml_file)
xml_file.close()
def get(self):
return self.mylist

View File

@ -209,11 +209,11 @@ def redraw_list(dlist,clist,func):
clist.clear()
index = 0
for object in dlist:
for obj in dlist:
col = 0
iter = clist.append()
for data in func(object):
clist.set_value(iter,col,data)
node = clist.append()
for data in func(obj):
clist.set_value(node,col,data)
col = col + 1
index = index + 1
return index
@ -225,9 +225,9 @@ def redraw_list(dlist,clist,func):
#-------------------------------------------------------------------------
def delete_selected(obj,list):
sel = obj.get_selection()
model,iter = sel.get_selected()
if iter:
index = model.get_path(iter)[0]
model,node = sel.get_selected()
if node:
index = model.get_path(node)[0]
del list[index]
return 1
@ -249,9 +249,9 @@ def add_menuitem(menu,msg,obj,func):
#
#-------------------------------------------------------------------------
def view_photo(photo):
type = photo.get_mime_type()
mime_type = photo.get_mime_type()
try:
data = GrampsMime.get_application(type)
data = GrampsMime.get_application(mime_type)
prog = data[0]
except:
return
@ -274,7 +274,7 @@ def strip_id(text):
text = string.rstrip(text)
return text
def nautilus_icon(icon,type):
def nautilus_icon(icon,mime_type):
import GrampsCfg
theme = GrampsCfg.client.get_string("/desktop/gnome/file_views/icon_theme")
@ -288,7 +288,7 @@ def nautilus_icon(icon,type):
if os.path.isfile(newicon):
return newicon
return None
elif type == "x-directory/":
elif mime_type == "x-directory/":
if theme:
newicon = "%s/%s/i-directory.png" % (const.nautdir,theme)
else:
@ -297,7 +297,7 @@ def nautilus_icon(icon,type):
return newicon
return None
else:
icontmp = type.replace('/','-')
icontmp = mime_type.replace('/','-')
if theme:
newicon = "%s/%s/gnome-%s.png" % (const.nautdir,theme,icontmp)
if os.path.isfile(newicon):
@ -321,9 +321,9 @@ def get_mime_type(file):
except:
return "unknown"
def get_mime_description(type):
def get_mime_description(mime_type):
try:
value = gnome.vfs.mime_get_description(type)
value = gnome.vfs.mime_get_description(mime_type)
if value:
return value
else:
@ -338,19 +338,19 @@ def get_mime_description(type):
#
#-------------------------------------------------------------------------
def thumb_path(dir,mobj):
type = mobj.get_mime_type()
mime_type = mobj.get_mime_type()
if type[0:5] == "image":
if mime_type[0:5] == "image":
thumb = "%s/.thumb/%s.jpg" % (os.path.dirname(dir),mobj.get_handle())
try:
if RelImage.check_thumb(mobj.get_path(),thumb,const.thumbScale):
return thumb
else:
return find_icon(type)
return find_icon(mime_type)
except:
return find_icon(type)
return find_icon(mime_type)
else:
return find_icon(type)
return find_icon(mime_type)
#-------------------------------------------------------------------------
#

View File

@ -338,15 +338,14 @@ class XmlWriter:
count = count + 1
self.write_family_handle(family,2)
fh = family.get_father_handle()
mh = family.get_mother_handle()
if fh:
fid = self.db.get_person_from_handle (fh).get_gramps_id ()
fhandle = family.get_father_handle()
mhandle = family.get_mother_handle()
if fhandle:
fid = self.db.get_person_from_handle (fhandle).get_gramps_id ()
self.write_ref("father",fid,3)
if mh:
mid = self.db.get_person_from_handle (mh).get_gramps_id ()
if mhandle:
mid = self.db.get_person_from_handle (mhandle).get_gramps_id ()
self.write_ref("mother",mid,3)
for event_handle in family.get_event_list():
event = self.db.get_event_from_handle(event_handle)
self.dump_event(event,3)
@ -406,13 +405,13 @@ class XmlWriter:
keys = self.db.get_media_object_handles()
sorted_keys = []
for key in keys:
object = self.db.get_object_from_handle (key)
tuple = (object.get_gramps_id (), object)
obj = self.db.get_object_from_handle (key)
tuple = (obj.get_gramps_id (), obj)
sorted_keys.append (tuple)
sorted_keys.sort ()
for (gramps_id, object) in sorted_keys:
self.write_object(object)
for (gramps_id, obj) in sorted_keys:
self.write_object(obj)
self.g.write(" </objects>\n")
if len(self.db.get_bookmarks()) > 0:
@ -548,8 +547,8 @@ class XmlWriter:
self.write_date(d,index+1)
self.g.write("%s</sourceref>\n" % (" " * index))
def write_ref(self,label,id,index=1):
if id:
def write_ref(self,label,gid,index=1):
if gid:
self.g.write('%s<%s ref="%s"/>\n' % (" "*index,label,id))
def write_id(self,label,person,index=1):
@ -624,9 +623,9 @@ class XmlWriter:
def dump_name(self,label,name,index=1):
sp = " "*index
type = name.get_type()
if type:
self.g.write('%s<%s type="%s"%s>\n' % (sp,label,type,conf_priv(name)))
name_type = name.get_type()
if name_type:
self.g.write('%s<%s type="%s"%s>\n' % (sp,label,name_type,conf_priv(name)))
else:
self.g.write('%s<%s%s>\n' % (sp,label,conf_priv(name)))
self.write_line("first",name.get_first_name(),index+1)
@ -777,10 +776,10 @@ class XmlWriter:
self.dump_source_ref(s,3)
self.g.write(" </placeobj>\n")
def write_object(self,object):
id = object.get_gramps_id()
type = object.get_mime_type()
path = object.get_path()
def write_object(self,obj):
handle = obj.get_gramps_id()
mime_type = obj.get_mime_type()
path = obj.get_path()
if self.strip_photos:
path = os.path.basename(path)
else:
@ -788,18 +787,18 @@ class XmlWriter:
if len(path) >= l:
if self.fileroot == path[0:l]:
path = path[l+1:]
self.g.write(' <object id="%s" src="%s" mime="%s"' % (id,path,type))
self.g.write(' description="%s"' % self.fix(object.get_description()))
alist = object.get_attribute_list()
note = object.get_note()
slist = object.get_source_references()
self.g.write(' <object id="%s" src="%s" mime="%s"' % (handle,path,mime_type))
self.g.write(' description="%s"' % self.fix(obj.get_description()))
alist = obj.get_attribute_list()
note = obj.get_note()
slist = obj.get_source_references()
if len(alist) == 0 and len(slist) == 0 and note == "":
self.g.write('/>\n')
else:
self.g.write('>\n')
self.write_attribute_list(alist)
if note != "":
self.write_note("note",object.get_note_object(),3)
self.write_note("note",obj.get_note_object(),3)
for s in slist:
self.dump_source_ref(s,3)
self.g.write(" </object>\n")