From 254ac30ed2a4f6319c3650c8ac4a88bef36d5bb7 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Fri, 24 Jan 2003 03:47:05 +0000 Subject: [PATCH] Capitalize last names svn: r1271 --- gramps2/src/EditPerson.py | 21 +++-- gramps2/src/Errors.py | 8 +- gramps2/src/GrampsCfg.py | 8 ++ gramps2/src/RelLib.py | 1 - gramps2/src/plugins/ReadGedcom.py | 5 +- gramps2/src/preferences.glade | 130 +++++++----------------------- 6 files changed, 61 insertions(+), 112 deletions(-) diff --git a/gramps2/src/EditPerson.py b/gramps2/src/EditPerson.py index 2009f1a57..814aadb3e 100644 --- a/gramps2/src/EditPerson.py +++ b/gramps2/src/EditPerson.py @@ -828,6 +828,8 @@ class EditPerson: """Check to see if any of the data has changed from the original record""" surname = self.surname_field.get_text() + if GrampsCfg.capitalize: + surname = surname.upper() ntype = self.ntype_field.entry.get_text() suffix = self.suffix.get_text() prefix = self.prefix.get_text() @@ -850,8 +852,12 @@ class EditPerson: changed = 1 if prefix != name.getSurnamePrefix(): changed = 1 - if surname != name.getSurname(): - changed = 1 + if GrampsCfg.capitalize: + if surname != name.getSurname(): + changed = 1 + else: + if surname.upper() != name.getSurname().upper(): + changed = 1 if ntype != name.getType(): changed = 1 if given != name.getFirstName(): @@ -1206,9 +1212,14 @@ class EditPerson: if ntype != name.getType(): name.setType(ntype) - if surname != name.getSurname(): - name.setSurname(surname) - self.db.addSurname(surname) + if GrampsCfg.capitalize: + if surname.upper() != name.getSurname().upper(): + name.setSurname(surname.upper()) + self.db.addSurname(surname.upper()) + else: + if surname != name.getSurname(): + name.setSurname(surname) + self.db.addSurname(surname) if given != name.getFirstName(): name.setFirstName(given) diff --git a/gramps2/src/Errors.py b/gramps2/src/Errors.py index d04dd5b57..cb3307382 100644 --- a/gramps2/src/Errors.py +++ b/gramps2/src/Errors.py @@ -1,7 +1,7 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2001 David R. Hampton +# Copyright (C) 2003 Donald N. Allingham # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -19,7 +19,7 @@ # class ReportError(Exception): - + """Error used to report Report errors""" def __init__(self,value): self.value = value @@ -27,7 +27,7 @@ class ReportError(Exception): return self.value class GedcomError(Exception): - + """Error used to report GEDCOM errors""" def __init__(self,value): self.value = value @@ -35,7 +35,7 @@ class GedcomError(Exception): return self.value class PluginError(Exception): - + """Error used to report plugin errors""" def __init__(self,value): self.value = value diff --git a/gramps2/src/GrampsCfg.py b/gramps2/src/GrampsCfg.py index 0b0cc0651..3c7214249 100644 --- a/gramps2/src/GrampsCfg.py +++ b/gramps2/src/GrampsCfg.py @@ -144,6 +144,7 @@ index_visible = 0 mediaref = 1 globalprop = 1 localprop = 1 +capitalize = 0 #------------------------------------------------------------------------- # @@ -223,6 +224,7 @@ def loadConfig(call): vc_comment = get_bool("/apps/gramps/use-comment") uncompress = get_bool("/apps/gramps/dont-compress-xml") id_edit = get_bool("/apps/gramps/id-edit") + capitalize = get_bool("/apps/gramps/capitalize") index_visible = get_bool("/apps/gramps/index-visible") status_bar = get_int("/apps/gramps/statusbar") toolbar = get_int("/apps/gramps/toolbar",2) @@ -544,6 +546,7 @@ class GrampsPreferences: auto = self.top.get_widget("autoload") asave_int = self.top.get_widget("autosave_interval") idedit = self.top.get_widget("gid_edit") + cap = self.top.get_widget('capitalize') index_vis = self.top.get_widget("show_child_id") lds = self.top.get_widget("uselds") ac = self.top.get_widget("autocomp") @@ -571,6 +574,7 @@ class GrampsPreferences: vcom.set_active(vc_comment) compress.set_active(uncompress) idedit.set_active(id_edit) + cap.set_active(capitalize) index_vis.set_active(index_visible) self.top.get_widget("iprefix").set_text(iprefix) @@ -792,6 +796,7 @@ class GrampsPreferences: global vc_comment global uncompress global id_edit + global capitalize global index_visible global status_bar global toolbar @@ -816,6 +821,8 @@ class GrampsPreferences: vc_comment = self.top.get_widget("vc_comment").get_active() uncompress = self.top.get_widget("uncompress").get_active() id_edit = self.top.get_widget("gid_edit").get_active() + capitalize = self.top.get_widget('capitalize').get_active() + index_visible = self.top.get_widget("show_child_id").get_active() paper_obj = self.top.get_widget("paper_size").get_menu().get_active() @@ -878,6 +885,7 @@ class GrampsPreferences: set_bool("/apps/gramps/use-comment",vc_comment) set_bool("/apps/gramps/dont-compress-xml",uncompress) set_bool("/apps/gramps/id-edit",id_edit) + set_bool("/apps/gramps/capitalize",capitalize) set_bool("/apps/gramps/index-visible",index_visible) set_int("/apps/gramps/statusbar",status_bar) set_int("/apps/gramps/toolbar",toolbar+1) diff --git a/gramps2/src/RelLib.py b/gramps2/src/RelLib.py index 99a230471..e868484f1 100644 --- a/gramps2/src/RelLib.py +++ b/gramps2/src/RelLib.py @@ -1021,7 +1021,6 @@ class Person(Persistent): bday.getQuoteDate(), dday.getQuoteDate(), sort.build_sort_name(self.getPrimaryName()), sort.build_sort_date(bday),sort.build_sort_date(dday)] - def setPrimaryName(self,name): """sets the primary name of the Person to the specified diff --git a/gramps2/src/plugins/ReadGedcom.py b/gramps2/src/plugins/ReadGedcom.py index 46670b83c..5e33146c9 100644 --- a/gramps2/src/plugins/ReadGedcom.py +++ b/gramps2/src/plugins/ReadGedcom.py @@ -285,7 +285,8 @@ class GedcomParser: if self.backoff == 0: next_line = self.f.readline() self.text = string.translate(next_line.strip(),self.trans,self.delc) - if self.text == '': + + if not self.text: raise Errors.GedcomError(_("GEDCOM file ended unexpectedly")) try: @@ -293,7 +294,7 @@ class GedcomParser: except: self.text = string.translate(self.text,self.trans2) - self.index = self.index + 1 + self.index += 1 l = string.split(self.text, None, 2) ln = len(l) try: diff --git a/gramps2/src/preferences.glade b/gramps2/src/preferences.glade index 8a1e21db6..0f7b81aeb 100644 --- a/gramps2/src/preferences.glade +++ b/gramps2/src/preferences.glade @@ -281,7 +281,7 @@ True - 4 + 5 3 False 0 @@ -304,8 +304,8 @@ 0 1 - 3 - 4 + 4 + 5 3 3 fill @@ -341,8 +341,8 @@ 1 3 - 3 - 4 + 4 + 5 3 3 @@ -412,8 +412,8 @@ 1 2 - 2 - 3 + 3 + 4 3 3 @@ -437,6 +437,29 @@ 0 1 + 3 + 4 + 3 + 3 + fill + + + + + + + True + True + Capitalize surnames + True + GTK_RELIEF_NORMAL + False + False + True + + + 0 + 3 2 3 3 @@ -893,26 +916,6 @@ False - - - - True - True - Active person's name and attribute - True - GTK_RELIEF_NORMAL - False - False - True - stat1 - - - - 0 - False - False - - @@ -1006,59 +1009,6 @@ False - - - - 3 - True - False - 0 - - - - True - True - Display attribute on Edit Person form - True - GTK_RELIEF_NORMAL - False - False - True - - - - 0 - False - False - - - - - - True - True - True - True - 0 - - True - * - False - - - - 5 - True - True - - - - - 0 - False - False - - @@ -1102,26 +1052,6 @@ False 0 - - - 3 - True - True - Do not display alternate names in person list - True - GTK_RELIEF_NORMAL - False - False - True - - - - 0 - False - False - - - 3