From 39368e4eb67cff4cb054c9f4b1fd17cdbce29186 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Tue, 9 Jan 2007 04:32:07 +0000 Subject: [PATCH] * src/DataViews/_MediaView.py: pylint * src/DataViews/_RepositoryView.py: pylint * src/DataViews/_SourceView.py: pylint * src/DataViews/_EventView.py: pylint * src/DataViews/_FamilyList.py: pylint * src/DataViews/_PlaceView.py: pylint * src/DataViews/__init__.py: pylint * src/DataViews/_PersonView.py: pylint * src/DataViews/Makefile.am: pylint * src/DataViews/_RelationView.py: pylint * src/RelLib/_CalSdn.py: pylint * src/RelLib/_Person.py: pylint * src/RelLib/_Family.py: pylint * src/RelLib/_EventType.py: pylint * src/RelLib/_GrampsType.py: pylint * src/RelLib/_Event.py: pylint * src/RelLib/_LdsOrd.py: pylint * src/PageView.py: pylint svn: r7885 --- ChangeLog | 19 +++ src/DataViews/Makefile.am | 6 +- src/DataViews/_EventView.py | 103 ++++++------ src/DataViews/_FamilyList.py | 71 ++++----- src/DataViews/_MediaView.py | 99 +++++------- src/DataViews/_PersonView.py | 266 +++++++++++++++++-------------- src/DataViews/_PlaceView.py | 81 ++++------ src/DataViews/_RelationView.py | 95 ++++++----- src/DataViews/_RepositoryView.py | 57 +++---- src/DataViews/_SourceView.py | 59 +++---- src/DataViews/__init__.py | 10 ++ src/PageView.py | 19 +++ src/RelLib/_CalSdn.py | 32 ++-- src/RelLib/_Event.py | 29 ++++ src/RelLib/_EventType.py | 4 +- src/RelLib/_Family.py | 29 ++++ src/RelLib/_GrampsType.py | 6 + src/RelLib/_LdsOrd.py | 12 ++ src/RelLib/_Person.py | 11 ++ 19 files changed, 579 insertions(+), 429 deletions(-) diff --git a/ChangeLog b/ChangeLog index b199e145f..a59d50c8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,23 @@ 2007-01-08 Don Allingham + + * src/DataViews/_MediaView.py: pylint + * src/DataViews/_RepositoryView.py: pylint + * src/DataViews/_SourceView.py: pylint + * src/DataViews/_EventView.py: pylint + * src/DataViews/_FamilyList.py: pylint + * src/DataViews/_PlaceView.py: pylint + * src/DataViews/__init__.py: pylint + * src/DataViews/_PersonView.py: pylint + * src/DataViews/Makefile.am: pylint + * src/DataViews/_RelationView.py: pylint + * src/RelLib/_CalSdn.py: pylint + * src/RelLib/_Person.py: pylint + * src/RelLib/_Family.py: pylint + * src/RelLib/_EventType.py: pylint + * src/RelLib/_GrampsType.py: pylint + * src/RelLib/_Event.py: pylint + * src/RelLib/_LdsOrd.py: pylint + * src/PageView.py: pylint * src/Filters/Rules/Place/__init__.py: add HasPlace to editor_rule_list * src/RelLib/_Name.py: default utf8 strings * src/RelLib/_MarkerType.py: default utf8 strings diff --git a/src/DataViews/Makefile.am b/src/DataViews/Makefile.am index 53377ac6c..c4a4e5ba1 100644 --- a/src/DataViews/Makefile.am +++ b/src/DataViews/Makefile.am @@ -15,9 +15,10 @@ pkgdata_PYTHON = \ _SourceView.py\ _PlaceView.py\ _MediaView.py\ - _MapView.py\ _RepositoryView.py +# _MapView.py + pkgpyexecdir = @pkgpyexecdir@/DataViews pkgpythondir = @pkgpythondir@/DataViews @@ -29,3 +30,6 @@ GRAMPS_PY_MODPATH = "../" pycheck: (export PYTHONPATH=$(GRAMPS_PY_MODPATH); \ pychecker $(pkgdata_PYTHON)); + +pylint: + PYTHONPATH=$(GRAMPS_PY_MODPATH) pylint $(pkgdata_PYTHON) > pylint.out diff --git a/src/DataViews/_EventView.py b/src/DataViews/_EventView.py index fb0bea459..f5c95fcbe 100644 --- a/src/DataViews/_EventView.py +++ b/src/DataViews/_EventView.py @@ -19,6 +19,13 @@ # $Id$ +""" +Provides the event view +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision$" + #------------------------------------------------------------------------- # # gramps modules @@ -59,12 +66,19 @@ column_names = [ # #------------------------------------------------------------------------- class EventView(PageView.ListView): + """ + EventView class, derived from the ListView + """ - ADD_MSG = _("Add a new event") - EDIT_MSG = _("Edit the selected event") - DEL_MSG = _("Delete the selected event") + ADD_MSG = _("Add a new event") + EDIT_MSG = _("Edit the selected event") + DEL_MSG = _("Delete the selected event") + FILTER_TYPE = "Event" - def __init__(self,dbstate,uistate): + def __init__(self, dbstate, uistate): + """ + Create the Event View + """ signal_map = { 'event-add' : self.row_add, @@ -83,18 +97,33 @@ class EventView(PageView.ListView): self.filter_toggle) def get_bookmarks(self): + """ + Returns the bookmark object + """ return self.dbstate.db.get_event_bookmarks() def drag_info(self): + """ + Indicates that the drag type is an EVENT + """ return DdTargets.EVENT def column_order(self): + """ + returns a tuple indicating the column order + """ return self.dbstate.db.get_event_column_order() def get_stock(self): + """ + Use the gramps-event stock icon + """ return 'gramps-event' def ui_definition(self): + """ + Defines the UI string for UIManager + """ return ''' @@ -132,26 +161,7 @@ class EventView(PageView.ListView): self.add_action('FilterEdit', None, _('Event Filter Editor'), callback=self.filter_editor,) - def filter_toggle(self, client, cnxn_id, etnry, data): - if Config.get(Config.FILTER): - self.search_bar.hide() - self.filter_pane.show() - active = True - else: - self.search_bar.show() - self.filter_pane.hide() - active = False - - def filter_editor(self,obj): - from FilterEditor import FilterEditor - - try: - FilterEditor('Event',const.custom_filters, - self.dbstate,self.uistate) - except Errors.WindowActiveError: - pass - - def column_editor(self,obj): + def column_editor(self, obj): import ColumnOrder ColumnOrder.ColumnOrder( @@ -161,38 +171,41 @@ class EventView(PageView.ListView): column_names, self.set_column_order) - def set_column_order(self,list): - self.dbstate.db.set_event_column_order(list) + def set_column_order(self, clist): + self.dbstate.db.set_event_column_order(clist) self.build_columns() - def on_double_click(self,obj,event): + def on_double_click(self, obj, event): handle = self.first_selected() the_event = self.dbstate.db.get_event_from_handle(handle) try: - EditEvent(the_event,self.dbstate, self.uistate, []) + EditEvent(the_event, self.dbstate, self.uistate, []) except Errors.WindowActiveError: pass - def add(self,obj): + def add(self, obj): try: - EditEvent(RelLib.Event(),self.dbstate, self.uistate, []) + EditEvent(RelLib.Event(), self.dbstate, self.uistate, []) except Errors.WindowActiveError: pass - def remove(self,obj): - for event_handle in self.selected_handles(): + def remove(self, obj): + for ehandle in self.selected_handles(): db = self.dbstate.db - person_list = [ handle for handle in - db.get_person_handles(False) - if db.get_person_from_handle(handle).has_handle_reference('Event',event_handle) ] - family_list = [ handle for handle in - db.get_family_handles() - if db.get_family_from_handle(handle).has_handle_reference('Event',event_handle) ] + person_list = [ + h for h in + db.get_person_handles(False) + if db.get_person_from_handle(h).has_handle_reference('Event', + ehandle) ] + family_list = [ + h for h in + db.get_family_handles() + if db.get_family_from_handle(h).has_handle_reference('Event', + ehandle) ] - event = db.get_event_from_handle(event_handle) + event = db.get_event_from_handle(ehandle) - ans = DelEventQuery(event,db, - person_list,family_list) + ans = DelEventQuery(event, db, person_list, family_list) if len(person_list) + len(family_list) > 0: msg = _('This event is currently being used. Deleting it ' @@ -201,17 +214,17 @@ class EventView(PageView.ListView): else: msg = _('Deleting event will remove it from the database.') - msg = "%s %s" % (msg,Utils.data_recover_msg) + msg = "%s %s" % (msg, Utils.data_recover_msg) descr = event.get_description() if descr == "": descr = event.get_gramps_id() QuestionDialog(_('Delete %s?') % descr, msg, - _('_Delete Event'),ans.query_response) + _('_Delete Event'), ans.query_response) - def edit(self,obj): + def edit(self, obj): mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) for handle in mlist: event = self.dbstate.db.get_event_from_handle(handle) diff --git a/src/DataViews/_FamilyList.py b/src/DataViews/_FamilyList.py index bb8464628..14e991fb3 100644 --- a/src/DataViews/_FamilyList.py +++ b/src/DataViews/_FamilyList.py @@ -19,6 +19,13 @@ # $Id$ +""" +FamilyList View +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision$" + #------------------------------------------------------------------------- # # gramps modules @@ -56,11 +63,12 @@ column_names = [ #------------------------------------------------------------------------- class FamilyListView(PageView.ListView): - ADD_MSG = _("Add a new family") - EDIT_MSG = _("Edit the selected family") - DEL_MSG = _("Delete the selected family") - - def __init__(self,dbstate,uistate): + ADD_MSG = _("Add a new family") + EDIT_MSG = _("Edit the selected family") + DEL_MSG = _("Delete the selected family") + FILTER_TYPE = "Family" + + def __init__(self, dbstate, uistate): signal_map = { 'family-add' : self.family_add, @@ -81,7 +89,9 @@ class FamilyListView(PageView.ListView): self.filter_toggle) def define_actions(self): - # add the Forward action group to handle the Forward button + """ + add the Forward action group to handle the Forward button + """ PageView.ListView.define_actions(self) self.add_action('ColumnEdit', gtk.STOCK_PROPERTIES, @@ -90,25 +100,6 @@ class FamilyListView(PageView.ListView): self.add_action('FilterEdit', None, _('Family Filter Editor'), callback=self.filter_editor,) - def filter_toggle(self, client, cnxn_id, etnry, data): - if Config.get(Config.FILTER): - self.search_bar.hide() - self.filter_pane.show() - active = True - else: - self.search_bar.show() - self.filter_pane.hide() - active = False - - def filter_editor(self,obj): - from FilterEditor import FilterEditor - - try: - FilterEditor('Family',const.custom_filters, - self.dbstate,self.uistate) - except Errors.WindowActiveError: - pass - def add_bookmark(self, obj): mlist = [] self.selection.selected_foreach(self.blist, mlist) @@ -128,7 +119,7 @@ class FamilyListView(PageView.ListView): def column_order(self): return self.dbstate.db.get_family_list_column_order() - def column_editor(self,obj): + def column_editor(self, obj): import ColumnOrder ColumnOrder.ColumnOrder( @@ -138,8 +129,8 @@ class FamilyListView(PageView.ListView): column_names, self.set_column_order) - def set_column_order(self,list): - self.dbstate.db.set_family_list_column_order(list) + def set_column_order(self, clist): + self.dbstate.db.set_family_list_column_order(clist) self.build_columns() def get_stock(self): @@ -178,27 +169,27 @@ class FamilyListView(PageView.ListView): ''' - def add(self,obj): + def add(self, obj): from Editors import EditFamily family = RelLib.Family() try: - EditFamily(self.dbstate,self.uistate,[],family) + EditFamily(self.dbstate, self.uistate, [], family) except Errors.WindowActiveError: pass - def family_add(self,handle_list): + def family_add(self, handle_list): while not self.family_add_loop(handle_list): pass - def family_update(self,handle_list): + def family_update(self, handle_list): while not self.family_update_loop(handle_list): pass - def family_delete(self,handle_list): + def family_delete(self, handle_list): while not self.family_delete_loop(handle_list): pass - def family_add_loop(self,handle_list): + def family_add_loop(self, handle_list): if self.updating: return False self.updating = True @@ -206,7 +197,7 @@ class FamilyListView(PageView.ListView): self.updating = False return True - def family_update_loop(self,handle_list): + def family_update_loop(self, handle_list): if self.updating: return False self.updating = True @@ -214,7 +205,7 @@ class FamilyListView(PageView.ListView): self.updating = False return True - def family_delete_loop(self,handle_list): + def family_delete_loop(self, handle_list): if self.updating: return False self.updating = True @@ -222,7 +213,7 @@ class FamilyListView(PageView.ListView): self.updating = False return True - def remove(self,obj): + def remove(self, obj): import GrampsDb mlist = [] @@ -232,14 +223,14 @@ class FamilyListView(PageView.ListView): GrampsDb.remove_family_relationships(self.dbstate.db, handle) self.build_tree() - def edit(self,obj): + def edit(self, obj): mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) for handle in mlist: from Editors import EditFamily family = self.dbstate.db.get_family_from_handle(handle) try: - EditFamily(self.dbstate,self.uistate,[],family) + EditFamily(self.dbstate, self.uistate, [], family) except Errors.WindowActiveError: pass diff --git a/src/DataViews/_MediaView.py b/src/DataViews/_MediaView.py index fbaa3cf76..2eed9109a 100644 --- a/src/DataViews/_MediaView.py +++ b/src/DataViews/_MediaView.py @@ -19,6 +19,13 @@ # $Id$ +""" +Media View +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision$" + #------------------------------------------------------------------------- # # Python modules @@ -73,13 +80,14 @@ column_names = [ #------------------------------------------------------------------------- class MediaView(PageView.ListView): - ADD_MSG = _("Add a new media object") - EDIT_MSG = _("Edit the selected media object") - DEL_MSG = _("Delete the selected media object") + ADD_MSG = _("Add a new media object") + EDIT_MSG = _("Edit the selected media object") + DEL_MSG = _("Delete the selected media object") + FILTER_TYPE = 'MediaObject' _DND_TYPE = DdTargets.URI_LIST - def __init__(self,dbstate,uistate): + def __init__(self, dbstate, uistate): signal_map = { 'media-add' : self.row_add, @@ -92,7 +100,7 @@ class MediaView(PageView.ListView): self, _('Media'), dbstate, uistate, column_names,len(column_names), DisplayModels.MediaModel, signal_map, dbstate.db.get_media_bookmarks(), - Bookmarks.MediaBookmarks,filter_class=MediaSidebarFilter) + Bookmarks.MediaBookmarks, filter_class=MediaSidebarFilter) Config.client.notify_add("/apps/gramps/interface/filter", self.filter_toggle) @@ -132,7 +140,7 @@ class MediaView(PageView.ListView): selected_ids = self.selected_handles() if selected_ids: data = (self.drag_info().drag_type, id(self), selected_ids[0], 0) - sel_data.set(sel_data.target, 8 ,pickle.dumps(data)) + sel_data.set(sel_data.target, 8, pickle.dumps(data)) def drag_info(self): return DdTargets.MEDIAOBJ @@ -153,7 +161,7 @@ class MediaView(PageView.ListView): if sel_data and sel_data.data: d = Utils.fix_encoding(sel_data.data.replace('\0',' ').strip()) - protocol,site,mfile,j,k,l = urlparse.urlparse(d) + protocol, site, mfile, j, k, l = urlparse.urlparse(d) if protocol == "file": name = Utils.fix_encoding(mfile) mime = Mime.get_type(name) @@ -163,7 +171,7 @@ class MediaView(PageView.ListView): photo.set_path(name) photo.set_mime_type(mime) basename = os.path.basename(name) - (root,ext) = os.path.splitext(basename) + (root, ext) = os.path.splitext(basename) photo.set_description(root) trans = self.dbstate.db.transaction_begin() self.dbstate.db.add_object(photo, trans) @@ -185,35 +193,16 @@ class MediaView(PageView.ListView): def view_media(self, obj): mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) for handle in mlist: ref_obj = self.dbstate.db.get_object_from_handle(handle) mime_type = ref_obj.get_mime_type() app = Mime.get_application(mime_type) if app: - Utils.launch(app[0],ref_obj.get_path()) + Utils.launch(app[0], ref_obj.get_path()) - def filter_toggle(self, client, cnxn_id, etnry, data): - if Config.get(Config.FILTER): - self.search_bar.hide() - self.filter_pane.show() - active = True - else: - self.search_bar.show() - self.filter_pane.hide() - active = False - - def filter_editor(self,obj): - from FilterEditor import FilterEditor - - try: - FilterEditor('MediaObject',const.custom_filters, - self.dbstate,self.uistate) - except Errors.WindowActiveError: - pass - - def column_editor(self,obj): + def column_editor(self, obj): import ColumnOrder ColumnOrder.ColumnOrder( @@ -223,8 +212,8 @@ class MediaView(PageView.ListView): column_names, self.set_column_order) - def set_column_order(self,list): - self.dbstate.db.set_media_column_order(list) + def set_column_order(self, clist): + self.dbstate.db.set_media_column_order(clist) self.build_columns() def column_order(self): @@ -251,15 +240,15 @@ class MediaView(PageView.ListView): self.tt = gtk.Tooltips() self.tt.set_tip(ebox, _('Double click image to view in an external viewer')) - self.selection.connect('changed',self.row_change) + self.selection.connect('changed', self.row_change) self._set_dnd() return vbox def button_press_event(self, obj, event): - if event.button==1 and event.type == gtk.gdk._2BUTTON_PRESS: + if event.button == 1 and event.type == gtk.gdk._2BUTTON_PRESS: self.view_media(obj) - def row_change(self,obj): + def row_change(self, obj): handle = self.first_selected() if not handle: try: @@ -310,44 +299,44 @@ class MediaView(PageView.ListView): ''' - def add(self,obj): + def add(self, obj): """Add a new media object to the media list""" import AddMedia am = AddMedia.AddMediaObject(self.dbstate, self.uistate, []) am.run() - def remove(self,obj): + def remove(self, obj): handle = self.first_selected() if not handle: return - the_lists = Utils.get_media_referents(handle,self.dbstate.db) + the_lists = Utils.get_media_referents(handle, self.dbstate.db) - ans = DeleteMediaQuery(handle,self.dbstate.db,the_lists) - if filter(None,the_lists): # quick test for non-emptiness + ans = DeleteMediaQuery(handle, self.dbstate.db, the_lists) + if filter(None, the_lists): # quick test for non-emptiness msg = _('This media object is currently being used. ' 'If you delete this object, it will be removed from ' 'the database and from all records that reference it.') else: msg = _('Deleting media object will remove it from the database.') - msg = "%s %s" % (msg,Utils.data_recover_msg) - QuestionDialog(_('Delete Media Object?'),msg, - _('_Delete Media Object'),ans.query_response) + msg = "%s %s" % (msg, Utils.data_recover_msg) + QuestionDialog(_('Delete Media Object?'), msg, + _('_Delete Media Object'), ans.query_response) - def edit(self,obj): + def edit(self, obj): handle = self.first_selected() if not handle: return obj = self.dbstate.db.get_object_from_handle(handle) try: - EditMedia(self.dbstate,self.uistate, [], obj) + EditMedia(self.dbstate, self.uistate, [], obj) except Errors.WindowActiveError: pass class DeleteMediaQuery: - def __init__(self,media_handle,db,the_lists): + def __init__(self, media_handle, db, the_lists): self.db = db self.media_handle = media_handle self.the_lists = the_lists @@ -356,44 +345,44 @@ class DeleteMediaQuery: trans = self.db.transaction_begin() self.db.disable_signals() - (person_list,family_list,event_list, - place_list,source_list) = self.the_lists + (person_list, family_list, event_list, + place_list, source_list) = self.the_lists for handle in person_list: person = self.db.get_person_from_handle(handle) new_list = [ photo for photo in person.get_media_list() \ if photo.get_reference_handle() != self.media_handle ] person.set_media_list(new_list) - self.db.commit_person(person,trans) + self.db.commit_person(person, trans) for handle in family_list: family = self.db.get_family_from_handle(handle) new_list = [ photo for photo in family.get_media_list() \ if photo.get_reference_handle() != self.media_handle ] family.set_media_list(new_list) - self.db.commit_family(family,trans) + self.db.commit_family(family, trans) for handle in event_list: event = self.db.get_event_from_handle(handle) new_list = [ photo for photo in event.get_media_list() \ if photo.get_reference_handle() != self.media_handle ] event.set_media_list(new_list) - self.db.commit_event(event,trans) + self.db.commit_event(event, trans) for handle in place_list: place = self.db.get_place_from_handle(handle) new_list = [ photo for photo in place.get_media_list() \ if photo.get_reference_handle() != self.media_handle ] place.set_media_list(new_list) - self.db.commit_place(place,trans) + self.db.commit_place(place, trans) for handle in source_list: source = self.db.get_source_from_handle(handle) new_list = [ photo for photo in source.get_media_list() \ if photo.get_reference_handle() != self.media_handle ] source.set_media_list(new_list) - self.db.commit_source(source,trans) + self.db.commit_source(source, trans) self.db.enable_signals() - self.db.remove_object(self.media_handle,trans) - self.db.transaction_commit(trans,_("Remove Media Object")) + self.db.remove_object(self.media_handle, trans) + self.db.transaction_commit(trans, _("Remove Media Object")) diff --git a/src/DataViews/_PersonView.py b/src/DataViews/_PersonView.py index 512136145..d1afddf4a 100644 --- a/src/DataViews/_PersonView.py +++ b/src/DataViews/_PersonView.py @@ -20,6 +20,13 @@ # $Id$ +""" +PersonView interface +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision$" + #------------------------------------------------------------------------ # # standard python modules @@ -31,7 +38,7 @@ import cPickle as pickle try: set() -except: +except NameError: from sets import Set as set #------------------------------------------------------------------------- @@ -77,12 +84,18 @@ column_names = [ ] class PersonView(PageView.PersonNavView): + """ + PersonView interface + """ - def __init__(self,dbstate,uistate): + def __init__(self, dbstate, uistate): + """ + Creates the new PersonView interface, with the current dbstate and uistate + """ PageView.PersonNavView.__init__(self, _('People'), dbstate, uistate) self.inactive = False - dbstate.connect('database-changed',self.change_db) + dbstate.connect('database-changed', self.change_db) self.handle_col = PeopleModel.COLUMN_INT_ID self.model = None self.generic_filter = None @@ -132,18 +145,27 @@ class PersonView(PageView.PersonNavView): self.edit_action = gtk.ActionGroup(self.title + "/PersonEdit") self.all_action.add_actions([ - ('OpenAllNodes', None, _("Expand all nodes"), None, None, self.open_all_nodes), - ('Edit', gtk.STOCK_EDIT, _("_Edit"), None, _("Edit the selected person"), self.edit), - ('CloseAllNodes', None, _("Collapse all nodes"), None, None, self.close_all_nodes), + ('OpenAllNodes', None, _("Expand all nodes"), None, None, + self.open_all_nodes), + ('Edit', gtk.STOCK_EDIT, _("_Edit"), None, + _("Edit the selected person"), self.edit), + ('CloseAllNodes', None, _("Collapse all nodes"), None, None, + self.close_all_nodes), ('Jump', None, _("_Jump"),"j", None, self.jumpto), ]) - self.edit_action.add_actions([ - ('Add', gtk.STOCK_ADD, _("_Add"), None, _("Add a new person"), self.add), - ('Remove', gtk.STOCK_REMOVE, _("_Remove"), None, _("Remove the selected person"), self.remove), - ('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), None, None, self.column_editor), - ('CmpMerge', None, _('_Compare and merge'), None, None, self.cmp_merge), - ('FastMerge', None, _('_Fast merge'), None, None, self.fast_merge), + self.edit_action.add_actions( + [ + ('Add', gtk.STOCK_ADD, _("_Add"), None, _("Add a new person"), + self.add), + ('Remove', gtk.STOCK_REMOVE, _("_Remove"), None, + _("Remove the selected person"), self.remove), + ('ColumnEdit', gtk.STOCK_PROPERTIES, _('_Column Editor'), None, + None, self.column_editor), + ('CmpMerge', None, _('_Compare and merge'), None, None, + self.cmp_merge), + ('FastMerge', None, _('_Fast merge'), None, None, + self.fast_merge), ]) self.add_action_group(self.edit_action) @@ -172,11 +194,11 @@ class PersonView(PageView.PersonNavView): "control key while clicking on the desired person.")) else: import Merge - p1 = self.db.get_person_from_handle(mlist[0]) - p2 = self.db.get_person_from_handle(mlist[1]) - if p1 and p2: - Merge.PersonCompare(self.dbstate, self.uistate, p1, p2, - self.build_tree) + person1 = self.db.get_person_from_handle(mlist[0]) + person2 = self.db.get_person_from_handle(mlist[1]) + if person1 and person2: + Merge.PersonCompare(self.dbstate, self.uistate, person1, + person2, self.build_tree) else: QuestionDialog.ErrorDialog( _("Cannot merge people"), @@ -197,11 +219,11 @@ class PersonView(PageView.PersonNavView): else: import Merge - p1 = self.db.get_person_from_handle(mlist[0]) - p2 = self.db.get_person_from_handle(mlist[1]) - if p1 and p2: - Merge.MergePeopleUI(self.dbstate, self.uistate, p1, p2, - self.build_tree) + person1 = self.db.get_person_from_handle(mlist[0]) + person2 = self.db.get_person_from_handle(mlist[1]) + if person1 and person2: + Merge.MergePeopleUI(self.dbstate, self.uistate, person1, + person2, self.build_tree) else: QuestionDialog.ErrorDialog( _("Cannot merge people"), @@ -209,7 +231,7 @@ class PersonView(PageView.PersonNavView): "A second person can be selected by holding down the " "control key while clicking on the desired person.")) - def column_editor(self,obj): + def column_editor(self, obj): import ColumnOrder ColumnOrder.ColumnOrder( @@ -251,7 +273,7 @@ class PersonView(PageView.PersonNavView): self.tree.set_rules_hint(True) self.tree.set_headers_visible(True) self.tree.set_fixed_height_mode(True) - self.tree.connect('key-press-event',self.key_press) + self.tree.connect('key-press-event', self.key_press) scrollwindow = gtk.ScrolledWindow() scrollwindow.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) @@ -259,11 +281,11 @@ class PersonView(PageView.PersonNavView): scrollwindow.add(self.tree) scrollwindow.show_all() - self.vbox.pack_start(filter_box,False) - self.vbox.pack_start(scrollwindow,True) + self.vbox.pack_start(filter_box, False) + self.vbox.pack_start(scrollwindow, True) self.renderer = gtk.CellRendererText() - self.renderer.set_property('ellipsize',pango.ELLIPSIZE_END) + self.renderer.set_property('ellipsize', pango.ELLIPSIZE_END) self.inactive = False self.columns = [] @@ -276,7 +298,7 @@ class PersonView(PageView.PersonNavView): self.selection = self.tree.get_selection() self.selection.set_mode(gtk.SELECTION_MULTIPLE) - self.selection.connect('changed',self.row_changed) + self.selection.connect('changed', self.row_changed) self.filter_sidebar = PersonSidebarFilter(self.uistate, self.filter_clicked) @@ -298,7 +320,18 @@ class PersonView(PageView.PersonNavView): def filter_clicked(self): self.generic_filter = self.filter_sidebar.get_filter() self.build_tree() - + + def filter_toggle(self, client, cnxn_id, entry, data): + if Config.get(Config.FILTER): + self.search_bar.hide() + self.filter_pane.show() + active = True + else: + self.search_bar.show() + self.filter_pane.hide() + active = False + self.build_tree() + def drag_begin(self, widget, *data): widget.drag_source_set_icon_stock(self.get_stock()) @@ -366,7 +399,7 @@ class PersonView(PageView.PersonNavView): ''' - def change_db(self,db): + def change_db(self, db): """ Callback associated with DbState. Whenenver the database changes, this task is called. In this case, we rebuild the @@ -386,7 +419,7 @@ class PersonView(PageView.PersonNavView): if self.active: self.bookmarks.redraw() - def goto_active_person(self,obj=None): + def goto_active_person(self, obj=None): """ Callback (and usable function) that selects the active person in the display tree. @@ -422,29 +455,31 @@ class PersonView(PageView.PersonNavView): self.handle_history(self.dbstate.active.handle) def _goto(self): + """ + select the active person in the person view + """ - # select the active person in the person view - p = self.dbstate.active + person = self.dbstate.active try: - if self.model and p: - path = self.model.on_get_path(p.get_handle()) + if self.model and person: + path = self.model.on_get_path(person.get_handle()) - group_name = p.get_primary_name().get_group_name() + group_name = person.get_primary_name().get_group_name() top_name = self.dbstate.db.get_name_group_mapping(group_name) top_path = self.model.on_get_path(top_name) - self.tree.expand_row(top_path,0) + self.tree.expand_row(top_path, 0) current = self.model.on_get_iter(path) selected = self.selection.path_is_selected(path) - if current != p.get_handle() or not selected: + if current != person.get_handle() or not selected: self.selection.unselect_all() self.selection.select_path(path) - self.tree.scroll_to_cell(path,None,1,0.5,0) + self.tree.scroll_to_cell(path, None, 1, 0.5, 0) except KeyError: self.selection.unselect_all() self.uistate.push_message(self.dbstate, _("Active person not visible")) - self.dbstate.active = p + self.dbstate.active = person def setup_filter(self): """ @@ -452,11 +487,11 @@ class PersonView(PageView.PersonNavView): """ cols = [] - cols.append((_("Name"),0)) + cols.append((_("Name"), 0)) for pair in self.dbstate.db.get_person_column_order(): if not pair[0]: continue - cols.append((column_names[pair[1]],pair[1])) + cols.append((column_names[pair[1]], pair[1])) self.search_bar.setup_filter(cols) @@ -491,23 +526,12 @@ class PersonView(PageView.PersonNavView): else: self.dirty = True - def filter_toggle(self, client, cnxn_id, etnry, data): - if Config.get(Config.FILTER): - self.search_bar.hide() - self.filter_pane.show() - active = True - else: - self.search_bar.show() - self.filter_pane.hide() - active = False - self.build_tree() - - def add(self,obj): + def add(self, obj): person = RelLib.Person() # attempt to get the current surname - (mode,paths) = self.selection.get_selected_rows() + (mode, paths) = self.selection.get_selected_rows() name = u"" @@ -517,16 +541,17 @@ class PersonView(PageView.PersonNavView): name = self.model.on_get_iter(path) else: node = self.model.on_get_iter(path) - handle = self.model.on_get_value(node, PeopleModel.COLUMN_INT_ID) - p = self.dbstate.db.get_person_from_handle(handle) - name = p.get_primary_name().get_surname() + handle = self.model.on_get_value(node, + PeopleModel.COLUMN_INT_ID) + newp = self.dbstate.db.get_person_from_handle(handle) + name = newp.get_primary_name().get_surname() try: person.get_primary_name().set_surname(name) EditPerson(self.dbstate, self.uistate, [], person) except Errors.WindowActiveError: pass - def edit(self,obj): + def edit(self, obj): if self.dbstate.active: try: handle = self.dbstate.active.handle @@ -535,26 +560,27 @@ class PersonView(PageView.PersonNavView): except Errors.WindowActiveError: pass - def open_all_nodes(self,obj): + def open_all_nodes(self, obj): self.tree.expand_all() - def close_all_nodes(self,obj): + def close_all_nodes(self, obj): self.tree.collapse_all() - def remove(self,obj): + def remove(self, obj): mlist = self.get_selected_objects() if len(mlist) == 0: return for sel in mlist: - p = self.dbstate.db.get_person_from_handle(sel) - self.active_person = p - name = NameDisplay.displayer.display(p) + person = self.dbstate.db.get_person_from_handle(sel) + self.active_person = person + name = NameDisplay.displayer.display(person) msg = _('Deleting the person will remove the person ' 'from the database.') - msg = "%s %s" % (msg,Utils.data_recover_msg) - QuestionDialog.QuestionDialog(_('Delete %s?') % name,msg, + msg = "%s %s" % (msg, Utils.data_recover_msg) + QuestionDialog.QuestionDialog(_('Delete %s?') % name, + msg, _('_Delete Person'), self.delete_person_response) @@ -562,7 +588,7 @@ class PersonView(PageView.PersonNavView): #self.disable_interface() trans = self.dbstate.db.transaction_begin() - n = NameDisplay.displayer.display(self.active_person) + active_name = NameDisplay.displayer.display(self.active_person) if self.dbstate.db.get_default_person() == self.active_person: self.dbstate.db.set_default_person_handle(None) @@ -586,32 +612,35 @@ class PersonView(PageView.PersonNavView): for child_ref in family.get_child_ref_list(): child = self.dbstate.db.get_person_from_handle(child_ref.ref) child.remove_parent_family_handle(family_handle) - self.dbstate.db.commit_person(child,trans) - self.dbstate.db.remove_family(family_handle,trans) + self.dbstate.db.commit_person(child, trans) + self.dbstate.db.remove_family(family_handle, trans) else: - self.dbstate.db.commit_family(family,trans) + self.dbstate.db.commit_family(family, trans) for family_handle in self.active_person.get_parent_family_handle_list(): if family_handle: family = self.dbstate.db.get_family_from_handle(family_handle) family.remove_child_handle(self.active_person.get_handle()) - self.dbstate.db.commit_family(family,trans) + self.dbstate.db.commit_family(family, trans) handle = self.active_person.get_handle() - person_list = [ phandle for phandle in self.dbstate.db.get_person_handles(False) - if self.dbstate.db.get_person_from_handle(phandle).has_handle_reference('Person',handle) ] + person_list = [ + phdl for phdl in self.dbstate.db.get_person_handles(False) + if self.dbstate.db.get_person_from_handle(phdl).has_handle_reference('Person', + handle) ] for phandle in person_list: person = self.dbstate.db.get_person_from_handle(phandle) - person.remove_handle_references('Person',handle) - self.dbstate.db.commit_person(person,trans) + person.remove_handle_references('Person', handle) + self.dbstate.db.commit_person(person, trans) person = self.active_person self.remove_from_person_list(person) self.dbstate.db.remove_person(handle, trans) self.uistate.phistory.back() - self.dbstate.db.transaction_commit(trans,_("Delete Person (%s)") % n) + self.dbstate.db.transaction_commit( + trans, _("Delete Person (%s)") % active_name) def build_columns(self): for column in self.columns: @@ -619,11 +648,12 @@ class PersonView(PageView.PersonNavView): try: column = gtk.TreeViewColumn( _('Name'), - self.renderer,text=0, + self.renderer, + text=0, foreground=self.model.marker_color_column) except AttributeError: - column = gtk.TreeViewColumn(_('Name'), self.renderer,text=0) + column = gtk.TreeViewColumn(_('Name'), self.renderer, text=0) column.set_resizable(True) column.set_sizing(gtk.TREE_VIEW_COLUMN_FIXED) @@ -649,7 +679,7 @@ class PersonView(PageView.PersonNavView): self.columns.append(column) self.tree.append_column(column) - def row_changed(self,obj): + def row_changed(self, obj): """Called with a row is changed. Check the selected objects from the person_tree to get the IDs of the selected objects. Set the active person to the first person in the list. If no one is @@ -681,43 +711,43 @@ class PersonView(PageView.PersonNavView): selected_ids = self.get_selected_objects() nonempty_ids = [h for h in selected_ids if h] if nonempty_ids: - data = (DdTargets.PERSON_LINK.drag_type, id(self), - nonempty_ids[0], 0) - sel_data.set(sel_data.target, 8 ,pickle.dumps(data)) + data = (DdTargets.PERSON_LINK.drag_type, + id(self), nonempty_ids[0], 0) + sel_data.set(sel_data.target, 8, pickle.dumps(data)) - def person_added(self,handle_list): + def person_added(self, handle_list): if not self.model: return - if self.active: - self.dirty = False - for node in handle_list: - person = self.dbstate.db.get_person_from_handle(node) - pn = person.get_primary_name() - top = NameDisplay.displayer.name_grouping_name(self.db, pn) + if self.active: + self.dirty = False + for node in handle_list: + person = self.dbstate.db.get_person_from_handle(node) + pname = person.get_primary_name() + top = NameDisplay.displayer.name_grouping_name(self.db, pname) - self.model.rebuild_data() - if not self.model.is_visable(node): - continue + self.model.rebuild_data() + if not self.model.is_visable(node): + continue - if (not self.model.sname_sub.has_key(top) or - len(self.model.sname_sub[top]) == 1): - path = self.model.on_get_path(top) - pnode = self.model.get_iter(path) - self.model.row_inserted(path,pnode) - path = self.model.on_get_path(node) - pnode = self.model.get_iter(path) - self.model.row_inserted(path, pnode) - else: - self.dirty = True + if (not self.model.sname_sub.has_key(top) or + len(self.model.sname_sub[top]) == 1): + path = self.model.on_get_path(top) + pnode = self.model.get_iter(path) + self.model.row_inserted(path, pnode) + path = self.model.on_get_path(node) + pnode = self.model.get_iter(path) + self.model.row_inserted(path, pnode) + else: + self.dirty = True - def person_removed(self,handle_list): + def person_removed(self, handle_list): if not self.model: return if Config.get(Config.FILTER): data_filter = self.generic_filter else: - col,text,inv = self.search_bar.get_value() + col, text, inv = self.search_bar.get_value() func = lambda x: self.model.on_get_value(x, col) or u"" if col == PeopleModel._GENDER_COL: data_filter = ExactSearchFilter(func, text, inv) @@ -728,7 +758,7 @@ class PersonView(PageView.PersonNavView): for node in handle_list: person = self.dbstate.db.get_person_from_handle(node) top = person.get_primary_name().get_group_name() - mylist = self.model.sname_sub.get(top,[]) + mylist = self.model.sname_sub.get(top, []) self.model.calculate_data(data_filter, skip=set(handle_list)) if mylist: try: @@ -741,7 +771,7 @@ class PersonView(PageView.PersonNavView): pass self.model.assign_data() - def person_updated(self,handle_list): + def person_updated(self, handle_list): if not self.model: return @@ -764,10 +794,10 @@ class PersonView(PageView.PersonNavView): surname = self.dbstate.db.get_name_group_mapping(base) if oldpath[0] == surname: - try: - self.model.build_sub_entry(surname) - except: - self.model.calculate_data() + try: + self.model.build_sub_entry(surname) + except: + self.model.calculate_data() else: self.model.calculate_data() @@ -777,7 +807,7 @@ class PersonView(PageView.PersonNavView): # if paths same, just issue row changed signal if oldpath == newpath: - self.model.row_changed(pathval,pnode) + self.model.row_changed(pathval, pnode) else: self.build_tree() break @@ -785,7 +815,7 @@ class PersonView(PageView.PersonNavView): self.goto_active_person() def get_selected_objects(self): - (mode,paths) = self.selection.get_selected_rows() + (mode, paths) = self.selection.get_selected_rows() mlist = [] for path in paths: node = self.model.on_get_iter(path) @@ -794,17 +824,17 @@ class PersonView(PageView.PersonNavView): mlist.append(handle) return mlist - def remove_from_person_list(self,person): + def remove_from_person_list(self, person): """Remove the selected person from the list. A person object is expected, not an ID""" path = self.model.on_get_path(person.get_handle()) - (col,row) = path + (col, row) = path if row > 0: - self.selection.select_path((col,row-1)) + self.selection.select_path((col, row-1)) elif row == 0 and self.model.on_get_iter(path): self.selection.select_path(path) - def button_press(self,obj,event): + def button_press(self, obj, event): if event.type == gtk.gdk._2BUTTON_PRESS and event.button == 1: handle = self.first_selected() person = self.dbstate.db.get_person_from_handle(handle) @@ -817,7 +847,7 @@ class PersonView(PageView.PersonNavView): elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: menu = self.uistate.uimanager.get_widget('/Popup') if menu: - menu.popup(None,None,None,event.button,event.time) + menu.popup(None, None, None, event.button, event.time) return True return False diff --git a/src/DataViews/_PlaceView.py b/src/DataViews/_PlaceView.py index 1f54d6215..2527a0fee 100644 --- a/src/DataViews/_PlaceView.py +++ b/src/DataViews/_PlaceView.py @@ -19,6 +19,13 @@ # $Id$ +""" +Place View +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision$" + #------------------------------------------------------------------------- # # GTK/Gnome modules @@ -73,11 +80,12 @@ column_names = [ #------------------------------------------------------------------------- class PlaceView(PageView.ListView): - ADD_MSG = _("Add a new place") - EDIT_MSG = _("Edit the selected place") - DEL_MSG = _("Delete the selected place") + ADD_MSG = _("Add a new place") + EDIT_MSG = _("Edit the selected place") + DEL_MSG = _("Delete the selected place") + FILTER_TYPE = "Place" - def __init__(self,dbstate,uistate): + def __init__(self, dbstate, uistate): signal_map = { 'place-add' : self.row_add, @@ -115,25 +123,6 @@ class PlaceView(PageView.ListView): def drag_info(self): return DdTargets.PLACE_LINK - def filter_toggle(self, client, cnxn_id, etnry, data): - if Config.get(Config.FILTER): - self.search_bar.hide() - self.filter_pane.show() - active = True - else: - self.search_bar.show() - self.filter_pane.hide() - active = False - - def filter_editor(self,obj): - from FilterEditor import FilterEditor - - try: - FilterEditor('Place',const.custom_filters, - self.dbstate,self.uistate) - except Errors.WindowActiveError: - pass - def google(self, obj): import GrampsDisplay from PlaceUtils import conv_lat_lon @@ -146,19 +135,19 @@ class PlaceView(PageView.ListView): descr = place.get_title() longitude = place.get_longitude() latitude = place.get_latitude() - latitude,longitude = conv_lat_lon(latitude,longitude,"D.D8") + latitude, longitude = conv_lat_lon(latitude, longitude, "D.D8") city = place.get_main_location().get_city() country = place.get_main_location().get_country() if longitude and latitude: - path = "http://maps.google.com/?sll=%s,%s&z=15" % (latitude,longitude) + path = "http://maps.google.com/?sll=%s,%s&z=15" % (latitude, longitude) elif city and country: - path = "http://maps.google.com/maps?q=%s,%s" % (city,country) + path = "http://maps.google.com/maps?q=%s,%s" % (city, country) else: path = "http://maps.google.com/maps?q=%s" % '+'.join(descr.split()) GrampsDisplay.url(path) - def column_editor(self,obj): + def column_editor(self, obj): import ColumnOrder ColumnOrder.ColumnOrder( @@ -168,8 +157,8 @@ class PlaceView(PageView.ListView): column_names, self.set_column_order) - def set_column_order(self,list): - self.dbstate.db.set_place_column_order(list) + def set_column_order(self, clist): + self.dbstate.db.set_place_column_order(clist) self.build_columns() def column_order(self): @@ -217,33 +206,33 @@ class PlaceView(PageView.ListView): ''' - def on_double_click(self,obj,event): + def on_double_click(self, obj, event): handle = self.first_selected() place = self.dbstate.db.get_place_from_handle(handle) try: - EditPlace(self.dbstate,self.uistate,[],place) + EditPlace(self.dbstate, self.uistate, [], place) except Errors.WindowActiveError: pass - def add(self,obj): + def add(self, obj): try: - EditPlace(self.dbstate,self.uistate,[],RelLib.Place()) + EditPlace(self.dbstate, self.uistate, [], RelLib.Place()) except Errors.WindowActiveError: pass - def remove(self,obj): + def remove(self, obj): for place_handle in self.selected_handles(): db = self.dbstate.db - person_list = [ handle for handle in + person_list = [ h for h in db.get_person_handles(False) - if db.get_person_from_handle(handle).has_handle_reference('Place',place_handle) ] - family_list = [ handle for handle in + if db.get_person_from_handle(h).has_handle_reference('Place', place_handle) ] + family_list = [ h for h in db.get_family_handles() - if db.get_family_from_handle(handle).has_handle_reference('Place',place_handle) ] + if db.get_family_from_handle(h).has_handle_reference('Place', place_handle) ] place = db.get_place_from_handle(place_handle) - ans = DeletePlaceQuery(place,db) + ans = DeletePlaceQuery(place, db) if len(person_list) + len(family_list) > 0: msg = _('This place is currently being used. Deleting it ' @@ -252,35 +241,35 @@ class PlaceView(PageView.ListView): else: msg = _('Deleting place will remove it from the database.') - msg = "%s %s" % (msg,Utils.data_recover_msg) + msg = "%s %s" % (msg, Utils.data_recover_msg) descr = place.get_title() if descr == "": descr = place.get_gramps_id() QuestionDialog(_('Delete %s?') % descr, msg, - _('_Delete Place'),ans.query_response) + _('_Delete Place'), ans.query_response) - def edit(self,obj): + def edit(self, obj): mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) for handle in mlist: place = self.dbstate.db.get_place_from_handle(handle) try: - EditPlace(self.dbstate,self.uistate,[],place) + EditPlace(self.dbstate, self.uistate, [], place) except Errors.WindowActiveError: pass def fast_merge(self, obj): mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) if len(mlist) != 2: msg = _("Cannot merge places.") msg2 = _("Exactly two places must be selected to perform a merge. " "A second place can be selected by holding down the " "control key while clicking on the desired place.") - ErrorDialog(msg,msg2) + ErrorDialog(msg, msg2) else: import Merge Merge.MergePlaces(self.dbstate, self.uistate, mlist[0], mlist[1]) diff --git a/src/DataViews/_RelationView.py b/src/DataViews/_RelationView.py index 1dfa920ff..e7cf6656a 100644 --- a/src/DataViews/_RelationView.py +++ b/src/DataViews/_RelationView.py @@ -19,6 +19,13 @@ # $Id$ +""" +Relationship View +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision$" + #------------------------------------------------------------------------- # # Python modules @@ -29,7 +36,7 @@ import cgi try: set() -except: +except NameError: from sets import Set as set #------------------------------------------------------------------------- @@ -331,12 +338,12 @@ class RelationshipView(PageView.PersonNavView): def siblings_toggle(self, obj): self.show_siblings = obj.get_active() self.change_person(self.dbstate.active.handle) - Config.set(Config.FAMILY_SIBLINGS,self.show_siblings) + Config.set(Config.FAMILY_SIBLINGS, self.show_siblings) def details_toggle(self, obj): self.show_details = obj.get_active() self.change_person(self.dbstate.active.handle) - Config.set(Config.FAMILY_DETAILS,self.show_details) + Config.set(Config.FAMILY_DETAILS, self.show_details) def change_db(self, db): self.connect_to_db(db) @@ -358,10 +365,10 @@ class RelationshipView(PageView.PersonNavView): def get_name(self, handle, use_gender=False): if handle: - p = self.dbstate.db.get_person_from_handle(handle) - name = NameDisplay.displayer.display(p) + person = self.dbstate.db.get_person_from_handle(handle) + name = NameDisplay.displayer.display(person) if use_gender: - gender = _GenderCode[p.gender] + gender = _GenderCode[person.gender] else: gender = "" return (name, gender) @@ -480,7 +487,7 @@ class RelationshipView(PageView.PersonNavView): for old_child in self.header.get_children(): self.header.remove(old_child) - table = gtk.Table(2,3) + table = gtk.Table(2, 3) table.set_col_spacings(12) table.set_row_spacings(6) @@ -490,8 +497,8 @@ class RelationshipView(PageView.PersonNavView): text = fmt % cgi.escape(name) label = GrampsWidgets.DualMarkupLabel(text, _GenderCode[person.gender]) if Config.get(Config.RELEDITBTN): - button = GrampsWidgets.IconButton(self.edit_button_press,person.handle) - self.tooltips.set_tip(button,_('Edit %s') % name) + button = GrampsWidgets.IconButton(self.edit_button_press, person.handle) + self.tooltips.set_tip(button, _('Edit %s') % name) else: button = None hbox = GrampsWidgets.LinkBox(label, button) @@ -515,7 +522,7 @@ class RelationshipView(PageView.PersonNavView): 2, 3, 0, 1, yoptions=0) # Birth event. - birth = ReportUtils.get_birth_or_fallback(self.dbstate.db,person) + birth = ReportUtils.get_birth_or_fallback(self.dbstate.db, person) if birth: birth_title = birth.get_type() else: @@ -526,7 +533,7 @@ class RelationshipView(PageView.PersonNavView): subtbl.attach(GrampsWidgets.BasicLabel(self.format_event(birth)), 2, 3, 1, 2, yoptions=0) - death = ReportUtils.get_death_or_fallback(self.dbstate.db,person) + death = ReportUtils.get_death_or_fallback(self.dbstate.db, person) if death: death_title = death.get_type() else: @@ -550,10 +557,10 @@ class RelationshipView(PageView.PersonNavView): image = gtk.Image() image.set_from_pixbuf(pixbuf) image.show() - mbox.pack_end(image,False) + mbox.pack_end(image, False) mbox.show_all() - self.header.pack_start(mbox,False) + self.header.pack_start(mbox, False) def write_person_event(self, ename, event): if event: @@ -727,9 +734,9 @@ class RelationshipView(PageView.PersonNavView): format = "%s" label = GrampsWidgets.MarkupLabel(format % cgi.escape(title)) - label.set_alignment(0,0) + label.set_alignment(0, 0) if Config.get(Config.RELEDITBTN): - label.set_padding(0,5) + label.set_padding(0, 5) self.attach.attach(label, _PLABEL_START, _PLABEL_STOP, self.row, self.row+1, xoptions=gtk.FILL|gtk.SHRINK, yoptions=gtk.FILL|gtk.SHRINK) @@ -777,7 +784,7 @@ class RelationshipView(PageView.PersonNavView): lbl = GrampsWidgets.MarkupLabel(format % cgi.escape(title)) if Config.get(Config.RELEDITBTN): - lbl.set_padding(0,5) + lbl.set_padding(0, 5) return lbl def write_child(self, vbox, handle, index): @@ -844,36 +851,36 @@ class RelationshipView(PageView.PersonNavView): def button_press(self, obj, event, handle): if event.type == gtk.gdk.BUTTON_PRESS and event.button == 1: self.dbstate.change_active_handle(handle) - elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: - myMenu = gtk.Menu() - myMenu.append(self.build_menu_item(handle)) - myMenu.popup(None, None, None, event.button, event.time) + elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 3: + myMenu = gtk.Menu() + myMenu.append(self.build_menu_item(handle)) + myMenu.popup(None, None, None, event.button, event.time) def build_menu_item(self, handle): - person = self.dbstate.db.get_person_from_handle(handle) - name = NameDisplay.displayer.display(person) + person = self.dbstate.db.get_person_from_handle(handle) + name = NameDisplay.displayer.display(person) - item = gtk.ImageMenuItem(None) - image = gtk.image_new_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_MENU) - image.show() - label = gtk.Label(_("Edit %s") % name) - label.show() - label.set_alignment(0,0) + item = gtk.ImageMenuItem(None) + image = gtk.image_new_from_stock(gtk.STOCK_EDIT, gtk.ICON_SIZE_MENU) + image.show() + label = gtk.Label(_("Edit %s") % name) + label.show() + label.set_alignment(0, 0) - item.set_image(image) - item.add(label) + item.set_image(image) + item.add(label) - item.connect('activate',self.edit_menu, handle) - item.show() - return item + item.connect('activate', self.edit_menu, handle) + item.show() + return item def edit_menu(self, obj, handle): - from Editors import EditPerson - person = self.dbstate.db.get_person_from_handle(handle) - try: - EditPerson(self.dbstate, self.uistate, [], person) - except Errors.WindowActiveError: - pass + from Editors import EditPerson + person = self.dbstate.db.get_person_from_handle(handle) + try: + EditPerson(self.dbstate, self.uistate, [], person) + except Errors.WindowActiveError: + pass def write_relationship(self, box, family): msg = _('Relationship type: %s') % cgi.escape(str(family.get_relationship())) @@ -960,7 +967,7 @@ class RelationshipView(PageView.PersonNavView): eventbox.modify_bg(gtk.STATE_NORMAL, self.color) vbox = gtk.VBox() label_cell = self.build_label_cell(_('Children')) - label_cell.set_alignment(0,0) + label_cell.set_alignment(0, 0) self.attach.attach( label_cell, _CLABEL_START, _CLABEL_STOP, self.row, self.row+1, xoptions=gtk.FILL|gtk.SHRINK, @@ -1119,11 +1126,11 @@ class RelationshipView(PageView.PersonNavView): def change_to(self, obj, handle): self.dbstate.change_active_handle(handle) - def reorder(self,obj,dumm1=None,dummy2=None): + def reorder(self, obj, dumm1=None, dummy2=None): if self.dbstate.active: try: - import Reorder - Reorder.Reorder(self.dbstate, self.uistate, [], - self.dbstate.active.handle) + import Reorder + Reorder.Reorder(self.dbstate, self.uistate, [], + self.dbstate.active.handle) except Errors.WindowActiveError: pass diff --git a/src/DataViews/_RepositoryView.py b/src/DataViews/_RepositoryView.py index fa9bb17cd..f322536c7 100644 --- a/src/DataViews/_RepositoryView.py +++ b/src/DataViews/_RepositoryView.py @@ -19,6 +19,13 @@ # $Id$ +""" +Repository View +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision$" + #------------------------------------------------------------------------- # # GTK/Gnome modules @@ -77,8 +84,9 @@ class RepositoryView(PageView.ListView): ADD_MSG = _("Add a new repository") EDIT_MSG = _("Edit the selected repository") DEL_MSG = _("Delete the selected repository") + FILTER_TYPE = "Repository" - def __init__(self,dbstate,uistate): + def __init__(self, dbstate, uistate): signal_map = { 'repository-add' : self.row_add, @@ -110,26 +118,7 @@ class RepositoryView(PageView.ListView): self.add_action('FilterEdit', None, _('Repository Filter Editor'), callback=self.filter_editor,) - def filter_toggle(self, client, cnxn_id, etnry, data): - if Config.get(Config.FILTER): - self.search_bar.hide() - self.filter_pane.show() - active = True - else: - self.search_bar.show() - self.filter_pane.hide() - active = False - - def filter_editor(self,obj): - from FilterEditor import FilterEditor - - try: - FilterEditor('Repository',const.custom_filters, - self.dbstate,self.uistate) - except Errors.WindowActiveError: - pass - - def column_editor(self,obj): + def column_editor(self, obj): import ColumnOrder ColumnOrder.ColumnOrder( @@ -139,8 +128,8 @@ class RepositoryView(PageView.ListView): column_names, self.set_column_order) - def set_column_order(self,list): - self.dbstate.db.set_repository_column_order(list) + def set_column_order(self, clist): + self.dbstate.db.set_repository_column_order(clist) self.build_columns() def column_order(self): @@ -182,21 +171,21 @@ class RepositoryView(PageView.ListView): ''' - def on_double_click(self,obj,event): + def on_double_click(self, obj, event): handle = self.first_selected() repos = self.dbstate.db.get_repository_from_handle(handle) try: - EditRepository(self.dbstate, self.uistate,[],repos) + EditRepository(self.dbstate, self.uistate, [], repos) except Errors.WindowActiveError: pass - def add(self,obj): - EditRepository(self.dbstate, self.uistate,[],RelLib.Repository()) + def add(self, obj): + EditRepository(self.dbstate, self.uistate, [], RelLib.Repository()) - def remove(self,obj): + def remove(self, obj): db = self.dbstate.db mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) for repos_handle in mlist: @@ -206,7 +195,7 @@ class RepositoryView(PageView.ListView): repository = db.get_repository_from_handle(repos_handle) - ans = DelRepositoryQuery(repository,db,source_list) + ans = DelRepositoryQuery(repository, db, source_list) if len(source_list) > 0: msg = _('This repository is currently being used. Deleting it ' @@ -215,14 +204,14 @@ class RepositoryView(PageView.ListView): else: msg = _('Deleting repository will remove it from the database.') - msg = "%s %s" % (msg,Utils.data_recover_msg) + msg = "%s %s" % (msg, Utils.data_recover_msg) QuestionDialog(_('Delete %s?') % repository.get_name(), msg, - _('_Delete Repository'),ans.query_response) + _('_Delete Repository'), ans.query_response) - def edit(self,obj): + def edit(self, obj): mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) for handle in mlist: repos = self.dbstate.db.get_repository_from_handle(handle) diff --git a/src/DataViews/_SourceView.py b/src/DataViews/_SourceView.py index 3b603b93b..b3c7e7cb2 100644 --- a/src/DataViews/_SourceView.py +++ b/src/DataViews/_SourceView.py @@ -19,6 +19,13 @@ # $Id$ +""" +Source View +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision$" + #------------------------------------------------------------------------- # # GTK/Gnome modules @@ -70,8 +77,9 @@ class SourceView(PageView.ListView): ADD_MSG = _("Add a new source") EDIT_MSG = _("Edit the selected source") DEL_MSG = _("Delete the selected source") + FILTER_TYPE = "Source" - def __init__(self,dbstate,uistate): + def __init__(self, dbstate, uistate): signal_map = { 'source-add' : self.row_add, @@ -105,26 +113,7 @@ class SourceView(PageView.ListView): self.add_action('FilterEdit', None, _('Source Filter Editor'), callback=self.filter_editor,) - def filter_toggle(self, client, cnxn_id, etnry, data): - if Config.get(Config.FILTER): - self.search_bar.hide() - self.filter_pane.show() - active = True - else: - self.search_bar.show() - self.filter_pane.hide() - active = False - - def filter_editor(self,obj): - from FilterEditor import FilterEditor - - try: - FilterEditor('Source',const.custom_filters, - self.dbstate,self.uistate) - except Errors.WindowActiveError: - pass - - def column_editor(self,obj): + def column_editor(self, obj): import ColumnOrder ColumnOrder.ColumnOrder( @@ -134,8 +123,8 @@ class SourceView(PageView.ListView): column_names, self.set_column_order) - def set_column_order(self,list): - self.dbstate.db.set_source_column_order(list) + def set_column_order(self, clist): + self.dbstate.db.set_source_column_order(clist) self.build_columns() def column_order(self): @@ -180,7 +169,7 @@ class SourceView(PageView.ListView): ''' - def on_double_click(self,obj,event): + def on_double_click(self, obj, event): handle = self.first_selected() source = self.dbstate.db.get_source_from_handle(handle) try: @@ -188,36 +177,36 @@ class SourceView(PageView.ListView): except Errors.WindowActiveError: pass - def add(self,obj): + def add(self, obj): EditSource(self.dbstate, self.uistate, [], RelLib.Source()) - def remove(self,obj): + def remove(self, obj): for source_handle in self.selected_handles(): db = self.dbstate.db - the_lists = Utils.get_source_referents(source_handle,db) + the_lists = Utils.get_source_referents(source_handle, db) source = db.get_source_from_handle(source_handle) - ans = DelSrcQuery(source,db,the_lists) + ans = DelSrcQuery(source, db, the_lists) - if filter(None,the_lists): # quick test for non-emptiness + if filter(None, the_lists): # quick test for non-emptiness msg = _('This source is currently being used. Deleting it ' 'will remove it from the database and from all ' 'people and families that reference it.') else: msg = _('Deleting source will remove it from the database.') - msg = "%s %s" % (msg,Utils.data_recover_msg) + msg = "%s %s" % (msg, Utils.data_recover_msg) descr = source.get_title() if descr == "": descr = source.get_gramps_id() QuestionDialog(_('Delete %s?') % descr, msg, - _('_Delete Source'),ans.query_response) + _('_Delete Source'), ans.query_response) - def edit(self,obj): + def edit(self, obj): mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) for handle in mlist: source = self.dbstate.db.get_source_from_handle(handle) @@ -228,14 +217,14 @@ class SourceView(PageView.ListView): def fast_merge(self, obj): mlist = [] - self.selection.selected_foreach(self.blist,mlist) + self.selection.selected_foreach(self.blist, mlist) if len(mlist) != 2: msg = _("Cannot merge sources.") msg2 = _("Exactly two sources must be selected to perform a merge. " "A second source can be selected by holding down the " "control key while clicking on the desired source.") - ErrorDialog(msg,msg2) + ErrorDialog(msg, msg2) else: import Merge Merge.MergeSources(self.dbstate, self.uistate, mlist[0], mlist[1]) diff --git a/src/DataViews/__init__.py b/src/DataViews/__init__.py index eb7595d64..1989f6f82 100644 --- a/src/DataViews/__init__.py +++ b/src/DataViews/__init__.py @@ -19,6 +19,13 @@ # $Id: __init__.py 6067 2006-03-04 05:24:16Z dallingham $ +""" +Package init for the DataView package +""" + +__author__ = "Don Allingham" +__revision__ = "$Revision: $" + from _PersonView import PersonView from _RelationView import RelationshipView from _FamilyList import FamilyListView @@ -31,6 +38,9 @@ from _MediaView import MediaView from _RepositoryView import RepositoryView def get_views(): + """ + Returns a list of PageView instances + """ return [ PersonView, RelationshipView, diff --git a/src/PageView.py b/src/PageView.py index 71bbec5f8..638b79372 100644 --- a/src/PageView.py +++ b/src/PageView.py @@ -478,6 +478,16 @@ class ListView(BookMarkView): self.filter_toggle(None, None, None, None) return hpaned + def filter_toggle(self, client, cnxn_id, entry, data): + if Config.get(Config.FILTER): + self.search_bar.hide() + self.filter_pane.show() + active = True + else: + self.search_bar.show() + self.filter_pane.hide() + active = False + def post(self): if self.filter_class: if Config.get(Config.FILTER): @@ -698,6 +708,15 @@ class ListView(BookMarkView): Config.set(Config.FILTER, active) self.build_tree() + def filter_editor(self,obj): + from FilterEditor import FilterEditor + + try: + FilterEditor(self.FILTER_TYPE ,const.custom_filters, + self.dbstate, self.uistate) + except Errors.WindowActiveError: + pass + def change_db(self,db): for sig in self.signal_map: db.connect(sig, self.signal_map[sig]) diff --git a/src/RelLib/_CalSdn.py b/src/RelLib/_CalSdn.py index a1e7f13d4..6365b8636 100644 --- a/src/RelLib/_CalSdn.py +++ b/src/RelLib/_CalSdn.py @@ -20,6 +20,10 @@ # $Id$ +""" +Provides calendar to sdn (serial date number) conversion. +""" + __revision__ = "$Revision$" #------------------------------------------------------------------------- @@ -100,11 +104,12 @@ def _tishri1(metonic_year, molad_day, molad_halakim): return tishri1 def _tishri_molad(input_day): - - # Estimate the metonic cycle number. Note that this may be an under - # estimate because there are 6939.6896 days in a metonic cycle not - # 6940, but it will never be an over estimate. The loop below will - # correct for any error in this estimate. */ + """ + Estimate the metonic cycle number. Note that this may be an under + estimate because there are 6939.6896 days in a metonic cycle not + 6940, but it will never be an over estimate. The loop below will + correct for any error in this estimate. + """ metonic_cycle = (input_day + 310) / 6940 @@ -124,7 +129,7 @@ def _tishri_molad(input_day): molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY # Find the molad of Tishri closest to this date. - + for metonic_year in range(0, 18): if molad_day > input_day - 74: break @@ -134,12 +139,13 @@ def _tishri_molad(input_day): molad_day = molad_day + (molad_halakim / _HBR_HALAKIM_PER_DAY) molad_halakim = molad_halakim % _HBR_HALAKIM_PER_DAY else: - metonic_year = metonic_year + 1 + metonic_year += 1 return (metonic_cycle, metonic_year, molad_day, molad_halakim) def _molad_of_metonic_cycle(metonic_cycle): - - # Start with the time of the first molad after creation. + """ + Start with the time of the first molad after creation. + """ r1 = _HBR_NEW_MOON_OF_CREATION @@ -167,7 +173,9 @@ def _molad_of_metonic_cycle(metonic_cycle): return (molad_day, molad_halakim) def _start_of_year(year): - + """ + calculate the start of the year. + """ metonic_cycle = (year - 1) / 19; metonic_year = (year - 1) % 19; (molad_day, molad_halakim) = _molad_of_metonic_cycle(metonic_cycle) @@ -473,6 +481,7 @@ def french_ymd(sdn): return (year, month, day) def persian_sdn(year, month, day): + """Converts an Persian date to an SDN number""" if year >= 0: epbase = year - 474 else: @@ -491,6 +500,7 @@ def persian_sdn(year, month, day): return int(math.ceil(v1 + v2 + v3 + v4 + _PRS_EPOCH - 1)) def persian_ymd(sdn): + """Converts an SDN number to a Persian calendar date""" sdn = math.floor(sdn) + 0.5 depoch = sdn - 2121446 @@ -516,6 +526,7 @@ def persian_ymd(sdn): return (int(year), int(month), int(day)) def islamic_sdn(year, month, day): + """Converts an Islamic date to an SDN number""" v1 = math.ceil(29.5 * (month - 1)) v2 = (year - 1) * 354 v3 = math.floor((3 + (11 *year)) / 30) @@ -523,6 +534,7 @@ def islamic_sdn(year, month, day): return int(math.ceil((day + v1 + v2 + v3 + _ISM_EPOCH) - 1)) def islamic_ymd(sdn): + """Converts an SDN number to an Islamic calendar date""" sdn = math.floor(sdn) + 0.5 year = int(math.floor(((30*(sdn-_ISM_EPOCH))+10646)/10631)) month = int(min(12, math.ceil((sdn-(29+islamic_sdn(year, 1, 1)))/29.5) + 1)) diff --git a/src/RelLib/_Event.py b/src/RelLib/_Event.py index fee266520..0bac612df 100644 --- a/src/RelLib/_Event.py +++ b/src/RelLib/_Event.py @@ -126,15 +126,44 @@ class Event(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase, NoteBase.unserialize(self, note) def _has_handle_reference(self, classname, handle): + """ + Returns True if the object has reference to a given handle + of given primary object type. + + @param classname: The name of the primary object class. + @type classname: str + @param handle: The handle to be checked. + @type handle: str + @return: Returns whether the object has reference to this handle of this object type. + @rtype: bool + """ if classname == 'Place': return self.place == handle return False def _remove_handle_references(self, classname, handle_list): + """ + Removes all references in this object to object handles in the list. + + @param classname: The name of the primary object class. + @type classname: str + @param handle_list: The list of handles to be removed. + @type handle_list: str + """ if classname == 'Place' and self.place in handle_list: self.place = "" def _replace_handle_reference(self, classname, old_handle, new_handle): + """ + Replaces all references to old handle with those to the new handle. + + @param classname: The name of the primary object class. + @type classname: str + @param old_handle: The handle to be replaced. + @type old_handle: str + @param new_handle: The handle to replace the old one with. + @type new_handle: str + """ if classname == 'Place' and self.place == old_handle: self.place = new_handle diff --git a/src/RelLib/_EventType.py b/src/RelLib/_EventType.py index 16c26218b..9c4d741bc 100644 --- a/src/RelLib/_EventType.py +++ b/src/RelLib/_EventType.py @@ -30,7 +30,9 @@ from _GrampsType import GrampsType, init_map from gettext import gettext as _ class EventType(GrampsType): - + """ + Event types + """ UNKNOWN = -1 CUSTOM = 0 MARRIAGE = 1 diff --git a/src/RelLib/_Family.py b/src/RelLib/_Family.py index 46e1cb5c1..ca82ba9f0 100644 --- a/src/RelLib/_Family.py +++ b/src/RelLib/_Family.py @@ -146,6 +146,17 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase.unserialize(self, lds_seal_list) def _has_handle_reference(self, classname, handle): + """ + Returns True if the object has reference to a given handle + of given primary object type. + + @param classname: The name of the primary object class. + @type classname: str + @param handle: The handle to be checked. + @type handle: str + @return: Returns whether the object has reference to this handle of this object type. + @rtype: bool + """ if classname == 'Event': return handle in [ref.ref for ref in self.event_ref_list] elif classname == 'Person': @@ -156,6 +167,14 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase, return False def _remove_handle_references(self, classname, handle_list): + """ + Removes all references in this object to object handles in the list. + + @param classname: The name of the primary object class. + @type classname: str + @param handle_list: The list of handles to be removed. + @type handle_list: str + """ if classname == 'Event': new_list = [ ref for ref in self.event_ref_list \ if ref.ref not in handle_list ] @@ -174,6 +193,16 @@ class Family(PrimaryObject, SourceBase, NoteBase, MediaBase, AttributeBase, x.place = None def _replace_handle_reference(self, classname, old_handle, new_handle): + """ + Replaces all references to old handle with those to the new handle. + + @param classname: The name of the primary object class. + @type classname: str + @param old_handle: The handle to be replaced. + @type old_handle: str + @param new_handle: The handle to replace the old one with. + @type new_handle: str + """ if classname == 'Event': handle_list = [ref.ref for ref in self.event_ref_list] while old_handle in handle_list: diff --git a/src/RelLib/_GrampsType.py b/src/RelLib/_GrampsType.py index 3d7faf5cb..83678ab61 100644 --- a/src/RelLib/_GrampsType.py +++ b/src/RelLib/_GrampsType.py @@ -29,6 +29,9 @@ __revision__ = "$Revision$" from gettext import gettext as _ def init_map(data, key_col, data_col): + """ + Initializes the map, building a new map from the specified columns. + """ new_data = {} for item in data: new_data[item[key_col]] = item[data_col] @@ -47,6 +50,9 @@ class GrampsType: _E2IMAP = init_map(_DATAMAP, 2, 0) def __init__(self, value=None): + """ + Creates a new type, initialize the value from one of several possible states. + """ self.value = None self.string = None self.set(value) diff --git a/src/RelLib/_LdsOrd.py b/src/RelLib/_LdsOrd.py index 7263a4b73..e13dc240e 100644 --- a/src/RelLib/_LdsOrd.py +++ b/src/RelLib/_LdsOrd.py @@ -199,9 +199,21 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase, return self.source_list def get_type(self): + """ + Returns the type of the Event. + + @return: Type of the Event + @rtype: tuple + """ return self.type def set_type(self, ord_type): + """ + Sets the type of the LdsOrd to the passed (int,str) tuple. + + @param ord_type: Type to assign to the LdsOrd + @type ord_type: tuple + """ self.type = ord_type def set_family_handle(self, family): diff --git a/src/RelLib/_Person.py b/src/RelLib/_Person.py index edcf179ac..c83cab2e7 100644 --- a/src/RelLib/_Person.py +++ b/src/RelLib/_Person.py @@ -199,6 +199,17 @@ class Person(PrimaryObject, SourceBase, NoteBase, MediaBase, NoteBase.unserialize(self, note) def _has_handle_reference(self, classname, handle): + """ + Returns True if the object has reference to a given handle + of given primary object type. + + @param classname: The name of the primary object class. + @type classname: str + @param handle: The handle to be checked. + @type handle: str + @return: Returns whether the object has reference to this handle of this object type. + @rtype: bool + """ if classname == 'Event': return handle in [ref.ref for ref in self.event_ref_list] elif classname == 'Person':