From 15eb34737b54dad59c1e3836ca22e2a189afdaf4 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Wed, 6 Oct 2004 03:42:54 +0000 Subject: [PATCH] * src/docgen/PdfDoc.py: fixed register_book_doc call * src/AddrEdit.py: pychecker fixes * src/AttrEdit.py: pychecker fixes * src/AutoComp.py: pychecker fixes * src/ChooseParents.py: pychecker fixes * src/DbPrompter.py: pychecker fixes * src/DisplayModels.py: pychecker fixes * src/EventEdit.py: pychecker fixes * src/FamilyView.py: pychecker fixes * src/Filter.py: pychecker fixes * src/GenericFilter.py: pychecker fixes * src/GrampsCfg.py: pychecker fixes * src/GrampsGconfKeys.py: pychecker fixes * src/ImgManip.py: pychecker fixes * src/PlaceView.py: pychecker fixes * src/Plugins.py: pychecker fixes * src/ReadGedcom.py: pychecker fixes * src/ReadXML.py: pychecker fixes * src/SelectChild.py: pychecker fixes * src/SelectObject.py: pychecker fixes * src/SelectPerson.py: pychecker fixes * src/Sort.py: pychecker fixes * src/SourceView.py: pychecker fixes * src/Utils.py: pychecker fixes * src/Witness.py: pychecker fixes * src/WriteGedcom.py: pychecker fixes * src/WriteXML.py: pychecker fixes * src/gramps_main.py: pychecker fixes svn: r3599 --- ChangeLog | 30 ++++++++ src/AddrEdit.py | 1 - src/AttrEdit.py | 14 ++-- src/AutoComp.py | 1 - src/ChooseParents.py | 20 ----- src/DbPrompter.py | 1 - src/DisplayModels.py | 19 ++--- src/EventEdit.py | 1 - src/FamilyView.py | 163 +++++++++++++++++++++-------------------- src/Filter.py | 8 +- src/GenericFilter.py | 2 +- src/GrampsCfg.py | 1 - src/GrampsGconfKeys.py | 2 +- src/ImgManip.py | 9 --- src/PlaceView.py | 3 - src/Plugins.py | 6 +- src/ReadGedcom.py | 154 +++++++++++++++++++------------------- src/ReadXML.py | 132 ++++++++++++++++----------------- src/SelectChild.py | 17 ++--- src/SelectObject.py | 3 - src/SelectPerson.py | 1 - src/Sort.py | 2 +- src/SourceView.py | 2 - src/Utils.py | 2 +- src/Witness.py | 11 ++- src/WriteGedcom.py | 51 ++----------- src/WriteXML.py | 34 ++++----- src/gramps_main.py | 61 ++++----------- 28 files changed, 333 insertions(+), 418 deletions(-) diff --git a/ChangeLog b/ChangeLog index 954b56fbd..c76f1e9a8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,33 @@ +2004-10-05 Don Allingham + * src/docgen/PdfDoc.py: fixed register_book_doc call + * src/AddrEdit.py: pychecker fixes + * src/AttrEdit.py: pychecker fixes + * src/AutoComp.py: pychecker fixes + * src/ChooseParents.py: pychecker fixes + * src/DbPrompter.py: pychecker fixes + * src/DisplayModels.py: pychecker fixes + * src/EventEdit.py: pychecker fixes + * src/FamilyView.py: pychecker fixes + * src/Filter.py: pychecker fixes + * src/GenericFilter.py: pychecker fixes + * src/GrampsCfg.py: pychecker fixes + * src/GrampsGconfKeys.py: pychecker fixes + * src/ImgManip.py: pychecker fixes + * src/PlaceView.py: pychecker fixes + * src/Plugins.py: pychecker fixes + * src/ReadGedcom.py: pychecker fixes + * src/ReadXML.py: pychecker fixes + * src/SelectChild.py: pychecker fixes + * src/SelectObject.py: pychecker fixes + * src/SelectPerson.py: pychecker fixes + * src/Sort.py: pychecker fixes + * src/SourceView.py: pychecker fixes + * src/Utils.py: pychecker fixes + * src/Witness.py: pychecker fixes + * src/WriteGedcom.py: pychecker fixes + * src/WriteXML.py: pychecker fixes + * src/gramps_main.py: pychecker fixes + 2004-10-03 Frederick Noronha * src/data/tips.xml: Add more tips. diff --git a/src/AddrEdit.py b/src/AddrEdit.py index 8f6e2a7ef..00b41cebf 100644 --- a/src/AddrEdit.py +++ b/src/AddrEdit.py @@ -50,7 +50,6 @@ import Utils import Date import RelLib import Sources -import Date import DateEdit #------------------------------------------------------------------------- diff --git a/src/AttrEdit.py b/src/AttrEdit.py index 046161c6f..2cd654bb7 100644 --- a/src/AttrEdit.py +++ b/src/AttrEdit.py @@ -196,7 +196,7 @@ class AttributeEditor: Called when the OK button is pressed. Gets data from the form and updates the Attribute data structure. """ - type = unicode(self.type_field.get_text()) + attr = unicode(self.type_field.get_text()) value = unicode(self.value_field.get_text()) buf = self.note_field.get_buffer() @@ -204,11 +204,11 @@ class AttributeEditor: format = self.preform.get_active() priv = self.priv.get_active() - if not type in self.alist: + if not attr in self.alist: WarningDialog(_('New attribute type created'), _('The "%s" attribute type has been added to this database.\n' - 'It will now appear in the attribute menus for this database') % type) - self.alist.append(type) + 'It will now appear in the attribute menus for this database') % attr) + self.alist.append(attr) self.alist.sort() if self.attrib == None: @@ -216,7 +216,7 @@ class AttributeEditor: self.parent.alist.append(self.attrib) self.attrib.set_source_reference_list(self.srcreflist) - self.update(type,value,note,format,priv) + self.update(attr,value,note,format,priv) self.callback(self.attrib) self.close(obj) @@ -227,9 +227,9 @@ class AttributeEditor: set(data) self.parent.lists_changed = 1 - def update(self,type,value,note,format,priv): + def update(self,attr,value,note,format,priv): """Compares the data items, and updates if necessary""" - ntype = const.save_pattr(type) + ntype = const.save_pattr(attr) self.check(self.attrib.get_type,self.attrib.set_type,ntype) self.check(self.attrib.get_value,self.attrib.set_value,value) self.check(self.attrib.get_note,self.attrib.set_note,note) diff --git a/src/AutoComp.py b/src/AutoComp.py index 9ca54a452..c89ebda05 100644 --- a/src/AutoComp.py +++ b/src/AutoComp.py @@ -55,7 +55,6 @@ def fill_entry(entry,data_list): def fill_option_text(combobox,data): store = gtk.ListStore(gobject.TYPE_STRING) - cell = gtk.CellRendererText() for item in data: store.append(row=[item]) combobox.set_model(store) diff --git a/src/ChooseParents.py b/src/ChooseParents.py index a07289d47..eab8c95f0 100644 --- a/src/ChooseParents.py +++ b/src/ChooseParents.py @@ -34,7 +34,6 @@ __version__ = "$Revision$" # #------------------------------------------------------------------------- from gettext import gettext as _ -import os #------------------------------------------------------------------------- # @@ -417,25 +416,6 @@ class ChooseParents: self.db.commit_family(family,trans) return family - def mother_list_select_row(self,obj): - """Called when a row is selected in the mother list. Sets the - active mother based off the id associated with the row.""" - - idlist = self.get_selected_mother_handles() - if idlist and idlist[0]: - self.mother = self.db.get_person_from_handle(idlist[0]) - else: - self.mother = None - - if not self.parent_selected and self.mother: - self.parent_selected = 1 - family_handle_list = self.mother.get_family_handle_list() - if len(family_handle_list) >= 1: - family = self.db.get_family_from_handle(family_handle_list[0]) - father_handle = family.get_father_handle() - self.father_selection.select(father_handle) - #self.father_model.center_selected() - def father_select_function(self,store,path,iter,id_list): if len(path) != 1: val = self.father_model.get_value(iter,PeopleModel.COLUMN_INT_ID) diff --git a/src/DbPrompter.py b/src/DbPrompter.py index bf29c529e..bae472c34 100644 --- a/src/DbPrompter.py +++ b/src/DbPrompter.py @@ -26,7 +26,6 @@ # #------------------------------------------------------------------------- import os -import shutil from gettext import gettext as _ #------------------------------------------------------------------------- diff --git a/src/DisplayModels.py b/src/DisplayModels.py index 468abaef2..b206e07eb 100644 --- a/src/DisplayModels.py +++ b/src/DisplayModels.py @@ -51,19 +51,14 @@ class BaseModel(gtk.GenericTreeModel): self.datalist = self.sort_keys() - def on_row_inserted(self,obj,path,iter): + def on_row_inserted(self,obj,path,node): self.rebuild_data() - def delete_row_by_handle(self,handle): - index = self.datalist.index(handle) - del self.datalist[index] - self.row_deleted(index) - def add_row_by_handle(self,handle): self.datalist = self.sort_keys() index = self.datalist.index(handle) - iter = self.get_iter(index) - self.row_inserted(index,iter) + node = self.get_iter(index) + self.row_inserted(index,node) def delete_row_by_handle(self,handle): index = self.datalist.index(handle) @@ -72,8 +67,8 @@ class BaseModel(gtk.GenericTreeModel): def update_row_by_handle(self,handle): index = self.datalist.index(handle) - iter = self.get_iter(index) - self.row_changed(index,iter) + node = self.get_iter(index) + self.row_changed(index,node) def on_get_flags(self): '''returns the GtkTreeModelFlags for this particular type of model''' @@ -96,9 +91,9 @@ class BaseModel(gtk.GenericTreeModel): except IndexError: return None - def on_get_value(self,iter,col): + def on_get_value(self,node,col): try: - return self.fmap[col](self.map[str(iter)]) + return self.fmap[col](self.map[str(node)]) except: return u'' diff --git a/src/EventEdit.py b/src/EventEdit.py index 48e42b4ac..8123891e1 100644 --- a/src/EventEdit.py +++ b/src/EventEdit.py @@ -46,7 +46,6 @@ import Sources import Witness import const import Utils -import GrampsCfg import AutoComp import RelLib import Date diff --git a/src/FamilyView.py b/src/FamilyView.py index aa20ebf96..032d5224f 100644 --- a/src/FamilyView.py +++ b/src/FamilyView.py @@ -291,12 +291,12 @@ class FamilyView: self.add_sp_parents(obj) def child_key_press(self,obj,event): - model, iter = self.child_selection.get_selected() - if not iter: + model, node = self.child_selection.get_selected() + if not node: return - id = self.child_model.get_value(iter,7) + handle = self.child_model.get_value(node,7) if event.keyval == gtk.gdk.keyval_from_name("Return") and not event.state: - self.child_rel_by_id(id) + self.child_rel_by_id(handle) elif event.keyval == gtk.gdk.keyval_from_name("Return") \ and event.state == gtk.gdk.SHIFT_MASK: self.edit_child_callback(obj) @@ -429,22 +429,22 @@ class FamilyView: menu.popup(None,None,None,event.button,event.time) def on_child_list_button_press(self,obj,event): - model, iter = self.child_selection.get_selected() - if not iter: + model, node = self.child_selection.get_selected() + if not node: if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: self.build_nav_menu(event) return - id = self.child_model.get_value(iter,7) + handle = self.child_model.get_value(node,7) if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: - self.child_rel_by_id(id) + self.child_rel_by_id(handle) elif event.state == gtk.gdk.SHIFT_MASK and \ event.type == gtk.gdk.BUTTON_PRESS and \ event.button == 1: self.edit_child_callback(obj) elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: - self.build_child_menu(id,event) + self.build_child_menu(handle,event) - def build_child_menu(self,id,event): + def build_child_menu(self,handle,event): """Builds the menu that allows editing operations on the child list""" menu = gtk.Menu() @@ -480,33 +480,36 @@ class FamilyView: (_("Remove the selected child"),self.remove_child_clicked), ] for msg,callback in entries: - Utils.add_menuitem(menu,msg,id,callback) + Utils.add_menuitem(menu,msg,handle,callback) menu.popup(None,None,None,event.button,event.time) def edit_child_callback(self,obj): - model, iter = self.child_selection.get_selected() - if not iter: + model, node = self.child_selection.get_selected() + if not node: return - child = self.parent.db.get_person_from_handle(self.child_model.get_value(iter,7)) + handle = self.child_model.get_value(node,7) + child = self.parent.db.get_person_from_handle(handle) try: - EditPerson.EditPerson(self.parent, child, self.parent.db, self.spouse_after_edit) + EditPerson.EditPerson(self.parent, child, self.parent.db, + self.spouse_after_edit) except: DisplayTrace.DisplayTrace() def child_rel(self,obj): - person = self.parent.db.get_person_from_handle(obj.get_data(Utils.OBJECT)) + handle = obj.get_data('o') + person = self.parent.db.get_person_from_handle(handle) SelectChild.EditRel(self.parent.db,person,self.family,self.load_family) - def child_rel_by_id(self,id): - person = self.parent.db.get_person_from_handle(id) + def child_rel_by_id(self,handle): + person = self.parent.db.get_person_from_handle(handle) SelectChild.EditRel(self.parent.db,person,self.family,self.load_family) def spouse_changed(self,obj): - model, iter = obj.get_selected() - if not iter: + model, node = obj.get_selected() + if not node: self.display_marriage(None) else: - row = model.get_path(iter) + row = model.get_path(node) family_handle = self.person.get_family_handle_list()[row[0]] fam = self.parent.db.get_family_from_handle(family_handle) self.display_marriage(fam) @@ -686,7 +689,7 @@ class FamilyView: DisplayTrace.DisplayTrace() def update_person_list(self,person): - trans = self.db.transaction_begin() + trans = self.parent.db.transaction_begin() if not self.family: self.family = RelLib.Family() @@ -701,9 +704,9 @@ class FamilyView: person.add_parent_family_handle(self.family.get_handle(),"Birth","Birth") self.parent.update_person_list(person) self.load_family(self.family) - self.db.commit_person(person,trans) - self.db.commit_family(self.family,trans) - self.db.transaction_commit(trans,_("Modify family")) + self.parent.db.commit_person(person,trans) + self.parent.db.commit_family(self.family,trans) + self.parent.db.transaction_commit(trans,_("Modify family")) def new_child_after_edit(self,epo,trans): @@ -739,12 +742,12 @@ class FamilyView: if not self.family or not self.person: return - model, iter = self.child_selection.get_selected() - if not iter: + model, node = self.child_selection.get_selected() + if not node: return - id = self.child_model.get_value(iter,7) - child = self.parent.db.get_person_from_handle(id) + handle = self.child_model.get_value(node,7) + child = self.parent.db.get_person_from_handle(handle) trans = self.parent.db.transaction_begin() @@ -834,8 +837,8 @@ class FamilyView: if len(plist) == 1: family_handle,m,r = plist[0] else: - model, iter = self.ap_selection.get_selected() - path = model.get_path(iter) + model, node = self.ap_selection.get_selected() + path = model.get_path(node) family_handle,m,r = plist[path[0]] family = self.parent.db.get_family_from_handle(family_handle) @@ -862,8 +865,8 @@ class FamilyView: def load_family(self,family=None): if self.parent.active_person: - id = self.parent.active_person.get_handle() - self.person = self.parent.db.get_person_from_handle(id) + handle = self.parent.active_person.get_handle() + self.person = self.parent.db.get_person_from_handle(handle) else: self.person = None self.clear() @@ -891,8 +894,8 @@ class FamilyView: self.ap_model.clear() self.ap_data.get_selection().set_mode(gtk.SELECTION_NONE) - iter = self.ap_model.append() - self.ap_model.set(iter,0,n) + node = self.ap_model.append() + self.ap_model.set(node,0,n) self.selected_spouse = None self.spouse_model.clear() @@ -916,8 +919,8 @@ class FamilyView: else: sp_id = fm.get_father_handle() - iter = self.spouse_model.append() - flist[f] = iter + node = self.spouse_model.append() + flist[f] = node if sp_id: sp = self.parent.db.get_person_from_handle(sp_id) @@ -930,20 +933,20 @@ class FamilyView: sp.get_gramps_id(), const.family_relations[fm.get_relationship()][0], mdate) - self.spouse_model.set(iter,0,v) + self.spouse_model.set(node,0,v) else: - self.spouse_model.set(iter,0,"%s\n" % _("")) + self.spouse_model.set(node,0,"%s\n" % _("")) if family and family.get_handle() in flist: self.display_marriage(family) - iter = flist[family.get_handle()] - self.spouse_selection.select_iter(iter) + node = flist[family.get_handle()] + self.spouse_selection.select_iter(node) elif len(flist) > 0: fid = splist[0] fam = self.parent.db.get_family_from_handle(fid) self.display_marriage(fam) - iter = flist[fid] - self.spouse_selection.select_iter(iter) + node = flist[fid] + self.spouse_selection.select_iter(node) else: self.display_marriage(None) @@ -961,9 +964,9 @@ class FamilyView: model.clear() sel = None selection = tree.get_selection() - list = person.get_parent_family_handle_list() + family_list = person.get_parent_family_handle_list() - for (f,mrel,frel) in list: + for (f,mrel,frel) in family_list: fam = self.parent.db.get_family_from_handle(f) father_handle = fam.get_father_handle() mother_handle = fam.get_mother_handle() @@ -972,12 +975,12 @@ class FamilyView: father = self.nameof(_("Father"),f,frel) mother = self.nameof(_("Mother"),m,mrel) - iter = model.append() + node = model.append() if not sel: - sel = iter + sel = node v = "%s\n%s" % (father,mother) - model.set(iter,0,v) - if len(list) > 1: + model.set(node,0,v) + if len(family_list) > 1: selection.set_mode(gtk.SELECTION_SINGLE) selection.select_iter(sel) else: @@ -1045,11 +1048,11 @@ class FamilyView: else: status = "%s/%s" % (_(fam[1]),_(fam[2])) - iter = self.child_model.append() - self.child_map[iter] = child.get_handle() + node = self.child_model.append() + self.child_map[node] = child.get_handle() if fiter == None: - fiter = self.child_model.get_path(iter) + fiter = self.child_model.get_path(node) val = child.get_display_info() i += 1 @@ -1058,7 +1061,7 @@ class FamilyView: dval = self.dd.display(event.get_date_object()) else: dval = u'' - self.child_model.set(iter,0,i,1,val[0],2,val[1],3,val[2], + self.child_model.set(node,0,i,1,val[0],2,val[1],3,val[2], 4,dval,5,status,6,val[6],7,child.get_handle()) def build_parents_menu(self,family,event): @@ -1157,8 +1160,8 @@ class FamilyView: elif len(plist) == 1: family,m,r = plist[0] else: - model, iter = self.ap_selection.get_selected() - path = model.get_path(iter) + model, node = self.ap_selection.get_selected() + path = model.get_path(node) family,m,r = plist[path[0]] self.build_parents_menu(family,event) @@ -1177,8 +1180,8 @@ class FamilyView: elif len(plist) == 1: family,m,r = plist[0] else: - model, iter = self.sp_selection.get_selected() - path = model.get_path(iter) + model, node = self.sp_selection.get_selected() + path = model.get_path(node) family,m,r = plist[path[0]] self.build_sp_parents_menu(family,event) @@ -1221,16 +1224,16 @@ class FamilyView: def child_back(self,obj): """makes the currently select child the active person""" - model, iter = self.child_selection.get_selected() - if iter: - id = self.child_model.get_value(iter,2) - child = self.parent.db.get_person_from_gramps_id(id) + model, node = self.child_selection.get_selected() + if node: + handle = self.child_model.get_value(node,2) + child = self.parent.db.get_person_from_gramps_id(handle) self.parent.change_active_person(child) self.load_family() else: - list = self.family.get_child_handle_list() - if len(list) == 1: - p = self.parent.db.get_person_from_handle(list[0]) + child_list = self.family.get_child_handle_list() + if len(child_list) == 1: + p = self.parent.db.get_person_from_handle(child_list[0]) self.parent.change_active_person(p) self.load_family() @@ -1245,11 +1248,11 @@ class FamilyView: elif len(plist) == 1: parents,mrel,frel = plist[0] else: - model, iter = selection.get_selected() - if not iter: + model, node = selection.get_selected() + if not node: return - row = model.get_path(iter) + row = model.get_path(node) parents,mrel,frel = plist[row[0]] try: @@ -1285,11 +1288,11 @@ class FamilyView: if len(plist) == 1: person.clear_parent_family_handle_list() else: - model, iter = selection.get_selected() - if not iter: + model, node = selection.get_selected() + if not node: return - row = model.get_path(iter) + row = model.get_path(node) family_handle = person.get_parent_family_handle_list()[row[0]][0] person.remove_parent_family_handle(family_handle) fam = self.parent.db.get_family_from_handle(family_handle) @@ -1335,29 +1338,29 @@ class FamilyView: spath = s.get_path(i) src = spath[0] - list = self.family.get_child_handle_list() + child_list = self.family.get_child_handle_list() - obj = list[src] - list.remove(obj) - list.insert(row,obj) + obj = child_list[src] + child_list.remove(obj) + child_list.insert(row,obj) - if self.birth_dates_in_order(list) == 0: + if self.birth_dates_in_order(child_list) == 0: WarningDialog(_("Attempt to Reorder Children Failed"), _("Children must be ordered by their birth dates.")) return - self.family.set_child_handle_list(list) + self.family.set_child_handle_list(child_list) trans = self.parent.db.transaction_begin() self.parent.db.commit_family(self.family,trans) self.parent.db.transaction_commit(trans,_('Reorder children')) self.display_marriage(self.family) def drag_data_get(self,widget, context, sel_data, info, time): - store,iter = self.child_selection.get_selected() - if not iter: + store,node = self.child_selection.get_selected() + if not node: return - id = self.child_model.get_value(iter,2) + handle = self.child_model.get_value(node,2) bits_per = 8; # we're going to pass a string - data = str(('child',id)); + data = str(('child',handle)); sel_data.set(sel_data.target, bits_per, data) def north_american(self,val): diff --git a/src/Filter.py b/src/Filter.py index 7547f5bc2..7f9e49e88 100644 --- a/src/Filter.py +++ b/src/Filter.py @@ -108,8 +108,8 @@ def load_filters(dir): return sys.path.append(dir) - for file in os.listdir(dir): - name = os.path.split(file) + for filename in os.listdir(dir): + name = os.path.split(filename) match = pymod.match(name[1]) if match: plugin = match.groups()[0] @@ -127,8 +127,8 @@ def load_filters(dir): #------------------------------------------------------------------------- def build_filter_menu(callback,fw): myMenu = gtk.Menu() - for filter in _filter_list: - menuitem = gtk.MenuItem(filter[1]) + for filter_obj in _filter_list: + menuitem = gtk.MenuItem(filter_obj[1]) myMenu.append(menuitem) menuitem.set_data("filter",fw) menuitem.set_data("name",filter[1]) diff --git a/src/GenericFilter.py b/src/GenericFilter.py index dfd996575..34ccec0a2 100644 --- a/src/GenericFilter.py +++ b/src/GenericFilter.py @@ -60,7 +60,7 @@ from Utils import for_each_ancestor def date_cmp(rule,value): sd = rule.get_start_date() s = sd.get_modifier() - val = s.get_start_date() + value = s.get_start_date() if s == Date.MOD_BEFORE: return rule > value elif s == Date.MOD_AFTER: diff --git a/src/GrampsCfg.py b/src/GrampsCfg.py index 691c8a88f..842e5e5dd 100644 --- a/src/GrampsCfg.py +++ b/src/GrampsCfg.py @@ -26,7 +26,6 @@ # #------------------------------------------------------------------------- import os -import string from gettext import gettext as _ #------------------------------------------------------------------------- diff --git a/src/GrampsGconfKeys.py b/src/GrampsGconfKeys.py index 615f20626..51e18088b 100644 --- a/src/GrampsGconfKeys.py +++ b/src/GrampsGconfKeys.py @@ -36,7 +36,7 @@ except ImportError: import gnome.gconf gconf = gnome.gconf - +import gobject import os client = gconf.client_get_default() diff --git a/src/ImgManip.py b/src/ImgManip.py index a9f9e4719..89445c775 100644 --- a/src/ImgManip.py +++ b/src/ImgManip.py @@ -72,9 +72,6 @@ class ImgManip: def png_thumbnail(self,dest,width,height): self.fmt_thumbnail(dest,width,height,"png") - def eps_thumbnail(self,dest,width,height): - self.fmt_thumbnail(dest,width,height,"eps") - def jpg_convert(self,dest): self.fmt_convert(dest,"jpeg") @@ -90,17 +87,11 @@ class ImgManip: def png_data(self): return self.fmt_data("png") - def eps_data(self): - return self.fmt_data("eps") - def jpg_scale_data(self,x,y): return self.fmt_scale_data(x,y,"jpeg") def png_scale_data(self,x,y): return self.fmt_scale_data(x,y,"png") - def eps_scale_data(self,x,y): - return self.fmt_scale_data(x,y,"eps") - diff --git a/src/PlaceView.py b/src/PlaceView.py index b650df99d..43c427b9d 100644 --- a/src/PlaceView.py +++ b/src/PlaceView.py @@ -29,7 +29,6 @@ Handles the place view for GRAMPS. # GTK modules # #------------------------------------------------------------------------- -import gobject import gtk import gtk.gdk @@ -40,9 +39,7 @@ import gtk.gdk #------------------------------------------------------------------------- import RelLib import EditPlace -import Utils import DisplayModels -import ColumnOrder import const from QuestionDialog import QuestionDialog, ErrorDialog diff --git a/src/Plugins.py b/src/Plugins.py index fdc8f948e..3325f75cd 100644 --- a/src/Plugins.py +++ b/src/Plugins.py @@ -460,13 +460,13 @@ def reload_plugins(obj): # Plugin registering # #------------------------------------------------------------------------- -def register_export(exportData,_title,_description='',_config=None,_filename=''): +def register_export(exportData,title,description='',config=None,filename=''): """ Register an export filter, taking the task, file filter, and the list of patterns for the filename matching. """ - if _description and _filename: - _exports.append((exportData,_title,_description,_config,_filename)) + if description and filename: + _exports.append((exportData,title,description,config,filename)) def register_import(task, ffilter, mime=None, native_format=0): """Register an import filter, taking the task and file filter""" diff --git a/src/ReadGedcom.py b/src/ReadGedcom.py index 2ec48aee6..f0441f7ec 100644 --- a/src/ReadGedcom.py +++ b/src/ReadGedcom.py @@ -290,11 +290,11 @@ class GedcomParser: self.error_count = 0 - map = const.personalConstantAttributes - self.attrs = map.values() + amap = const.personalConstantAttributes + self.attrs = amap.values() self.gedattr = {} - for val in map.keys(): - self.gedattr[map[val]] = val + for val in amap.keys(): + self.gedattr[amap[val]] = val if self.window: self.update(self.file_obj,os.path.basename(file)) @@ -407,14 +407,12 @@ class GedcomParser: return self.groups def barf(self,level): - import traceback msg = _("Warning: line %d was not understood, so it was ignored.") % self.index self.errmsg(msg) msg = "\n\t%s\n" % self.text self.errmsg(msg) self.error_count = self.error_count + 1 -# self.errmsg(string.join(traceback.format_stack())) self.ignore_sub_junk(level) def warn(self,msg): @@ -559,9 +557,9 @@ class GedcomParser: if self.indi_count % UPDATE == 0 and self.window: self.update(self.people_obj,str(self.indi_count)) self.indi_count = self.indi_count + 1 - id = matches[1] - id = id[1:-1] - self.person = self.find_or_create_person(self.map_gid(id)) + gid = matches[1] + gid = gid[1:-1] + self.person = self.find_or_create_person(self.map_gid(gid)) self.added[self.person.get_handle()] = 1 self.parse_individual() self.db.commit_person(self.person, self.trans) @@ -588,15 +586,15 @@ class GedcomParser: else: self.barf(1) - def map_gid(self,id): - if self.idswap.get(id): - return self.idswap[id] + def map_gid(self,gid): + if self.idswap.get(gid): + return self.idswap[gid] else: - if self.db.id_trans.get(str(id)): - self.idswap[id] = self.db.find_next_gid() + if self.db.id_trans.get(str(gid)): + self.idswap[gid] = self.db.find_next_gid() else: - self.idswap[id] = id - return self.idswap[id] + self.idswap[gid] = gid + return self.idswap[gid] def find_or_create_person(self,gramps_id): person = RelLib.Person() @@ -704,6 +702,7 @@ class GedcomParser: pass else: self.barf(level+1) + return None def parse_family(self): self.addr = None @@ -715,27 +714,27 @@ class GedcomParser: self.backup() return elif matches[1] == "HUSB": - id = matches[2] - person = self.find_or_create_person(self.map_gid(id[1:-1])) + gid = matches[2] + person = self.find_or_create_person(self.map_gid(gid[1:-1])) self.family.set_father_handle(person.get_handle()) self.ignore_sub_junk(2) elif matches[1] == "WIFE": - id = matches[2] - person = self.find_or_create_person(self.map_gid(id[1:-1])) + gid = matches[2] + person = self.find_or_create_person(self.map_gid(gid[1:-1])) self.family.set_mother_handle(person.get_handle()) self.ignore_sub_junk(2) elif matches[1] == "SLGS": - ord = RelLib.LdsOrd() - self.family.set_lds_sealing(ord) - self.parse_ord(ord,2) + lds_ord = RelLib.LdsOrd() + self.family.set_lds_sealing(lds_ord) + self.parse_ord(lds_ord,2) elif matches[1] == "ADDR": self.addr = RelLib.Address() self.addr.set_street(matches[2] + self.parse_continue_data(1)) self.parse_address(self.addr,2) elif matches[1] == "CHIL": mrel,frel = self.parse_ftw_relations(2) - id = matches[2] - child = self.find_or_create_person(self.map_gid(id[1:-1])) + gid = matches[2] + child = self.find_or_create_person(self.map_gid(gid[1:-1])) self.family.add_child_handle(child.get_handle()) for f in child.get_parent_family_handle_list(): @@ -868,14 +867,14 @@ class GedcomParser: else: self.person.set_gender(RelLib.Person.female) elif matches[1] in [ "BAPL", "ENDL", "SLGC" ]: - ord = RelLib.LdsOrd() + lds_ord = RelLib.LdsOrd() if matches[1] == "BAPL": - self.person.set_lds_baptism(ord) + self.person.set_lds_baptism(lds_ord) elif matches[1] == "ENDL": - self.person.set_lds_endowment(ord) + self.person.set_lds_endowment(lds_ord) else: - self.person.set_lds_sealing(ord) - self.parse_ord(ord,2) + self.person.set_lds_sealing(lds_ord) + self.parse_ord(lds_ord,2) elif matches[1] == "FAMS": family = self.find_or_create_family(matches[2][1:-1]) self.person.add_family_handle(family.get_handle()) @@ -885,14 +884,14 @@ class GedcomParser: note = "%s\n\n%s" % (note,self.parse_optional_note(2)) self.db.commit_family(family, self.trans) elif matches[1] == "FAMC": - type,note = self.parse_famc_type(2) + ftype,note = self.parse_famc_type(2) family = self.find_or_create_family(matches[2][1:-1]) for f in self.person.get_parent_family_handle_list(): if f[0] == family.get_handle(): break else: - if type == "" or type == "Birth": + if ftype == "" or ftype == "Birth": if self.person.get_main_parents_family_handle() == None: self.person.set_main_parent_family_handle(family.get_handle()) else: @@ -900,7 +899,7 @@ class GedcomParser: else: if self.person.get_main_parents_family_handle() == family.get_handle(): self.person.set_main_parent_family_handle(None) - self.person.add_parent_family_handle(family.get_handle(),type,type) + self.person.add_parent_family_handle(family.get_handle(),ftype,ftype) self.db.commit_family(family, self.trans) elif matches[1] == "RESI": addr = RelLib.Address() @@ -1015,18 +1014,19 @@ class GedcomParser: self.ignore_sub_junk(level+1) else: self.barf(level+1) - + return None + def parse_famc_type(self,level): - type = "" + ftype = "" note = "" while 1: matches = self.get_next() if int(matches[0]) < level: self.backup() - return (string.capitalize(type),note) + return (string.capitalize(ftype),note) elif matches[1] == "PEDI": - type = matches[2] + ftype = matches[2] elif matches[1] == "SOUR": source_ref = self.handle_source(matches,level+1) self.person.get_primary_name().add_source_reference(source_ref) @@ -1040,10 +1040,11 @@ class GedcomParser: self.ignore_sub_junk(level+1) else: self.barf(level+1) - + return None + def parse_person_object(self,level): form = "" - file = "" + filename = "" title = "" note = "" while 1: @@ -1053,7 +1054,7 @@ class GedcomParser: elif matches[1] == "TITL": title = matches[2] elif matches[1] == "FILE": - file = matches[2] + filename = matches[2] elif matches[1] == "NOTE": note = matches[2] + self.parse_continue_data(level+1) elif matches[1][0] == "_": @@ -1066,13 +1067,13 @@ class GedcomParser: if form == "url": url = RelLib.Url() - url.set_path(file) + url.set_path(filename) url.set_description(title) self.person.add_url(url) else: - (ok,path) = self.find_file(file,self.dir_path) + (ok,path) = self.find_file(filename,self.dir_path) if not ok: - self.warn(_("Warning: could not import %s") % file + "\n") + self.warn(_("Warning: could not import %s") % filename + "\n") self.warn(_("\tThe following paths were tried:\n\t\t")) self.warn(string.join(path,"\n\t\t")) self.warn('\n') @@ -1089,7 +1090,7 @@ class GedcomParser: def parse_family_object(self,level): form = "" - file = "" + filename = "" title = "" note = "" while 1: @@ -1099,7 +1100,7 @@ class GedcomParser: elif matches[1] == "TITL": title = matches[2] elif matches[1] == "FILE": - file = matches[2] + filename = matches[2] elif matches[1] == "NOTE": note = matches[2] + self.parse_continue_data(level+1) elif int(matches[0]) < level: @@ -1109,9 +1110,9 @@ class GedcomParser: self.barf(level+1) if form: - (ok,path) = self.find_file(file,self.dir_path) + (ok,path) = self.find_file(filename,self.dir_path) if not ok: - self.warn(_("Warning: could not import %s") % file + "\n") + self.warn(_("Warning: could not import %s") % filename + "\n") self.warn(_("\tThe following paths were tried:\n\t\t")) self.warn(string.join(path,"\n\t\t")) self.warn('\n') @@ -1185,7 +1186,7 @@ class GedcomParser: else: self.barf(level+1) - def parse_ord(self,ord,level): + def parse_ord(self,lds_ord,level): note = "" while 1: matches = self.get_next() @@ -1195,28 +1196,27 @@ class GedcomParser: elif matches[1] == "TEMP": value = extract_temple(matches) if value: - ord.set_temple(value) + lds_ord.set_temple(value) elif matches[1] == "DATE": - ord.set_date_object(self.extract_date(matches[2])) + lds_ord.set_date_object(self.extract_date(matches[2])) elif matches[1] == "FAMC": - ord.set_family_handle(self.find_or_create_family(matches[2][1:-1])) + lds_ord.set_family_handle(self.find_or_create_family(matches[2][1:-1])) elif matches[1] == "PLAC": try: - val = matches[2] place = self.find_or_create_place(matches[2]) place.set_title(matches[2]) place_handle = place.get_handle() - ord.set_place_handle(place_handle) + lds_ord.set_place_handle(place_handle) self.ignore_sub_junk(level+1) except NameError: pass elif matches[1] == "SOUR": - ord.add_source_reference(self.handle_source(matches,level+1)) + lds_ord.add_source_reference(self.handle_source(matches,level+1)) elif matches[1] == "NOTE": - note = self.parse_note(matches,ord,level+1,note) + note = self.parse_note(matches,lds_ord,level+1,note) elif matches[1] == "STAT": if const.lds_status.has_key(matches[2]): - ord.set_status(const.lds_status[matches[2]]) + lds_ord.set_status(const.lds_status[matches[2]]) else: self.barf(level+1) @@ -1349,7 +1349,8 @@ class GedcomParser: frel = "Birth" else: self.barf(level+1) - + return None + def parse_person_attr(self,attr,level): note = "" while 1: @@ -1486,7 +1487,8 @@ class GedcomParser: note = matches[2] + self.parse_continue_data(level+1) else: self.barf(level+1) - + return None + def parse_name(self,name,level): """Parses the person's name information""" note = "" @@ -1655,7 +1657,8 @@ class GedcomParser: return matches[2] else: self.barf(2) - + return None + def parse_ftw_fam_schema(self,level): while 1: matches = self.get_next() @@ -1666,16 +1669,16 @@ class GedcomParser: else: label = self.parse_label(level+1) ged2fam[matches[1]] = label - + return None + def ignore_sub_junk(self,level): - while 1: matches = self.get_next() - if int(matches[0]) < level: self.backup() return - + return + def ignore_change_data(self,level): matches = self.get_next() if matches[1] == "CHAN": @@ -1692,7 +1695,7 @@ class GedcomParser: return elif matches[1] != "FORM": self.barf(level+1) - + def parse_continue_data(self,level): data = "" while 1: @@ -1711,7 +1714,8 @@ class GedcomParser: else: self.backup() return data - + return None + def parse_note_continue(self,level): data = "" while 1: @@ -1732,6 +1736,7 @@ class GedcomParser: else: self.backup() return data + return None def parse_date(self,level): date = DateStruct() @@ -1745,6 +1750,7 @@ class GedcomParser: date.time = matches[2] else: self.barf(level+1) + return None def extract_date(self,text): dateobj = Date.Date() @@ -1887,16 +1893,16 @@ def readData(database,active_person,cb): gtk.RESPONSE_CANCEL, gtk.STOCK_OPEN, gtk.RESPONSE_OK)) - filter = gtk.FileFilter() - filter.set_name(_('GEDCOM files')) - filter.add_pattern('*.ged') - filter.add_pattern('*.GED') - choose.add_filter(filter) + mime_filter = gtk.FileFilter() + mime_filter.set_name(_('GEDCOM files')) + mime_filter.add_pattern('*.ged') + mime_filter.add_pattern('*.GED') + choose.add_filter(mime_filter) - filter = gtk.FileFilter() - filter.set_name(_('All files')) - filter.add_pattern('*') - choose.add_filter(filter) + mime_filter = gtk.FileFilter() + mime_filter.set_name(_('All files')) + mime_filter.add_pattern('*') + choose.add_filter(mime_filter) response = choose.run() if response == gtk.RESPONSE_OK: diff --git a/src/ReadXML.py b/src/ReadXML.py index 375151174..acb8d31e9 100644 --- a/src/ReadXML.py +++ b/src/ReadXML.py @@ -31,7 +31,6 @@ import gtk import shutil import xml.parsers.expat from gettext import gettext as _ -import time #------------------------------------------------------------------------- # @@ -104,15 +103,14 @@ def importData(database, filename, callback=None,cl=0): os._exit(1) else: ErrorDialog(_("%s could not be opened") % filename,str(msg)) - return 0 + return except: if cl: print "Error: %s could not be opened. Exiting." % filename os._exit(1) else: ErrorDialog(_("%s could not be opened") % filename) - return 0 - + return try: parser.parse(xml_file) except IOError,msg: @@ -126,7 +124,7 @@ def importData(database, filename, callback=None,cl=0): ErrorDialog(_("Error reading %s") % filename,str(msg)) import traceback traceback.print_exc() - return 0 + return except xml.parsers.expat.ExpatError, msg: if cl: print "Error reading %s" % filename @@ -135,7 +133,7 @@ def importData(database, filename, callback=None,cl=0): else: ErrorDialog(_("Error reading %s") % filename, _("The file is probably either corrupt or not a valid GRAMPS database.")) - return 0 + return except: if cl: import traceback @@ -144,7 +142,7 @@ def importData(database, filename, callback=None,cl=0): else: import DisplayTrace DisplayTrace.DisplayTrace() - return 0 + return xml_file.close() @@ -414,7 +412,6 @@ class GrampsParser: "sauthor" : (None, self.stop_sauthor), "sabbrev" : (None, self.stop_sabbrev), "scomments" : (None, self.stop_scomments), - "sdate" : (None,self.stop_sdate), "source" : (self.start_source, self.stop_source), "sourceref" : (self.start_sourceref, self.stop_sourceref), "sources" : (None, None), @@ -494,45 +491,45 @@ class GrampsParser: self.gid2oid[gramps_id] = intid return obj - def map_gid(self,id): - if not self.idswap.get(id): - if self.db.get_person_from_gramps_id(id): - self.idswap[id] = self.db.find_next_person_gramps_id() + def map_gid(self,handle): + if not self.idswap.get(handle): + if self.db.get_person_from_gramps_id(handle): + self.idswap[handle] = self.db.find_next_person_gramps_id() else: - self.idswap[id] = id - return self.idswap[id] + self.idswap[handle] = handle + return self.idswap[handle] - def map_fid(self,id): - if not self.fidswap.get(id): - if self.db.get_family_from_gramps_id(id): - self.fidswap[id] = self.db.find_next_family_gramps_id() + def map_fid(self,handle): + if not self.fidswap.get(handle): + if self.db.get_family_from_gramps_id(handle): + self.fidswap[handle] = self.db.find_next_family_gramps_id() else: - self.fidswap[id] = id - return self.fidswap[id] + self.fidswap[handle] = handle + return self.fidswap[handle] - def map_pid(self,id): - if not self.pidswap.get(id): - if self.db.get_place_from_gramps_id(id): - self.pidswap[id] = self.db.find_next_place_gramps_id() + def map_pid(self,handle): + if not self.pidswap.get(handle): + if self.db.get_place_from_gramps_id(handle): + self.pidswap[handle] = self.db.find_next_place_gramps_id() else: - self.pidswap[id] = id - return self.pidswap[id] + self.pidswap[handle] = handle + return self.pidswap[handle] - def map_sid(self,id): - if not self.sidswap.get(id): - if self.db.get_source_from_gramps_id(id): - self.sidswap[id] = self.db.find_next_source_gramps_id() + def map_sid(self,handle): + if not self.sidswap.get(handle): + if self.db.get_source_from_gramps_id(handle): + self.sidswap[handle] = self.db.find_next_source_gramps_id() else: - self.sidswap[id] = id - return self.sidswap[id] + self.sidswap[handle] = handle + return self.sidswap[handle] - def map_oid(self,id): - if not self.oidswap.get(id): - if self.db.get_object_from_gramps_id(id): - self.oidswap[id] = self.db.find_next_object_gramps_id() + def map_oid(self,handle): + if not self.oidswap.get(handle): + if self.db.get_object_from_gramps_id(handle): + self.oidswap[handle] = self.db.find_next_object_gramps_id() else: - self.oidswap[id] = id - return self.oidswap[id] + self.oidswap[handle] = handle + return self.oidswap[handle] def parse(self,file): self.trans = self.db.transaction_begin() @@ -547,8 +544,8 @@ class GrampsParser: person = self.db.find_person_from_handle(self.home,self.trans) self.db.set_default_person_handle(person.get_handle()) if self.tempDefault != None: - id = self.map_gid(self.tempDefault) - person = self.find_person_by_gramps_id(id) + handle = self.map_gid(self.tempDefault) + person = self.find_person_by_gramps_id(handle) if person: self.db.set_default_person_handle(person.get_handle()) @@ -560,17 +557,17 @@ class GrampsParser: self.db.transaction_commit(self.trans,_("GRAMPS XML import")) def start_lds_ord(self,attrs): - type = attrs['type'] + atype = attrs['type'] self.ord = RelLib.LdsOrd() if self.person: - if type == "baptism": + if atype == "baptism": self.person.set_lds_baptism(self.ord) - elif type == "endowment": + elif atype == "endowment": self.person.set_lds_endowment(self.ord) - elif type == "sealed_to_parents": + elif atype == "sealed_to_parents": self.person.set_lds_sealing(self.ord) elif self.family: - if type == "sealed_to_spouse": + if atype == "sealed_to_spouse": self.family.set_lds_sealing(self.ord) def start_temple(self,attrs): @@ -583,24 +580,24 @@ class GrampsParser: try: family = self.db.find_family_from_handle(attrs['hlink'],self.trans) except KeyError: - id = self.map_fid(attrs['ref']) - family = self.find_family_by_gramps_id(id) + handle = self.map_fid(attrs['ref']) + family = self.find_family_by_gramps_id(handle) self.ord.set_family_handle(family.get_handle()) def start_place(self,attrs): try: self.placeobj = self.db.find_place_from_handle(attrs['hlink'],self.trans) except KeyError: - id = self.map_pid(attrs['ref']) - self.placeobj = self.find_place_by_gramps_id(id) + handle = self.map_pid(attrs['ref']) + self.placeobj = self.find_place_by_gramps_id(handle) def start_placeobj(self,attrs): - id = self.map_pid(attrs['id']) + handle = self.map_pid(attrs['id']) try: self.placeobj = self.db.find_place_from_handle(attrs['handle'],self.trans) - self.placeobj.set_gramps_id(id) + self.placeobj.set_gramps_id(handle) except KeyError: - self.placeobj = self.find_place_by_gramps_id(id) + self.placeobj = self.find_place_by_gramps_id(handle) title = attrs['title'] if title == "": title = attrs['id'] @@ -700,8 +697,8 @@ class GrampsParser: try: person = self.db.find_person_from_handle(attrs['hlink'],self.trans) except KeyError: - id = self.map_gid(attrs["ref"]) - person = self.find_person_by_gramps_id(id) + handle = self.map_gid(attrs["ref"]) + person = self.find_person_by_gramps_id(handle) self.db.bookmarks.append(person.get_handle()) def start_person(self,attrs): @@ -773,12 +770,12 @@ class GrampsParser: if self.callback != None and self.count % self.increment == 0: self.callback(float(self.count)/float(self.entries)) self.count = self.count + 1 - id = self.map_fid(attrs["id"]) + handle = self.map_fid(attrs["id"]) try: self.family = self.db.find_family_from_handle(attrs["handle"],self.trans) - self.family.set_gramps_id(id) + self.family.set_gramps_id(handle) except KeyError: - self.family = self.find_family_by_gramps_id(id) + self.family = self.find_family_by_gramps_id(handle) if attrs.has_key("type"): self.family.set_relationship(_FAMILY_TRANS.get(attrs["type"], @@ -875,12 +872,12 @@ class GrampsParser: self.person.add_source_reference(self.source_ref) def start_source(self,attrs): - id = self.map_sid(attrs["id"]) + handle = self.map_sid(attrs["id"]) try: self.source = self.db.find_source_from_handle(attrs["handle"],self.trans) - self.source.set_gramps_id(id) + self.source.set_gramps_id(handle) except KeyError: - self.source = self.find_source_by_gramps_id(id) + self.source = self.find_source_by_gramps_id(handle) def start_objref(self,attrs): self.objref = RelLib.MediaRef() @@ -889,9 +886,9 @@ class GrampsParser: except KeyError: obj = self.find_object_by_gramps_id(self.map_oid(attrs['ref'])) - id = obj.get_handle() + handle = obj.get_handle() - self.objref.set_reference_handle(id) + self.objref.set_reference_handle(handle) if attrs.has_key('priv'): self.objref.set_privacy(int(attrs['priv'])) if self.event: @@ -906,12 +903,12 @@ class GrampsParser: self.placeobj.add_media_reference(self.objref) def start_object(self,attrs): - id = self.map_oid(attrs['id']) + handle = self.map_oid(attrs['id']) try: self.object = self.db.find_object_from_handle(attrs['handle'],self.trans) - self.object.set_gramps_id(id) + self.object.set_gramps_id(handle) except KeyError: - self.object = self.find_object_by_gramps_id(id) + self.object = self.find_object_by_gramps_id(handle) self.object.set_mime_type(attrs['mime']) self.object.set_description(attrs['description']) src = attrs["src"] @@ -1214,11 +1211,6 @@ class GrampsParser: def stop_sauthor(self,tag): self.source.set_author(tag) - def stop_sdate(self,tag): - date = Date.Date() - date.set(tag) - self.source_ref.set_date(date) - def stop_phone(self,tag): self.address.set_phone(tag) diff --git a/src/SelectChild.py b/src/SelectChild.py index d6ae1183d..ff0168195 100644 --- a/src/SelectChild.py +++ b/src/SelectChild.py @@ -45,7 +45,6 @@ import RelLib import const import Utils import PeopleModel -from RelLib import Person from QuestionDialog import ErrorDialog #------------------------------------------------------------------------- @@ -275,9 +274,9 @@ class SelectChild: if not idlist or not idlist[0]: return - id = idlist[0] - select_child = self.db.get_person_from_handle(id) - if self.person.get_handle() == id: + handle = idlist[0] + select_child = self.db.get_person_from_handle(handle) + if self.person.get_handle() == handle: ErrorDialog(_("Error selecting a child"), _("A person cannot be linked as his/her own child"), self.top) @@ -294,7 +293,7 @@ class SelectChild: else: self.family.set_mother_handle(self.person) - if id in (self.family.get_father_handle(),self.family.get_mother_handle()): + if handle in (self.family.get_father_handle(),self.family.get_mother_handle()): ErrorDialog(_("Error selecting a child"), _("A person cannot be linked as his/her own child"), self.top) @@ -310,7 +309,7 @@ class SelectChild: frel = const.child_relations.find_value(self.frel.get_text()) father = self.db.get_person_from_handle(self.family.get_father_handle()) - if father and father.get_gender() !=RelLib. Person.male: + if father and father.get_gender() !=RelLib.Person.male: if frel == "Birth": frel = "Unknown" @@ -328,7 +327,7 @@ class SelectChild: self.redraw_child_list(not obj.get_active()) def north_american(self,val): - if self.person.get_gender() == Person.male: + if self.person.get_gender() == RelLib.Person.male: return self.person.get_primary_name().get_surname() elif self.family: f = self.family.get_father_handle() @@ -359,7 +358,7 @@ class SelectChild: def icelandic(self,val): fname = "" - if self.person.get_gender() == Person.male: + if self.person.get_gender() == RelLib.Person.male: fname = self.person.get_primary_name().get_first_name() elif self.family: f = self.family.get_father_handle() @@ -446,7 +445,7 @@ class EditRel: frel = const.child_relations.find_value(self.fentry.get_text()) father = self.db.get_person_from_handle(self.family.get_father_handle()) - if father and father.get_gender() !=RelLib. Person.male: + if father and father.get_gender() !=RelLib.Person.male: if frel == "Birth": frel = "Unknown" diff --git a/src/SelectObject.py b/src/SelectObject.py index 959bf2ebb..bab825637 100644 --- a/src/SelectObject.py +++ b/src/SelectObject.py @@ -30,7 +30,6 @@ # general modules # #------------------------------------------------------------------------- -import string import os #------------------------------------------------------------------------- @@ -55,7 +54,6 @@ import gtk.gdk # gramps modules # #------------------------------------------------------------------------- -import RelLib import const import Utils import ListModel @@ -101,7 +99,6 @@ class SelectObject: for key in self.db.get_media_object_handles(): 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,obj.get_gramps_id(),the_type,path],key) diff --git a/src/SelectPerson.py b/src/SelectPerson.py index 2e881f139..1a7a1ef99 100644 --- a/src/SelectPerson.py +++ b/src/SelectPerson.py @@ -41,7 +41,6 @@ import gtk.glade # gramps modules # #------------------------------------------------------------------------- -import RelLib import const import Utils import PeopleModel diff --git a/src/Sort.py b/src/Sort.py index a09372555..5716d1e41 100644 --- a/src/Sort.py +++ b/src/Sort.py @@ -93,7 +93,7 @@ class Sort: else: date2 = Date.Date() - val = Date.compare_dates(date1,date2) + val = date1.is_equal(date2) if val == 0: return self.by_last_name(first_id,second_id) return val diff --git a/src/SourceView.py b/src/SourceView.py index eaedbdca7..15fc0b0b4 100644 --- a/src/SourceView.py +++ b/src/SourceView.py @@ -25,7 +25,6 @@ # GTK/Gnome modules # #------------------------------------------------------------------------- -import gobject import gtk import gtk.gdk @@ -36,7 +35,6 @@ import gtk.gdk #------------------------------------------------------------------------- import RelLib import EditSource -import Utils import DisplayModels import const diff --git a/src/Utils.py b/src/Utils.py index 1748c3cb5..f576a8184 100644 --- a/src/Utils.py +++ b/src/Utils.py @@ -508,7 +508,7 @@ def roman(num): rnum = romans[num] return rnum else: - return + return '?' #------------------------------------------------------------------------- # diff --git a/src/Witness.py b/src/Witness.py index 6d213c38f..b97a4e1da 100644 --- a/src/Witness.py +++ b/src/Witness.py @@ -25,7 +25,6 @@ # GTK/Gnome modules # #------------------------------------------------------------------------- -import gobject import gtk import gtk.glade import gnome @@ -89,8 +88,8 @@ class WitnessTab: self.parent.lists_changed = 1 def edit_clicked(self,obj): - store,iter = self.selection.get_selected() - if iter: + store,node = self.selection.get_selected() + if node: objs = self.model.get_selected_objects() src = objs[0] WitnessEditor(src,self.db,self,self.update_clist,self.window) @@ -104,9 +103,9 @@ class WitnessTab: inst.redraw() def del_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() diff --git a/src/WriteGedcom.py b/src/WriteGedcom.py index 3f5ae3c91..3da76b882 100644 --- a/src/WriteGedcom.py +++ b/src/WriteGedcom.py @@ -38,7 +38,6 @@ import re #------------------------------------------------------------------------- import gtk import gtk.glade -import gnome #------------------------------------------------------------------------- # @@ -48,7 +47,6 @@ import gnome import RelLib import GenericFilter import const -import Utils import Date import GedcomInfo import Errors @@ -56,8 +54,6 @@ import ansel_utf8 from gettext import gettext as _ from QuestionDialog import ErrorDialog -_title_string = _("Export to GEDCOM") - def keep_utf8(s): return s @@ -614,35 +610,23 @@ class GedcomWriter: sorted = [] for key in pkeys: person = self.db.get_person_from_handle (key) - tuple = (person.get_gramps_id (), person) - sorted.append (tuple) + data = (person.get_gramps_id (), person) + sorted.append (data) sorted.sort() - nump = float(len(self.plist)) index = 0.0 for (gramps_id, person) in sorted: self.write_person(person) index = index + 1 - #if index%100 == 0 and not self.cl: - # self.pbar.set_fraction(index/nump) - # while(gtk.events_pending()): - # gtk.mainiteration() -# if not self.cl: -# self.pbar.set_fraction(1.0) self.write_families() if self.source_refs: self.write_sources() - #else: - # if not self.cl: - # self.sbar.set_fraction(1.0) self.writeln("0 TRLR") self.g.close() return 1 def write_copy(self): - import time - t = time.localtime(time.time()) y = t[0] @@ -654,8 +638,6 @@ class GedcomWriter: self.writeln('1 COPR Copyright (c) %d %s. See additional copyright NOTE below.' % (y,o)) def gnu_fdl(self): - import time - if self.copy != 1: return @@ -673,13 +655,11 @@ class GedcomWriter: pass def write_families(self): - nump = float(len(self.flist)) - index = 0.0 sorted = [] for family_handle in self.flist.keys (): family = self.db.get_family_from_handle(family_handle) - tuple = (self.fid (family_handle), family_handle, family) - sorted.append (tuple) + data = (self.fid (family_handle), family_handle, family) + sorted.append (data) sorted.sort () for (gramps_id, family_handle, family) in sorted: father_alive = mother_alive = 0 @@ -745,22 +725,13 @@ class GedcomWriter: self.write_change(1,family.get_change_time()) -# index = index + 1 -# if index % 100 == 0 and not self.cl: -# self.fbar.set_fraction(index/nump) -# while(gtk.events_pending()): -# gtk.mainiteration() - #if not self.cl: - # self.fbar.set_fraction(1.0) - def write_sources(self): - nump = float(len(self.slist)) index = 0.0 sorted = [] for key in self.slist.keys(): source = self.db.get_source_from_handle(key) - tuple = (self.sid (source.get_gramps_id ()), source) - sorted.append (tuple) + data = (self.sid (source.get_gramps_id ()), source) + sorted.append (data) sorted.sort () for (source_id, source) in sorted: self.writeln("0 @%s@ SOUR" % source_id) @@ -777,13 +748,6 @@ class GedcomWriter: index = index + 1 self.write_change(1,source.get_change_time()) -# if index % 100 == 0 and not self.cl: -# self.sbar.set_fraction(index/nump) -# while(gtk.events_pending()): -# gtk.mainiteration() -# if not self.cl: -# self.sbar.set_fraction(1.0) - def write_person(self,person): self.writeln("0 @%s@ INDI" % person.get_gramps_id()) restricted = self.restrict and person.probably_alive (self.db) @@ -975,7 +939,7 @@ class GedcomWriter: dest = os.path.join (dirname, basename) try: os.link (path, dest) - except OSError, e: + except OSError: file (dest, "wb").writelines (file (path, "rb").xreadlines ()) @@ -1009,7 +973,6 @@ class GedcomWriter: def write_change(self,level,timeval): - tval = time.localtime(timeval) self.writeln('%d CHAN' % level) time_val = time.localtime(timeval) self.writeln('%d DATE %d %s %d' % (level + 1,time_val[2], diff --git a/src/WriteXML.py b/src/WriteXML.py index 4316742e9..3ea5552f0 100644 --- a/src/WriteXML.py +++ b/src/WriteXML.py @@ -245,8 +245,8 @@ class XmlWriter: sorted_keys = [] for key in keys: person = self.db.get_person_from_handle (key) - tuple = (person.get_gramps_id (), person) - sorted_keys.append (tuple) + value = (person.get_gramps_id (), person) + sorted_keys.append (value) sorted_keys.sort () for (gramps_id, person) in sorted_keys: @@ -330,8 +330,8 @@ class XmlWriter: sorted_keys = [] for key in keys: family = self.db.get_family_from_handle(key) - tuple = (family.get_gramps_id (), family) - sorted_keys.append (tuple) + value = (family.get_gramps_id (), family) + sorted_keys.append (value) sorted_keys.sort () for (gramps_id, family) in sorted_keys: @@ -409,8 +409,8 @@ class XmlWriter: sorted_keys = [] for key in keys: obj = self.db.get_object_from_handle (key) - tuple = (obj.get_gramps_id (), obj) - sorted_keys.append (tuple) + value = (obj.get_gramps_id (), obj) + sorted_keys.append (value) sorted_keys.sort () for (gramps_id, obj) in sorted_keys: @@ -714,7 +714,7 @@ class XmlWriter: state = self.fix(loc.get_state()) country = self.fix(loc.get_country()) county = self.fix(loc.get_county()) - zip = self.fix(loc.get_postal_code()) + zip_code = self.fix(loc.get_postal_code()) phone = self.fix(loc.get_phone()) self.g.write(' \n') @@ -781,9 +781,9 @@ class XmlWriter: def write_place_obj(self,place): title = self.fix(place.get_title()) - long = self.fix(place.get_longitude()) + longitude = self.fix(place.get_longitude()) lat = self.fix(place.get_latitude()) - id = place.get_gramps_id() + handle = place.get_gramps_id() main_loc = place.get_main_location() llen = len(place.get_alternate_locations()) + len(place.get_url_list()) + \ len(place.get_media_list()) + len(place.get_source_references()) @@ -795,16 +795,16 @@ class XmlWriter: title = self.fix(self.build_place_title(place.get_main_location())) self.g.write(' 0 or note: + if longitude or lat or not ml_empty or llen > 0 or note: self.g.write('>\n') else: self.g.write('/>\n') return - if long or lat: - self.g.write(' \n' % (long,lat)) + if longitude or lat: + self.g.write(' \n' % (longitude,lat)) self.dump_location(main_loc) for loc in place.get_alternate_locations(): @@ -818,7 +818,7 @@ class XmlWriter: self.g.write(" \n") def write_object(self,obj): - id = obj.get_gramps_id() + handle = obj.get_gramps_id() mime_type = obj.get_mime_type() path = obj.get_path() if self.strip_photos: @@ -829,7 +829,7 @@ class XmlWriter: if self.fileroot == path[0:l]: path = path[l+1:] self.g.write('