diff --git a/gramps/gen/lib/person.py b/gramps/gen/lib/person.py index af4d500f1..63e83101a 100644 --- a/gramps/gen/lib/person.py +++ b/gramps/gen/lib/person.py @@ -99,7 +99,7 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, self.parent_family_list = [] self.alternate_names = [] self.person_ref_list = [] - self.gender = Person.UNKNOWN + self.__gender = Person.UNKNOWN self.death_ref_index = -1 self.birth_ref_index = -1 if data: @@ -136,7 +136,7 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, return ( self.handle, # 0 self.gramps_id, # 1 - self.gender, # 2 + self.__gender, # 2 self.primary_name.serialize(), # 3 [name.serialize() for name in self.alternate_names], # 4 self.death_ref_index, # 5 @@ -181,7 +181,7 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, "_class": "Person", "handle": Handle("Person", self.handle), # 0 "gramps_id": self.gramps_id, # 1 - "gender": self.gender, # 2 + "gender": self.__gender, # 2 "primary_name": self.primary_name.to_struct(), # 3 "alternate_names": [name.to_struct() for name in self.alternate_names], # 4 @@ -276,7 +276,7 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, """ (self.handle, # 0 self.gramps_id, # 1 - self.gender, # 2 + self.__gender, # 2 primary_name, # 3 alternate_names, # 4 self.death_ref_index, # 5 @@ -675,7 +675,9 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, - Person.UNKNOWN :type gender: int """ - self.gender = gender + if gender not in (Person.MALE, Person.FEMALE, Person.UNKNOWN): + raise ValueError('Attempt to assign invalid gender') + self.__gender = gender def get_gender(self) : """ @@ -688,7 +690,10 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, - Person.UNKNOWN :rtype: int """ - return self.gender + return self.__gender + + gender = property(get_gender, set_gender, None, + 'Returns or sets the gender of the person') def set_birth_ref(self, event_ref): """