diff --git a/data/tests/imp_MediaTest.gramps b/data/tests/imp_MediaTest.gramps index d95009a86..2674b4e01 100644 --- a/data/tests/imp_MediaTest.gramps +++ b/data/tests/imp_MediaTest.gramps @@ -89,6 +89,7 @@ + diff --git a/gramps/gen/datehandler/test/datehandler_test.py b/gramps/gen/datehandler/test/datehandler_test.py index eb3eabd3d..9779d7b0f 100644 --- a/gramps/gen/datehandler/test/datehandler_test.py +++ b/gramps/gen/datehandler/test/datehandler_test.py @@ -63,7 +63,7 @@ class DateHandlerTest(unittest.TestCase): self.assertTrue(test_date.is_equal(new_date), "{} -> {}\n{} -> {}".format( test_date, new_date, - test_date.to_struct(), new_date.to_struct())) + test_date.__dict__, new_date.__dict__)) def test_simple(self): diff --git a/gramps/gen/lib/address.py b/gramps/gen/lib/address.py index c684667cc..89a02ed53 100644 --- a/gramps/gen/lib/address.py +++ b/gramps/gen/lib/address.py @@ -67,49 +67,6 @@ class Address(SecondaryObject, PrivacyBase, CitationBase, NoteBase, DateBase, DateBase.serialize(self), LocationBase.serialize(self)) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Address", - "private": PrivacyBase.serialize(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "date": DateBase.to_struct(self), - "location": LocationBase.to_struct(self) - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Address() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - DateBase.from_struct(struct.get("date", {})), - LocationBase.from_struct(struct.get("location", {})) - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/addressbase.py b/gramps/gen/lib/addressbase.py index 713a56075..ad9c3ac93 100644 --- a/gramps/gen/lib/addressbase.py +++ b/gramps/gen/lib/addressbase.py @@ -59,37 +59,6 @@ class AddressBase: """ return [addr.serialize() for addr in self.address_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [addr.to_struct() for addr in self.address_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Address.from_struct(addr) for addr in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/attrbase.py b/gramps/gen/lib/attrbase.py index 2f356b949..1e88269d7 100644 --- a/gramps/gen/lib/attrbase.py +++ b/gramps/gen/lib/attrbase.py @@ -65,37 +65,6 @@ class AttributeRootBase: """ return [attr.serialize() for attr in self.attribute_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [attr.to_struct() for attr in self.attribute_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [cls._CLASS.from_struct(attr) for attr in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/attribute.py b/gramps/gen/lib/attribute.py index d97024f43..39fcd47d1 100644 --- a/gramps/gen/lib/attribute.py +++ b/gramps/gen/lib/attribute.py @@ -77,43 +77,6 @@ class AttributeRoot(SecondaryObject, PrivacyBase): return (PrivacyBase.serialize(self), self.type.serialize(), self.value) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": self.__class__.__name__, - "private": PrivacyBase.serialize(self), - "type": self.type.to_struct(), - "value": self.value} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Attribute() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - AttributeType.from_struct(struct.get("type", {})), - struct.get("value", default.value)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. @@ -246,46 +209,6 @@ class Attribute(AttributeRoot, CitationBase, NoteBase): NoteBase.serialize(self), self.type.serialize(), self.value) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Attribute", - "private": PrivacyBase.serialize(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "type": self.type.to_struct(), - "value": self.value} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return (PrivacyBase.from_struct(struct["private"]), - CitationBase.from_struct(struct["citation_list"]), - NoteBase.from_struct(struct["note_list"]), - AttributeType.from_struct(struct["type"]), - struct["value"]) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/baseobj.py b/gramps/gen/lib/baseobj.py index acfe81e86..631b777c2 100644 --- a/gramps/gen/lib/baseobj.py +++ b/gramps/gen/lib/baseobj.py @@ -56,43 +56,6 @@ class BaseObject(metaclass=ABCMeta): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def matches_string(self, pattern, case_sensitive=False): """ Return True if any text data in the object or any of it's child diff --git a/gramps/gen/lib/childref.py b/gramps/gen/lib/childref.py index 35261474b..822f9dbfe 100644 --- a/gramps/gen/lib/childref.py +++ b/gramps/gen/lib/childref.py @@ -75,49 +75,6 @@ class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase): self.frel.serialize(), self.mrel.serialize()) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "ChildRef", - "private": PrivacyBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "ref": Handle("Person", self.ref), - "frel": self.frel.to_struct(), - "mrel": self.mrel.to_struct()} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = ChildRef() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - ChildRefType.from_struct(struct.get("frel", {})), - ChildRefType.from_struct(struct.get("mrel", {}))) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/citation.py b/gramps/gen/lib/citation.py index 75a587a65..cf48c304a 100644 --- a/gramps/gen/lib/citation.py +++ b/gramps/gen/lib/citation.py @@ -136,61 +136,6 @@ class Citation(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, TagBase.serialize(self), # 10 self.private) # 11 - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Citation", - "handle": Handle("Citation", self.handle), # 0 - "gramps_id": self.gramps_id, # 1 - "date": DateBase.to_struct(self), # 2 - "page": str(self.page), # 3 - "confidence": self.confidence, # 4 - "source_handle": Handle("Source", self.source_handle), # 5 - "note_list": NoteBase.to_struct(self), # 6 - "media_list": MediaBase.to_struct(self), # 7 - "srcattr_list": SrcAttributeBase.to_struct(self),# 8 - "change": self.change, # 9 - "tag_list": TagBase.to_struct(self), # 10 - "private": self.private} # 11 - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Citation() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - DateBase.from_struct(struct.get("date", {})), - struct.get("page", default.page), - struct.get("confidence", default.confidence), - Handle.from_struct(struct.get("source_handle", default.source_handle)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - MediaBase.from_struct(struct.get("media_list", default.media_list)), - SrcAttributeBase.from_struct(struct.get("srcattr_list", [])), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/citationbase.py b/gramps/gen/lib/citationbase.py index 59e5b60a3..7521ba5ac 100644 --- a/gramps/gen/lib/citationbase.py +++ b/gramps/gen/lib/citationbase.py @@ -75,37 +75,6 @@ class CitationBase: """ return self.citation_list - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [Handle("Citation", c) for c in self.citation_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Handle.from_struct(handle) for handle in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/date.py b/gramps/gen/lib/date.py index abcb93107..03664d098 100644 --- a/gramps/gen/lib/date.py +++ b/gramps/gen/lib/date.py @@ -671,55 +671,6 @@ class Date: return (self.calendar, self.modifier, self.quality, self.dateval, text, self.sortval, self.newyear) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Date", - "calendar": self.calendar, - "modifier": self.modifier, - "quality": self.quality, - "dateval": self.dateval, - "text": self.text, - "sortval": self.sortval, - "newyear": self.newyear} - - @classmethod - def from_struct(cls, struct, full=False): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Date() - retval = (struct.get("calendar", default.calendar), - struct.get("modifier", default.modifier), - struct.get("quality", default.quality), - struct.get("dateval", default.dateval), - struct.get("text", default.text), - struct.get("sortval", default.sortval), - struct.get("newyear", default.newyear)) - if not full and retval == (0, 0, 0, (0, 0, 0, False), '', 0, 0): - return None - else: - return retval - def unserialize(self, data): """ Load from the format created by serialize. @@ -1701,7 +1652,7 @@ class Date: self.__compare(sanity.dateval, value, year_delta) except DateError as err: LOG.debug("Sanity check failed - self: {}, sanity: {}". - format(self.to_struct(), sanity.to_struct())) + format(self.__dict__, sanity.__dict__)) err.date = self raise diff --git a/gramps/gen/lib/datebase.py b/gramps/gen/lib/datebase.py index 0ffd26c97..da3fe242c 100644 --- a/gramps/gen/lib/datebase.py +++ b/gramps/gen/lib/datebase.py @@ -61,41 +61,6 @@ class DateBase: date = self.date.serialize(no_text_date) return date - def to_struct(self, no_text_date=False): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - if self.date is None: - date = Date().to_struct() - else: - date = self.date.to_struct() - return date - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return Date.from_struct(struct) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/event.py b/gramps/gen/lib/event.py index 5047d0f53..5cf4f4295 100644 --- a/gramps/gen/lib/event.py +++ b/gramps/gen/lib/event.py @@ -118,41 +118,6 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase, AttributeBase.serialize(self), self.change, TagBase.serialize(self), self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Event", - "handle": Handle("Event", self.handle), - "gramps_id": self.gramps_id, - "type": self.__type.to_struct(), - "date": DateBase.to_struct(self), - "description": self.__description, - "place": Handle("Place", self.place), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "media_list": MediaBase.to_struct(self), - "attribute_list": AttributeBase.to_struct(self), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - @classmethod def get_schema(cls): """ @@ -199,28 +164,6 @@ class Event(CitationBase, NoteBase, MediaBase, AttributeBase, "private": _("Private"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Event() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - EventType.from_struct(struct.get("type", {})), - DateBase.from_struct(struct.get("date", {})), - struct.get("description", default.description), - Handle.from_struct(struct.get("place", default.place)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - MediaBase.from_struct(struct.get("media_list", default.media_list)), - AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/eventref.py b/gramps/gen/lib/eventref.py index c06686e2f..49af525fb 100644 --- a/gramps/gen/lib/eventref.py +++ b/gramps/gen/lib/eventref.py @@ -79,35 +79,6 @@ class EventRef(PrivacyBase, NoteBase, AttributeBase, RefBase, self.__role.serialize() ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "EventRef", - "private": PrivacyBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "attribute_list": AttributeBase.to_struct(self), - "ref": Handle("Event", self.ref), - "role": self.__role.to_struct() - } - @classmethod def get_schema(cls): """ @@ -142,22 +113,6 @@ class EventRef(PrivacyBase, NoteBase, AttributeBase, RefBase, "role": _("Role"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = EventRef() - return ( - PrivacyBase.from_struct(struct.get("private", default.private)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - EventRoleType.from_struct(struct.get("role", {})) - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/family.py b/gramps/gen/lib/family.py index 2ee59a0fd..d6236b584 100644 --- a/gramps/gen/lib/family.py +++ b/gramps/gen/lib/family.py @@ -127,78 +127,6 @@ class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase, NoteBase.serialize(self), self.change, TagBase.serialize(self), self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Family", - "handle": Handle("Family", self.handle), - "gramps_id": self.gramps_id, - "father_handle": Handle("Person", self.father_handle), - "mother_handle": Handle("Person", self.mother_handle), - "child_ref_list": [cr.to_struct() for cr in self.child_ref_list], - "type": self.type.to_struct(), - "event_ref_list": [er.to_struct() for er in self.event_ref_list], - "media_list": MediaBase.to_struct(self), - "attribute_list": AttributeBase.to_struct(self), - "lds_ord_list": LdsOrdBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Family() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - Handle.from_struct(struct.get("father_handle", - default.father_handle)), - Handle.from_struct(struct.get("mother_handle", - default.mother_handle)), - [ChildRef.from_struct(cr) - for cr in struct.get("child_ref_list", - default.child_ref_list)], - FamilyRelType.from_struct(struct.get("type", {})), - [EventRef.from_struct(er) - for er in struct.get("event_ref_list", - default.event_ref_list)], - MediaBase.from_struct(struct.get("media_list", - default.media_list)), - AttributeBase.from_struct(struct.get("attribute_list", - default.attribute_list)), - LdsOrdBase.from_struct(struct.get("lds_ord_list", - default.lds_ord_list)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - @classmethod def get_schema(cls): from .mediaref import MediaRef diff --git a/gramps/gen/lib/grampstype.py b/gramps/gen/lib/grampstype.py index e55de59ad..3042affea 100644 --- a/gramps/gen/lib/grampstype.py +++ b/gramps/gen/lib/grampstype.py @@ -215,44 +215,6 @@ class GrampsType(object, metaclass=GrampsTypeMeta): "string": _("Family Relationship"), } - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": self.__class__.__name__, - "value": self.__value, - "string": str(self)} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = cls() - if struct.get("value", cls._CUSTOM) == cls._CUSTOM: - return (struct.get("value", default.value), - struct.get("string", "")) - else: - return (struct.get("value", default.value), '') - def unserialize(self, data): """Convert a serialized tuple of data to an object.""" self.__value, self.__string = data diff --git a/gramps/gen/lib/handle.py b/gramps/gen/lib/handle.py index 565c47008..e8fbb14b6 100644 --- a/gramps/gen/lib/handle.py +++ b/gramps/gen/lib/handle.py @@ -53,7 +53,3 @@ def Handle(_classname, handle): classname = _classname h = MyHandleClass(handle) return h - -def __from_struct(struct): - return struct -Handle.from_struct = __from_struct diff --git a/gramps/gen/lib/ldsord.py b/gramps/gen/lib/ldsord.py index d44f21109..c9cef5efe 100644 --- a/gramps/gen/lib/ldsord.py +++ b/gramps/gen/lib/ldsord.py @@ -144,57 +144,6 @@ class LdsOrd(SecondaryObject, CitationBase, NoteBase, self.type, self.place, self.famc, self.temple, self.status, self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "LdsOrd", - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "date": DateBase.to_struct(self), - "type": self.type, - "place": self.place, - "famc": self.famc, - "temple": self.temple, - "status": self.status, - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = LdsOrd() - return (CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - DateBase.from_struct(struct.get("date", {})), - struct.get("type", {}), - struct.get("place", default.place), - struct.get("famc", default.famc), - struct.get("temple", default.temple), - struct.get("status", default.status), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/ldsordbase.py b/gramps/gen/lib/ldsordbase.py index 4b22560ef..b24abac0f 100644 --- a/gramps/gen/lib/ldsordbase.py +++ b/gramps/gen/lib/ldsordbase.py @@ -64,37 +64,6 @@ class LdsOrdBase: """ return [lds_ord.serialize() for lds_ord in self.lds_ord_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [lds_ord.to_struct() for lds_ord in self.lds_ord_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [LdsOrd.from_struct(lds_ord) for lds_ord in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object diff --git a/gramps/gen/lib/location.py b/gramps/gen/lib/location.py index 15b9d10a9..dd5d7f6a8 100644 --- a/gramps/gen/lib/location.py +++ b/gramps/gen/lib/location.py @@ -63,55 +63,6 @@ class Location(SecondaryObject, LocationBase): """ return (LocationBase.serialize(self), self.parish) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Location", - "street": self.street, - "locality": self.locality, - "city": self.city, - "county": self.county, - "state": self.state, - "country": self.country, - "postal": self.postal, - "phone": self.phone, - "parish": self.parish} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Location() - return ((struct.get("street", default.street), - struct.get("locality", default.locality), - struct.get("city", default.city), - struct.get("country", default.country), - struct.get("state", default.state), - struct.get("country", default.country), - struct.get("postal", default.postal), - struct.get("phone", default.phone)), - struct.get("parish", default.parish)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/locationbase.py b/gramps/gen/lib/locationbase.py index dc7373e12..304e24df0 100644 --- a/gramps/gen/lib/locationbase.py +++ b/gramps/gen/lib/locationbase.py @@ -64,55 +64,6 @@ class LocationBase: return (self.street, self.locality, self.city, self.county, self.state, self.country, self.postal, self.phone) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "LocationBase", - "street": self.street, - "locality": self.locality, - "city": self.city, - "county": self.county, - "state": self.state, - "country": self.country, - "postal": self.postal, - "phone": self.phone - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = LocationBase() - return (struct.get("street", default.street), - struct.get("locality", default.locality), - struct.get("city", default.city), - struct.get("county", default.county), - struct.get("state", default.state), - struct.get("country", default.country), - struct.get("postal", default.postal), - struct.get("phone", default.phone)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/media.py b/gramps/gen/lib/media.py index a439f8d48..4c15e57c2 100644 --- a/gramps/gen/lib/media.py +++ b/gramps/gen/lib/media.py @@ -118,41 +118,6 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase, TagBase.serialize(self), self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Media", - "handle": Handle("Media", self.handle), - "gramps_id": self.gramps_id, - "path": self.path, - "mime": self.mime, - "desc": self.desc, - "checksum": self.checksum, - "attribute_list": AttributeBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "change": self.change, - "date": DateBase.to_struct(self), - "tag_list": TagBase.to_struct(self), - "private": self.private} - @classmethod def get_schema(cls): """ @@ -205,28 +170,6 @@ class Media(CitationBase, NoteBase, DateBase, AttributeBase, "private": _("Private"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Media() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - struct.get("path", default.path), - struct.get("mime", default.mime), - struct.get("desc", default.desc), - struct.get("checksum", default.checksum), - AttributeBase.from_struct(struct.get("attribute_list", default.attribute_list)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - struct.get("change", default.change), - DateBase.from_struct(struct.get("date", {})), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/mediabase.py b/gramps/gen/lib/mediabase.py index 76a252173..5205e84b2 100644 --- a/gramps/gen/lib/mediabase.py +++ b/gramps/gen/lib/mediabase.py @@ -56,37 +56,6 @@ class MediaBase: """ return [mref.serialize() for mref in self.media_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [mref.to_struct() for mref in self.media_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [MediaRef.from_struct(mref) for mref in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/mediaref.py b/gramps/gen/lib/mediaref.py index 034369fad..b87df5e2e 100644 --- a/gramps/gen/lib/mediaref.py +++ b/gramps/gen/lib/mediaref.py @@ -70,34 +70,6 @@ class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase, RefBase.serialize(self), self.rect) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "MediaRef", - "private": PrivacyBase.serialize(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "attribute_list": AttributeBase.to_struct(self), - "ref": Handle("Media", self.ref), - "rect": self.rect if self.rect != (0, 0, 0, 0) else None} - @classmethod def get_schema(cls): """ @@ -118,24 +90,6 @@ class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase, "rect": tuple, # or None if (0,0,0,0) } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = MediaRef() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - AttributeBase.from_struct(struct.get("attribute_list", - default.attribute_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - struct.get("rect", default.rect)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/name.py b/gramps/gen/lib/name.py index 571a99cdf..91de6c856 100644 --- a/gramps/gen/lib/name.py +++ b/gramps/gen/lib/name.py @@ -129,70 +129,6 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase, self.group_as, self.sort_as, self.display_as, self.call, self.nick, self.famnick) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Name", - "private": PrivacyBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "date": DateBase.to_struct(self), - "first_name": self.first_name, - "surname_list": SurnameBase.to_struct(self), - "suffix": self.suffix, - "title": self.title, - "type": self.type.to_struct(), - "group_as": self.group_as, - "sort_as": self.sort_as, - "display_as": self.display_as, - "call": self.call, - "nick": self.nick, - "famnick": self.famnick} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Name() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - DateBase.from_struct(struct.get("date", {})), - struct.get("first_name", default.first_name), - SurnameBase.from_struct(struct.get("surname_list", - default.surname_list)), - struct.get("suffix", default.suffix), - struct.get("title", default.title), - NameType.from_struct(struct.get("type", {})), - struct.get("group_as", default.group_as), - struct.get("sort_as", default.sort_as), - struct.get("display_as", default.display_as), - struct.get("call", default.call), - struct.get("nick", default.nick), - struct.get("famnick", default.famnick)) - @classmethod def get_labels(cls, _): return { diff --git a/gramps/gen/lib/note.py b/gramps/gen/lib/note.py index 372da06f6..c7e02334c 100644 --- a/gramps/gen/lib/note.py +++ b/gramps/gen/lib/note.py @@ -95,36 +95,6 @@ class Note(BasicPrimaryObject): self.type.serialize(), self.change, TagBase.serialize(self), self.private) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Note", - "handle": Handle("Note", self.handle), - "gramps_id": self.gramps_id, - "text": self.text.to_struct(), - "format": self.format, - "type": self.type.to_struct(), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - @classmethod def get_schema(cls): """ @@ -154,23 +124,6 @@ class Note(BasicPrimaryObject): "private": _("Private"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Note() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - StyledText.from_struct(struct.get("text", {})), - struct.get("format", default.format), - NoteType.from_struct(struct.get("type", {})), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/notebase.py b/gramps/gen/lib/notebase.py index 2859a1886..6d20224a1 100644 --- a/gramps/gen/lib/notebase.py +++ b/gramps/gen/lib/notebase.py @@ -53,37 +53,6 @@ class NoteBase: """ return self.note_list - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [Handle("Note", n) for n in self.note_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Handle.from_struct(n) for n in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/person.py b/gramps/gen/lib/person.py index 3eec1e30d..c79227e91 100644 --- a/gramps/gen/lib/person.py +++ b/gramps/gen/lib/person.py @@ -157,56 +157,6 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, [pr.serialize() for pr in self.person_ref_list] # 20 ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "Person", - "handle": Handle("Person", self.handle), # 0 - "gramps_id": self.gramps_id, # 1 - "gender": self.__gender, # 2 - "primary_name": self.primary_name.to_struct(), # 3 - "alternate_names": [name.to_struct() - for name in self.alternate_names], # 4 - "death_ref_index": self.death_ref_index, # 5 - "birth_ref_index": self.birth_ref_index, # 6 - "event_ref_list": [er.to_struct() - for er in self.event_ref_list], # 7 - "family_list": [Handle("Family", f) for f in - self.family_list], # 8 - "parent_family_list": [Handle("Family", f) for f in - self.parent_family_list], # 9 - "media_list": MediaBase.to_struct(self), # 10 - "address_list": AddressBase.to_struct(self), # 11 - "attribute_list": AttributeBase.to_struct(self), # 12 - "urls": UrlBase.to_struct(self), # 13 - "lds_ord_list": LdsOrdBase.to_struct(self), # 14 - "citation_list": CitationBase.to_struct(self), # 15 - "note_list": NoteBase.to_struct(self), # 16 - "change": self.change, # 17 - "tag_list": TagBase.to_struct(self), # 18 - "private": self.private, # 19 - "person_ref_list": [pr.to_struct() - for pr in self.person_ref_list] # 20 - } - @classmethod def get_labels(cls, _): return { @@ -234,49 +184,6 @@ class Person(CitationBase, NoteBase, AttributeBase, MediaBase, "probably_alive": _("Probably alive"), } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Person() - return ( - Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - struct.get("gender", default.gender), - Name.from_struct(struct.get("primary_name", {})), - [Name.from_struct(name) - for name in struct.get("alternate_names", - default.alternate_names)], - struct.get("death_ref_index", default.death_ref_index), - struct.get("birth_ref_index", default.birth_ref_index), - [EventRef.from_struct(er) - for er in struct.get("event_ref_list", default.event_ref_list)], - [Handle.from_struct(handle) - for handle in struct.get("family_list", default.family_list)], - [Handle.from_struct(handle) - for handle in struct.get("parent_family_list", - default.parent_family_list)], - MediaBase.from_struct(struct.get("media_list", default.media_list)), - AddressBase.from_struct(struct.get("address_list", - default.address_list)), - AttributeBase.from_struct(struct.get("attribute_list", - default.attribute_list)), - UrlBase.from_struct(struct.get("urls", default.urls)), - LdsOrdBase.from_struct(struct.get("lds_ord_list", - default.lds_ord_list)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private), - [PersonRef.from_struct(p) - for p in struct.get("person_ref_list", default.person_ref_list)] - ) - @classmethod def get_schema(cls): """ diff --git a/gramps/gen/lib/personref.py b/gramps/gen/lib/personref.py index aa12c2b42..78506585c 100644 --- a/gramps/gen/lib/personref.py +++ b/gramps/gen/lib/personref.py @@ -72,47 +72,6 @@ class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase): RefBase.serialize(self), self.rel) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "PersonRef", - "private": PrivacyBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "ref": Handle("Person", self.ref), - "rel": self.rel} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = PersonRef() - return (PrivacyBase.from_struct(struct.get("private", default.private)), - CitationBase.from_struct(struct.get("citation_list", default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - struct.get("rel", default.rel)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/place.py b/gramps/gen/lib/place.py index 6c24cf0fd..6ce434ad7 100644 --- a/gramps/gen/lib/place.py +++ b/gramps/gen/lib/place.py @@ -166,78 +166,6 @@ class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject): "private": bool } - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Place", - "handle": Handle("Place", self.handle), - "gramps_id": self.gramps_id, - "title": self.title, - "long": self.long, - "lat": self.lat, - "placeref_list": [pr.to_struct() for pr in self.placeref_list], - "name": self.name.to_struct(), - "alt_names": [an.to_struct() for an in self.alt_names], - "place_type": self.place_type.to_struct(), - "code": self.code, - "alt_loc": [al.to_struct() for al in self.alt_loc], - "urls": UrlBase.to_struct(self), - "media_list": MediaBase.to_struct(self), - "citation_list": CitationBase.to_struct(self), - "note_list": NoteBase.to_struct(self), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Place() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - struct.get("title", default.title), - struct.get("long", default.long), - struct.get("lat", default.lat), - [PlaceRef.from_struct(pr) - for pr in struct.get("placeref_list", default.placeref_list)], - PlaceName.from_struct(struct.get("name", {})), - [PlaceName.from_struct(an) - for an in struct.get("alt_names", default.alt_names)], - PlaceType.from_struct(struct.get("place_type", {})), - struct.get("code", default.code), - [Location.from_struct(al) - for al in struct.get("alt_loc", default.alt_loc)], - UrlBase.from_struct(struct.get("urls", default.urls)), - MediaBase.from_struct(struct.get("media_list", - default.media_list)), - CitationBase.from_struct(struct.get("citation_list", - default.citation_list)), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/placename.py b/gramps/gen/lib/placename.py index 93dd48d17..80d6fb731 100644 --- a/gramps/gen/lib/placename.py +++ b/gramps/gen/lib/placename.py @@ -71,47 +71,6 @@ class PlaceName(SecondaryObject, DateBase): self.lang ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "PlaceName", - "value": self.value, - "date": DateBase.to_struct(self), - "lang": self.lang - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = PlaceName() - return ( - struct.get("value", default.value), - DateBase.from_struct(struct.get("date", {})), - struct.get("lang", default.lang) - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/placeref.py b/gramps/gen/lib/placeref.py index 75ed7a3d7..c5f1b0970 100644 --- a/gramps/gen/lib/placeref.py +++ b/gramps/gen/lib/placeref.py @@ -63,45 +63,6 @@ class PlaceRef(RefBase, DateBase, SecondaryObject): DateBase.serialize(self) ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "PlaceRef", - "ref": Handle("Place", self.ref), - "date": DateBase.to_struct(self) - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = PlaceRef() - return ( - RefBase.from_struct(struct.get("ref", default.ref)), - DateBase.from_struct(struct.get("date", {})) - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/primaryobj.py b/gramps/gen/lib/primaryobj.py index 3992aff31..59a1a1342 100644 --- a/gramps/gen/lib/primaryobj.py +++ b/gramps/gen/lib/primaryobj.py @@ -90,43 +90,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase, TagBase): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def set_gramps_id(self, gramps_id): """ Set the Gramps ID for the primary object. @@ -278,43 +241,6 @@ class PrimaryObject(BasicPrimaryObject): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def has_handle_reference(self, classname, handle): """ Return True if the object has reference to a given handle of given diff --git a/gramps/gen/lib/privacybase.py b/gramps/gen/lib/privacybase.py index c4b2d3923..872531c4a 100644 --- a/gramps/gen/lib/privacybase.py +++ b/gramps/gen/lib/privacybase.py @@ -55,37 +55,6 @@ class PrivacyBase: """ return self.private - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: bool - """ - return self.private - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return struct - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/refbase.py b/gramps/gen/lib/refbase.py index 0a0013705..8ca742bf4 100644 --- a/gramps/gen/lib/refbase.py +++ b/gramps/gen/lib/refbase.py @@ -53,15 +53,6 @@ class RefBase(metaclass=ABCMeta): """ return self.ref - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return str(struct) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/repo.py b/gramps/gen/lib/repo.py index e0a3edcd2..bd94a8436 100644 --- a/gramps/gen/lib/repo.py +++ b/gramps/gen/lib/repo.py @@ -104,57 +104,6 @@ class Repository(NoteBase, AddressBase, UrlBase, IndirectCitationBase, "private": bool } - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Repository", - "handle": Handle("Repository", self.handle), - "gramps_id": self.gramps_id, - "type": self.type.to_struct(), - "name": str(self.name), - "note_list": NoteBase.to_struct(self), - "address_list": AddressBase.to_struct(self), - "urls": UrlBase.to_struct(self), - "change": self.change, - "tag_list": TagBase.to_struct(self), - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Repository() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - RepositoryType.from_struct(struct.get("type", {})), - struct.get("name", default.name), - NoteBase.from_struct(struct.get("note_list", default.note_list)), - AddressBase.from_struct(struct.get("address_list", default.address_list)), - UrlBase.from_struct(struct.get("urls", default.urls)), - struct.get("change", default.change), - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/reporef.py b/gramps/gen/lib/reporef.py index 53e79603c..fe9717c4f 100644 --- a/gramps/gen/lib/reporef.py +++ b/gramps/gen/lib/reporef.py @@ -69,51 +69,6 @@ class RepoRef(SecondaryObject, PrivacyBase, NoteBase, RefBase): PrivacyBase.serialize(self), ) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return { - "_class": "RepositoryRef", - "note_list": NoteBase.to_struct(self), - "ref": Handle("Repository", self.ref), - "call_number": self.call_number, - "media_type": self.media_type.to_struct(), - "private": PrivacyBase.serialize(self), - } - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = RepoRef() - return ( - NoteBase.from_struct(struct.get("note_list", default.note_list)), - RefBase.from_struct(struct.get("ref", default.ref)), - struct.get("call_number", default.call_number), - SourceMediaType.from_struct(struct.get("media_type", {})), - struct.get("private", default.private), - ) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/researcher.py b/gramps/gen/lib/researcher.py index 309138c62..5a8caf270 100644 --- a/gramps/gen/lib/researcher.py +++ b/gramps/gen/lib/researcher.py @@ -60,59 +60,6 @@ class Researcher(LocationBase): return (LocationBase.serialize(self), self.name, self.addr, self.email) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Researcher", - "street": self.street, - "locality": self.locality, - "city": self.city, - "county": self.county, - "state": self.state, - "country": self.country, - "postal": self.postal, - "phone": self.phone, - "name": self.name, - "address": self.addr, - "email": self.email} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Researcher() - return (struct.get("street", default.street), - struct.get("locality", default.locality), - struct.get("city", default.city), - struct.get("country", default.country), - struct.get("state", default.state), - struct.get("country", default.country), - struct.get("postal", default.postal), - struct.get("phone", default.phone), - struct.get("name", default.name), - struct.get("address", default.addr), - struct.get("email", default.email)) - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/secondaryobj.py b/gramps/gen/lib/secondaryobj.py index 36165e312..4222f60ec 100644 --- a/gramps/gen/lib/secondaryobj.py +++ b/gramps/gen/lib/secondaryobj.py @@ -59,43 +59,6 @@ class SecondaryObject(BaseObject): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def is_equal(self, source): return self.serialize() == source.serialize() diff --git a/gramps/gen/lib/serialize.py b/gramps/gen/lib/serialize.py new file mode 100644 index 000000000..5e4dcea14 --- /dev/null +++ b/gramps/gen/lib/serialize.py @@ -0,0 +1,89 @@ +# +# Gramps - a GTK+/GNOME based genealogy program +# +# Copyright (C) 2017 Nick Hall +# +# 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 +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# + +""" +Serialization utilities for Gramps. +""" + +#------------------------------------------------------------------------ +# +# Python modules +# +#------------------------------------------------------------------------ +import json + +#------------------------------------------------------------------------ +# +# Gramps modules +# +#------------------------------------------------------------------------ +import gramps.gen.lib as lib + +def __default(obj): + obj_dict = {'_class': obj.__class__.__name__} + if isinstance(obj, lib.GrampsType): + obj_dict['string'] = getattr(obj, 'string') + if isinstance(obj, lib.Date): + if obj.is_empty() and not obj.text: + return None + for key, value in obj.__dict__.items(): + if not key.startswith('_'): + obj_dict[key] = value + for key, value in obj.__class__.__dict__.items(): + if isinstance(value, property): + if key != 'year': + obj_dict[key] = getattr(obj, key) + return obj_dict + +def __object_hook(obj_dict): + obj = getattr(lib, obj_dict['_class'])() + for key, value in obj_dict.items(): + if key != '_class': + if key in ('dateval', 'rect') and value is not None: + value = tuple(value) + if key == 'ranges': + value = [tuple(item) for item in value] + setattr(obj, key, value) + if obj_dict['_class'] == 'Date': + if obj.is_empty() and not obj.text: + return None + return obj + +def to_json(obj): + """ + Encode a Gramps object in JSON format. + + :param obj: The object to be serialized. + :type obj: object + :returns: A JSON string. + :rtype: str + """ + return json.dumps(obj, default=__default) + +def from_json(data): + """ + Decode JSON data into a Gramps object hierarchy. + + :param data: The JSON string to be unserialized. + :type data: str + :returns: A Gramps object. + :rtype: object + """ + return json.loads(data, object_hook=__object_hook) diff --git a/gramps/gen/lib/src.py b/gramps/gen/lib/src.py index b6dc9417b..6cb988a62 100644 --- a/gramps/gen/lib/src.py +++ b/gramps/gen/lib/src.py @@ -121,67 +121,6 @@ class Source(MediaBase, NoteBase, SrcAttributeBase, IndirectCitationBase, "private": bool } - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Source", - "handle": Handle("Source", self.handle), - "gramps_id": self.gramps_id, - "title": str(self.title), - "author": str(self.author), - "pubinfo": str(self.pubinfo), - "note_list": NoteBase.to_struct(self), - "media_list": MediaBase.to_struct(self), - "abbrev": str(self.abbrev), - "change": self.change, - "srcattr_list": SrcAttributeBase.to_struct(self), - "reporef_list": [rr.to_struct() for rr in self.reporef_list], - "tag_list": TagBase.to_struct(self), - "private": self.private} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - from .srcattribute import SrcAttribute - default = Source() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("gramps_id", default.gramps_id), - struct.get("title", default.title), - struct.get("author", default.author), - struct.get("pubinfo", default.pubinfo), - NoteBase.from_struct(struct.get("note_list", - default.note_list)), - MediaBase.from_struct(struct.get("media_list", - default.media_list)), - struct.get("abbrev", default.abbrev), - struct.get("change", default.change), - SrcAttributeBase.from_struct(struct.get("srcattr_list", {})), - [RepoRef.from_struct(rr) - for rr in struct.get("reporef_list", default.reporef_list)], - TagBase.from_struct(struct.get("tag_list", default.tag_list)), - struct.get("private", default.private)) - def unserialize(self, data): """ Convert the data held in a tuple created by the serialize method diff --git a/gramps/gen/lib/styledtext.py b/gramps/gen/lib/styledtext.py index 4ec33bee7..fed0a5474 100644 --- a/gramps/gen/lib/styledtext.py +++ b/gramps/gen/lib/styledtext.py @@ -288,47 +288,6 @@ class StyledText: return (self._string, the_tags) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :return: Returns a struct containing the data of the object. - :rtype: dict - """ - if self._tags: - the_tags = [tag.to_struct() for tag in self._tags] - else: - the_tags = [] - - return {"_class": "StyledText", - "string": self._string, - "tags": the_tags} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :return: Returns a serialized object - """ - default = StyledText() - return (struct.get("string", default.string), - [StyledTextTag.from_struct(t) - for t in struct.get("tags", default.tags)]) - @classmethod def get_schema(cls): """ @@ -372,14 +331,29 @@ class StyledText: """ return self._tags + def set_tags(self, tags): + """ + Set the list of formatting tags. + + :param tags: The formatting tags applied on the text. + :type tags: list of 0 or more :py:class:`.StyledTextTag` instances. + """ + self._tags = tags + def get_string(self): """ Accessor for the associated string. """ return self._string - tags = property(get_tags) - string = property(get_string) + def set_string(self, string): + """ + Setter for the associated string. + """ + self._string = string + + tags = property(get_tags, set_tags) + string = property(get_string, set_string) if __name__ == '__main__': from .styledtexttagtype import StyledTextTagType diff --git a/gramps/gen/lib/styledtexttag.py b/gramps/gen/lib/styledtexttag.py index 61603c3a1..f6dfc73d7 100644 --- a/gramps/gen/lib/styledtexttag.py +++ b/gramps/gen/lib/styledtexttag.py @@ -72,43 +72,6 @@ class StyledTextTag: """ return (self.name.serialize(), self.value, self.ranges) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :return: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "StyledTextTag", - "name": self.name.to_struct(), - "value": self.value, - "ranges": self.ranges} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :return: Returns a serialized object - """ - default = StyledTextTag() - return (StyledTextTagType.from_struct(struct.get("name", {})), - struct.get("value", default.value), - struct.get("ranges", default.ranges)) - def unserialize(self, data): """Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/surname.py b/gramps/gen/lib/surname.py index f92236290..22ddeda26 100644 --- a/gramps/gen/lib/surname.py +++ b/gramps/gen/lib/surname.py @@ -71,33 +71,6 @@ class Surname(SecondaryObject): return (self.surname, self.prefix, self.primary, self.origintype.serialize(), self.connector) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Surname", - "surname": self.surname, - "prefix": self.prefix, - "primary": self.primary, - "origintype": self.origintype.to_struct(), - "connector": self.connector} - @classmethod def get_schema(cls): return { @@ -119,20 +92,6 @@ class Surname(SecondaryObject): "connector": _("Connector") } - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Surname() - return (struct.get("surname", default.surname), - struct.get("prefix", default.prefix), - struct.get("primary", default.primary), - NameOriginType.from_struct(struct.get("origintype", {})), - struct.get("connector", default.connector)) - def is_empty(self): """ Indicate if the surname is empty. diff --git a/gramps/gen/lib/surnamebase.py b/gramps/gen/lib/surnamebase.py index 4aae88fb3..13ec123cb 100644 --- a/gramps/gen/lib/surnamebase.py +++ b/gramps/gen/lib/surnamebase.py @@ -60,37 +60,6 @@ class SurnameBase: """ return [surname.serialize() for surname in self.surname_list] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [surname.to_struct() for surname in self.surname_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Surname.from_struct(surname) for surname in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/tableobj.py b/gramps/gen/lib/tableobj.py index 0bf5973e9..9332fc0f1 100644 --- a/gramps/gen/lib/tableobj.py +++ b/gramps/gen/lib/tableobj.py @@ -92,43 +92,6 @@ class TableObject(BaseObject): Convert a serialized tuple of data to an object. """ - @abstractmethod - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - """ - - @abstractmethod - def from_struct(self, struct): - """ - Given a struct data representation, return an object of this type. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns an object of this type. - """ - def get_change_time(self): """ Return the time that the data was last changed. diff --git a/gramps/gen/lib/tag.py b/gramps/gen/lib/tag.py index 2b0f992fe..44dc3c75d 100644 --- a/gramps/gen/lib/tag.py +++ b/gramps/gen/lib/tag.py @@ -225,46 +225,5 @@ class Tag(TableObject): """ return self.__priority - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Tag", - "handle": Handle("Tag", self.handle), - "name": self.__name, - "color": self.__color, - "priority": self.__priority, - "change": self.change} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Tag() - return (Handle.from_struct(struct.get("handle", default.handle)), - struct.get("name", default.name), - struct.get("color", default.color), - struct.get("priority", default.priority), - struct.get("change", default.change)) - priority = property(get_priority, set_priority, None, 'Returns or sets priority of the tag') diff --git a/gramps/gen/lib/tagbase.py b/gramps/gen/lib/tagbase.py index e8e9e32c0..05f85c2c2 100644 --- a/gramps/gen/lib/tagbase.py +++ b/gramps/gen/lib/tagbase.py @@ -55,37 +55,6 @@ class TagBase: """ return self.tag_list - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [Handle('Tag', t) for t in self.tag_list] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Handle.from_struct(t) for t in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/lib/test/date_test.py b/gramps/gen/lib/test/date_test.py index e26ac426a..c6a6611e1 100644 --- a/gramps/gen/lib/test/date_test.py +++ b/gramps/gen/lib/test/date_test.py @@ -245,7 +245,8 @@ class ParserDateTest(BaseDateTest): "dateval fails is_equal in format %d:\n" " '%s' != '%s'\n" " '%s' != '%s'\n" % - (date_format, dateval, ndate, dateval.to_struct(), ndate.to_struct())) + (date_format, dateval, ndate, + dateval.__dict__, ndate.__dict__)) def test_basic(self): self.do_case("basic test") @@ -380,7 +381,7 @@ class MatchDateTest(BaseDateTest): d1, ("did not match" if expected else "matched"), d2, - date1.to_struct(), date2.to_struct())) + date1.__dict__, date2.__dict__)) def test_match(self): for testdata in self.tests: diff --git a/gramps/gen/lib/test/struct_test.py b/gramps/gen/lib/test/serialize_test.py similarity index 82% rename from gramps/gen/lib/test/struct_test.py rename to gramps/gen/lib/test/serialize_test.py index 83db0cf63..aa644b85f 100644 --- a/gramps/gen/lib/test/struct_test.py +++ b/gramps/gen/lib/test/serialize_test.py @@ -18,13 +18,14 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # -""" Unittest for to_struct, from_struct """ +""" Unittest for to_json, from_json """ import unittest import os -from .. import (Person, Family, Event, Source, Place, Citation, - Repository, Media, Note, Tag) +from .. import (Person, Family, Event, Source, Place, Citation, + Repository, Media, Note, Tag) +from ..serialize import to_json, from_json from gramps.gen.db.utils import import_as_dict from gramps.cli.user import User from gramps.gen.const import DATA_DIR @@ -33,14 +34,15 @@ TEST_DIR = os.path.abspath(os.path.join(DATA_DIR, "tests")) EXAMPLE = os.path.join(TEST_DIR, "example.gramps") class BaseCheck: - def test_from_struct(self): - struct = self.object.to_struct() - serialized = self.cls.from_struct(struct) - self.assertEqual(self.object.serialize(), serialized) + def test_from_json(self): + data = to_json(self.object) + obj = from_json(data) + self.assertEqual(self.object.serialize(), obj.serialize()) - def test_from_empty_struct(self): - serialized = self.cls.from_struct({}) - self.assertEqual(self.object.serialize(), serialized) + def test_from_empty_json(self): + data = '{"_class": "%s"}' % self.cls.__name__ + obj = from_json(data) + self.assertEqual(self.object.serialize(), obj.serialize()) class PersonCheck(unittest.TestCase, BaseCheck): def setUp(self): @@ -99,10 +101,10 @@ def generate_case(obj): """ Dynamically generate tests and attach to DatabaseCheck. """ - struct = obj.to_struct() - serialized = obj.__class__.from_struct(struct) + data = to_json(obj) + obj2 = from_json(data) def test(self): - self.assertEqual(obj.serialize(), serialized) + self.assertEqual(obj.serialize(), obj2.serialize()) name = "test_serialize_%s_%s" % (obj.__class__.__name__, obj.handle) setattr(DatabaseCheck, name, test) #### diff --git a/gramps/gen/lib/url.py b/gramps/gen/lib/url.py index e773f32f5..9bc837e72 100644 --- a/gramps/gen/lib/url.py +++ b/gramps/gen/lib/url.py @@ -67,45 +67,6 @@ class Url(SecondaryObject, PrivacyBase): def serialize(self): return (self.private, self.path, self.desc, self.type.serialize()) - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: dict - """ - return {"_class": "Url", - "private": self.private, - "path": self.path, - "desc": self.desc, - "type": self.type.to_struct()} - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - default = Url() - return (struct.get("private", default.private), - struct.get("path", default.path), - struct.get("desc", default.desc), - UrlType.from_struct(struct.get("type", {}))) - def unserialize(self, data): (self.private, self.path, self.desc, type_value) = data self.type.unserialize(type_value) diff --git a/gramps/gen/lib/urlbase.py b/gramps/gen/lib/urlbase.py index f7f6f6a61..3bc59fad6 100644 --- a/gramps/gen/lib/urlbase.py +++ b/gramps/gen/lib/urlbase.py @@ -58,37 +58,6 @@ class UrlBase: """ return [url.serialize() for url in self.urls] - def to_struct(self): - """ - Convert the data held in this object to a structure (eg, - struct) that represents all the data elements. - - This method is used to recursively convert the object into a - self-documenting form that can easily be used for various - purposes, including diffs and queries. - - These structures may be primitive Python types (string, - integer, boolean, etc.) or complex Python types (lists, - tuples, or dicts). If the return type is a dict, then the keys - of the dict match the fieldname of the object. If the return - struct (or value of a dict key) is a list, then it is a list - of structs. Otherwise, the struct is just the value of the - attribute. - - :returns: Returns a struct containing the data of the object. - :rtype: list - """ - return [url.to_struct() for url in self.urls] - - @classmethod - def from_struct(cls, struct): - """ - Given a struct data representation, return a serialized object. - - :returns: Returns a serialized object - """ - return [Url.from_struct(url) for url in struct] - def unserialize(self, data): """ Convert a serialized tuple of data to an object. diff --git a/gramps/gen/merge/diff.py b/gramps/gen/merge/diff.py index c72923281..8340ee8fd 100644 --- a/gramps/gen/merge/diff.py +++ b/gramps/gen/merge/diff.py @@ -22,11 +22,20 @@ This package implements an object difference engine. """ +import json + from gramps.cli.user import User from ..db.utils import import_as_dict +from ..lib.serialize import to_json from ..const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext +def to_struct(obj): + """ + Convert an object into a struct. + """ + return json.loads(to_json(obj)) + def diff_dates(json1, json2): """ Compare two json date objects. Returns True if different. @@ -110,7 +119,7 @@ def diff_dbs(db1, db2, user=None): if handles1[p1] == handles2[p2]: # in both item1 = db1.get_table_func(item,"handle_func")(handles1[p1]) item2 = db2.get_table_func(item,"handle_func")(handles2[p2]) - diff = diff_items(item, item1.to_struct(), item2.to_struct()) + diff = diff_items(item, to_struct(item1), to_struct(item2)) if diff: diffs += [(item, item1, item2)] # else same! diff --git a/gramps/gui/editors/editdate.py b/gramps/gui/editors/editdate.py index d6dc3abc1..eb91e1948 100644 --- a/gramps/gui/editors/editdate.py +++ b/gramps/gui/editors/editdate.py @@ -258,7 +258,7 @@ class EditDate(ManagedWindow): newyear=the_newyear) # didn't throw yet? self.validated_date = d - LOG.debug("validated_date set to: {0}".format(d.to_struct())) + LOG.debug("validated_date set to: {0}".format(d.__dict__)) self.ok_button.set_sensitive(1) self.calendar_box.set_sensitive(1) return True diff --git a/gramps/gui/editors/edittaglist.py b/gramps/gui/editors/edittaglist.py index 69b168038..62bb4824b 100644 --- a/gramps/gui/editors/edittaglist.py +++ b/gramps/gui/editors/edittaglist.py @@ -61,7 +61,9 @@ class EditTagList(ManagedWindow): """ Initiate and display the dialog. """ - ManagedWindow.__init__(self, uistate, track, self) + ManagedWindow.__init__(self, uistate, track, self, modal=True) + # the self.window.run() below makes Gtk make it modal, so any change + # to the previous line's "modal" would require that line to be changed self.namemodel = None top = self._create_dialog() @@ -78,6 +80,8 @@ class EditTagList(ManagedWindow): self.show() while True: + # the self.window.run() makes Gtk make it modal, so any change to + # that line means the ManagedWindow.__init__ must be changed also response = self.window.run() if response == Gtk.ResponseType.HELP: display_help(webpage=WIKI_HELP_PAGE, @@ -97,9 +101,7 @@ class EditTagList(ManagedWindow): Create a dialog box to select tags. """ # pylint: disable-msg=E1101 - title = _("%(title)s - Gramps") % {'title': _("Edit Tags")} - top = Gtk.Dialog(title, self.uistate.window) - top.set_modal(True) + top = Gtk.Dialog(parent=self.uistate.window) top.vbox.set_spacing(5) columns = [('', -1, 300), @@ -116,10 +118,9 @@ class EditTagList(ManagedWindow): top.add_button(_('_Help'), Gtk.ResponseType.HELP) top.add_button(_('_Cancel'), Gtk.ResponseType.CANCEL) top.add_button(_('_OK'), Gtk.ResponseType.OK) - top.show_all() return top - def build_menu_names(self, obj): + def build_menu_names(self, obj): # meaningless while it's modal """ Define the menu entry for the ManagedWindows. """ diff --git a/gramps/gui/managedwindow.py b/gramps/gui/managedwindow.py index 61e6e5348..063e0f15c 100644 --- a/gramps/gui/managedwindow.py +++ b/gramps/gui/managedwindow.py @@ -266,7 +266,7 @@ class GrampsWindowManager: if not isinstance(item, list): def func(obj): if item.window_id and self.id2item.get(item.window_id): - self.id2item[item.window_id].__present() + self.id2item[item.window_id]._present() else: def func(obj): pass @@ -418,7 +418,7 @@ class ManagedWindow: self.other_modal_window = None if uistate and uistate.gwm.get_item_from_id(window_key): - uistate.gwm.get_item_from_id(window_key).__present() + uistate.gwm.get_item_from_id(window_key)._present() raise WindowActiveError('This window is already active') else: self.window_id = window_key @@ -568,7 +568,7 @@ class ManagedWindow: self.other_modal_window.set_modal(True) self.parent_window.present() - def __present(self): + def _present(self): """ Present window (unroll/unminimize/bring to top). """ diff --git a/gramps/gui/merge/mergeplace.py b/gramps/gui/merge/mergeplace.py index 5c2b96e38..b5e611f21 100644 --- a/gramps/gui/merge/mergeplace.py +++ b/gramps/gui/merge/mergeplace.py @@ -154,7 +154,7 @@ class MergePlace(ManagedWindow): rbutton_label1 = self.get_widget("label_handle_btn1") rbutton_label2 = self.get_widget("label_handle_btn2") rbutton_label1.set_label(title1 + " [" + gramps1 + "] " + str(self.pl1.place_type)) - rbutton_label2.set_label(title2 + " [" + gramps2 + "] " + str(self.pl1.place_type)) + rbutton_label2.set_label(title2 + " [" + gramps2 + "] " + str(self.pl2.place_type)) rbutton1.connect("toggled", self.on_handle1_toggled) self.connect_button('place_help', self.cb_help) diff --git a/gramps/gui/plug/quick/_quickreports.py b/gramps/gui/plug/quick/_quickreports.py index 4cca1f298..46948c394 100644 --- a/gramps/gui/plug/quick/_quickreports.py +++ b/gramps/gui/plug/quick/_quickreports.py @@ -257,14 +257,12 @@ def run_report(dbstate, uistate, category, handle, pdata, container=None, elif category == CATEGORY_QR_CITATION : obj = dbstate.db.get_citation_from_handle(handle) elif category == CATEGORY_QR_SOURCE_OR_CITATION : - source = dbstate.db.get_source_from_handle(handle) - citation = dbstate.db.get_citation_from_handle(handle) - if (not source and not citation) or (source and citation): - raise ValueError("selection must be either source or citation") - if citation: - obj = citation + if dbstate.db.has_source_handle(handle): + obj = dbstate.db.get_source_from_handle(handle) + elif dbstate.db.has_citation_handle(handle): + obj = dbstate.db.get_citation_from_handle(handle) else: - obj = source + raise ValueError("selection must be either source or citation") elif category == CATEGORY_QR_PLACE : obj = dbstate.db.get_place_from_handle(handle) elif category == CATEGORY_QR_MEDIA : diff --git a/gramps/gui/selectors/baseselector.py b/gramps/gui/selectors/baseselector.py index a622a8fc9..726fca841 100644 --- a/gramps/gui/selectors/baseselector.py +++ b/gramps/gui/selectors/baseselector.py @@ -268,11 +268,10 @@ class BaseSelector(ManagedWindow): #reset the model with correct sorting self.clear_model() - self.model = self.get_model_class()(self.db, self.sort_col, - self.sortorder, - sort_map=self.column_order(), - skip=self.skip_list, - search=filter_info) + self.model = self.get_model_class()( + self.db, self.uistate, self.sort_col, self.sortorder, + sort_map=self.column_order(), skip=self.skip_list, + search=filter_info) self.tree.set_model(self.model) @@ -317,11 +316,10 @@ class BaseSelector(ManagedWindow): def show_toggle(self, obj): filter_info = None if obj.get_active() else self.filter self.clear_model() - self.model = self.get_model_class()(self.db, self.sort_col, - self.sortorder, - sort_map=self.column_order(), - skip=self.skip_list, - search=filter_info) + self.model = self.get_model_class()( + self.db, self.uistate, self.sort_col, self.sortorder, + sort_map=self.column_order(), skip=self.skip_list, + search=filter_info) self.tree.set_model(self.model) self.tree.grab_focus() diff --git a/gramps/gui/tipofday.py b/gramps/gui/tipofday.py index 26b75db83..4d0686bd5 100644 --- a/gramps/gui/tipofday.py +++ b/gramps/gui/tipofday.py @@ -96,7 +96,7 @@ class TipOfDay(ManagedWindow): self.index = 0 self.next_tip_cb() - window.show_all() + self.show() def escape(self,text): text = text.replace('&','&'); # Must be first diff --git a/gramps/gui/undohistory.py b/gramps/gui/undohistory.py index dd38c0d7d..5e4750fdd 100644 --- a/gramps/gui/undohistory.py +++ b/gramps/gui/undohistory.py @@ -91,7 +91,7 @@ class UndoHistory(ManagedWindow): Gtk.ResponseType.CLOSE) self.set_window(window, None, self.title) - self.setup_configs('interface.undohistory', 400, 200) + self.setup_configs('interface.undohistory', 500, 200) self.window.connect('response', self._response) scrolled_window = Gtk.ScrolledWindow() @@ -119,7 +119,6 @@ class UndoHistory(ManagedWindow): scrolled_window.add(self.tree) self.window.vbox.pack_start(scrolled_window, True, True, 0) - self.window.show_all() self._build_model() self._update_ui() diff --git a/gramps/gui/views/bookmarks.py b/gramps/gui/views/bookmarks.py index ae23957ac..fa4d5751a 100644 --- a/gramps/gui/views/bookmarks.py +++ b/gramps/gui/views/bookmarks.py @@ -50,6 +50,7 @@ from gi.repository import Gtk #------------------------------------------------------------------------- from ..display import display_help from ..listmodel import ListModel +from ..managedwindow import ManagedWindow from gramps.gen.utils.db import navigation_label from gramps.gen.const import URL_MANUAL_PAGE from gramps.gen.const import GRAMPS_LOCALE as glocale @@ -98,14 +99,6 @@ class Bookmarks(metaclass=ABCMeta): self.dbstate.connect('database-changed', self.db_changed) self.dbstate.connect("no-database", self.undisplay) - # initialise attributes - self.namemodel = None - self.namemodel_cols = None - self.top = None - self.modified = None - self.response = None - self.namelist = None - def db_changed(self, data): """ Reconnect the signals on a database changed. @@ -222,13 +215,50 @@ class Bookmarks(metaclass=ABCMeta): if modified: self.redraw_and_report_change() + def edit(self): + """ + Display the bookmark editor. + + The current bookmarked people are inserted into the namelist, + attaching the person object to the corresponding row. The currently + selected row is attached to the name list. This is either 0 if the + list is not empty, or -1 if it is. + """ + BookmarksDialog(self) + +class BookmarksDialog(ManagedWindow): + """ + A dialog to enable the user to organize bookmarks. + """ + + def __init__(self, bm_class): + + self.bm_class = bm_class + self.bookmarks = bm_class.bookmarks + self.dbstate = bm_class.dbstate + self.make_label = bm_class.make_label + uistate = bm_class.uistate + + self.namemodel = None + self.top = None + self.modified = None + self.response = None + self.namelist = None + + ManagedWindow.__init__(self, uistate, [], self.__class__, modal=True) + # the self.top.run() below makes Gtk make it modal, so any change to + # the previous line's "modal" would require that line to be changed + + self.draw_window() + self.set_window(self.top, None, _("Organize Bookmarks")) + self.setup_configs('interface.bookmarksdialog', 400, 350) + self.show() + self.edit() + self.close() + def draw_window(self): """Draw the bookmark dialog box.""" - title = _("%(title)s - Gramps") % {'title': _("Organize Bookmarks")} - self.top = Gtk.Dialog(title) - self.top.set_default_size(400, 350) - self.top.set_modal(True) - self.top.set_transient_for(self.uistate.window) + self.top = Gtk.Dialog(parent=self.parent_window) self.top.vbox.set_spacing(5) label = Gtk.Label(label='%s' % _("Organize Bookmarks")) @@ -240,7 +270,6 @@ class Bookmarks(metaclass=ABCMeta): name_titles = [(_('Name'), -1, 200), (_('ID'), -1, 50), ('', -1, 0)] self.namelist = Gtk.TreeView() self.namemodel = ListModel(self.namelist, name_titles) - self.namemodel_cols = len(name_titles) slist = Gtk.ScrolledWindow() slist.add(self.namelist) @@ -262,11 +291,6 @@ class Bookmarks(metaclass=ABCMeta): bbox.add(down) bbox.add(delete) box.pack_start(bbox, 0, 0, 5) - self.top.show_all() - - def close(self, widget, event): - """Stop the bookmark organizer""" - self.top.response(Gtk.ResponseType.CLOSE) def edit(self): """ @@ -277,7 +301,6 @@ class Bookmarks(metaclass=ABCMeta): selected row is attached to the name list. This is either 0 if the list is not empty, or -1 if it is. """ - self.draw_window() for handle in self.bookmarks.get(): name, obj = self.make_label(handle) if obj: @@ -287,13 +310,14 @@ class Bookmarks(metaclass=ABCMeta): self.modified = False while True: + # the self.top.run() makes Gtk make it modal, so any change to that + # line would require the ManagedWindow.__init__ to be changed also self.response = self.top.run() if self.response == Gtk.ResponseType.HELP: self.help_clicked() elif self.response == Gtk.ResponseType.CLOSE: if self.modified: - self.redraw_and_report_change() - self.top.destroy() + self.bm_class.redraw_and_report_change() break def delete_clicked(self, obj): @@ -329,6 +353,9 @@ class Bookmarks(metaclass=ABCMeta): """Display the relevant portion of GRAMPS manual.""" display_help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC) + def build_menu_names(self, obj): # this is meaningless while it's modal + return (_('Organize Bookmarks'), None) + class ListBookmarks(Bookmarks): """ Derived class from which all the specific type bookmark handlers are in turn derived""" diff --git a/gramps/gui/views/listview.py b/gramps/gui/views/listview.py index efc055606..2409f7bec 100644 --- a/gramps/gui/views/listview.py +++ b/gramps/gui/views/listview.py @@ -320,9 +320,9 @@ class ListView(NavigationView): if self.model: self.list.set_model(None) self.model.destroy() - self.model = self.make_model(self.dbstate.db, self.sort_col, - search=filter_info, - sort_map=self.column_order()) + self.model = self.make_model( + self.dbstate.db, self.uistate, self.sort_col, + search=filter_info, sort_map=self.column_order()) else: #the entire data to show is already in memory. #run only the part that determines what to show @@ -647,10 +647,9 @@ class ListView(NavigationView): self.model.reverse_order() self.list.set_model(self.model) else: - self.model = self.make_model(self.dbstate.db, self.sort_col, - self.sort_order, - search=filter_info, - sort_map=self.column_order()) + self.model = self.make_model( + self.dbstate.db, self.uistate, self.sort_col, self.sort_order, + search=filter_info, sort_map=self.column_order()) self.list.set_model(self.model) diff --git a/gramps/gui/views/treemodels/citationlistmodel.py b/gramps/gui/views/treemodels/citationlistmodel.py index 992f00acd..992c1ebcf 100644 --- a/gramps/gui/views/treemodels/citationlistmodel.py +++ b/gramps/gui/views/treemodels/citationlistmodel.py @@ -56,8 +56,8 @@ class CitationListModel(CitationBaseModel, FlatBaseModel): """ Flat citation model. (Original code in CitationBaseModel). """ - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): self.map = db.get_raw_citation_data self.gen_cursor = db.get_citation_cursor self.fmap = [ @@ -94,8 +94,8 @@ class CitationListModel(CitationBaseModel, FlatBaseModel): self.citation_src_chan, self.citation_tag_color ] - FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, - sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, scol, order, search=search, + skip=skip, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/citationtreemodel.py b/gramps/gui/views/treemodels/citationtreemodel.py index 822e734ad..c7763a3ef 100644 --- a/gramps/gui/views/treemodels/citationtreemodel.py +++ b/gramps/gui/views/treemodels/citationtreemodel.py @@ -65,8 +65,8 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel): """ Hierarchical citation model. """ - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): self.db = db self.number_items = self.db.get_number_of_sources self.map = self.db.get_raw_source_data @@ -100,7 +100,7 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel): self.source_src_tag_color ] - TreeBaseModel.__init__(self, self.db, scol=scol, order=order, + TreeBaseModel.__init__(self, self.db, uistate, scol=scol, order=order, search=search, skip=skip, sort_map=sort_map, nrgroups=1, group_can_have_handle=True, diff --git a/gramps/gui/views/treemodels/eventmodel.py b/gramps/gui/views/treemodels/eventmodel.py index 2b6436e27..b1b9c9dda 100644 --- a/gramps/gui/views/treemodels/eventmodel.py +++ b/gramps/gui/views/treemodels/eventmodel.py @@ -71,8 +71,8 @@ INVALID_DATE_FORMAT = config.get('preferences.invalid-date-format') #------------------------------------------------------------------------- class EventModel(FlatBaseModel): - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): self.gen_cursor = db.get_event_cursor self.map = db.get_raw_event_data @@ -100,8 +100,8 @@ class EventModel(FlatBaseModel): self.column_participant, self.column_tag_color ] - FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, - sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, scol, order, search=search, + skip=skip, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/familymodel.py b/gramps/gui/views/treemodels/familymodel.py index cac4c34e6..28f89ab68 100644 --- a/gramps/gui/views/treemodels/familymodel.py +++ b/gramps/gui/views/treemodels/familymodel.py @@ -56,8 +56,8 @@ invalid_date_format = config.get('preferences.invalid-date-format') #------------------------------------------------------------------------- class FamilyModel(FlatBaseModel): - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): self.gen_cursor = db.get_family_cursor self.map = db.get_raw_family_data self.fmap = [ @@ -82,8 +82,8 @@ class FamilyModel(FlatBaseModel): self.sort_change, self.column_tag_color, ] - FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, - sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, scol, order, search=search, + skip=skip, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/flatbasemodel.py b/gramps/gui/views/treemodels/flatbasemodel.py index 314ba82b6..bf05c4f57 100644 --- a/gramps/gui/views/treemodels/flatbasemodel.py +++ b/gramps/gui/views/treemodels/flatbasemodel.py @@ -450,7 +450,7 @@ class FlatBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): so as to have localized sort """ - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, search=None, skip=set(), sort_map=None): cput = time.clock() diff --git a/gramps/gui/views/treemodels/mediamodel.py b/gramps/gui/views/treemodels/mediamodel.py index e6f25fd14..1f91f9aca 100644 --- a/gramps/gui/views/treemodels/mediamodel.py +++ b/gramps/gui/views/treemodels/mediamodel.py @@ -52,8 +52,8 @@ from .flatbasemodel import FlatBaseModel #------------------------------------------------------------------------- class MediaModel(FlatBaseModel): - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): self.gen_cursor = db.get_media_cursor self.map = db.get_raw_media_data @@ -80,8 +80,8 @@ class MediaModel(FlatBaseModel): self.sort_change, self.column_tag_color, ] - FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, - sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, scol, order, search=search, + skip=skip, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/notemodel.py b/gramps/gui/views/treemodels/notemodel.py index 610864145..7682a5d1b 100644 --- a/gramps/gui/views/treemodels/notemodel.py +++ b/gramps/gui/views/treemodels/notemodel.py @@ -52,8 +52,8 @@ from gramps.gen.lib import (Note, NoteType, StyledText) class NoteModel(FlatBaseModel): """ """ - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): """Setup initial values for instance variables.""" self.gen_cursor = db.get_note_cursor self.map = db.get_raw_note_data @@ -75,8 +75,8 @@ class NoteModel(FlatBaseModel): self.sort_change, self.column_tag_color ] - FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, - sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, scol, order, search=search, + skip=skip, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/peoplemodel.py b/gramps/gui/views/treemodels/peoplemodel.py index f11bcd60f..2e4db0da7 100644 --- a/gramps/gui/views/treemodels/peoplemodel.py +++ b/gramps/gui/views/treemodels/peoplemodel.py @@ -573,11 +573,11 @@ class PersonListModel(PeopleBaseModel, FlatBaseModel): """ Listed people model. """ - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): PeopleBaseModel.__init__(self, db) - FlatBaseModel.__init__(self, db, search=search, skip=skip, scol=scol, - order=order, sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, search=search, skip=skip, + scol=scol, order=order, sort_map=sort_map) def destroy(self): """ @@ -590,11 +590,11 @@ class PersonTreeModel(PeopleBaseModel, TreeBaseModel): """ Hierarchical people model. """ - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): PeopleBaseModel.__init__(self, db) - TreeBaseModel.__init__(self, db, search=search, skip=skip, scol=scol, - order=order, sort_map=sort_map) + TreeBaseModel.__init__(self, db, uistate, search=search, skip=skip, + scol=scol, order=order, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/placemodel.py b/gramps/gui/views/treemodels/placemodel.py index 995eab4a1..6588a179c 100644 --- a/gramps/gui/views/treemodels/placemodel.py +++ b/gramps/gui/views/treemodels/placemodel.py @@ -230,12 +230,12 @@ class PlaceListModel(PlaceBaseModel, FlatBaseModel): """ Flat place model. (Original code in PlaceBaseModel). """ - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): PlaceBaseModel.__init__(self, db) - FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, - sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, scol, order, search=search, + skip=skip, sort_map=sort_map) def destroy(self): """ @@ -253,11 +253,11 @@ class PlaceTreeModel(PlaceBaseModel, TreeBaseModel): """ Hierarchical place model. """ - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): PlaceBaseModel.__init__(self, db) - TreeBaseModel.__init__(self, db, scol=scol, order=order, + TreeBaseModel.__init__(self, db, uistate, scol=scol, order=order, search=search, skip=skip, sort_map=sort_map, nrgroups=3, group_can_have_handle=True) diff --git a/gramps/gui/views/treemodels/repomodel.py b/gramps/gui/views/treemodels/repomodel.py index e01b18014..cb552c280 100644 --- a/gramps/gui/views/treemodels/repomodel.py +++ b/gramps/gui/views/treemodels/repomodel.py @@ -49,8 +49,8 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale #------------------------------------------------------------------------- class RepositoryModel(FlatBaseModel): - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): self.gen_cursor = db.get_repository_cursor self.get_handles = db.get_repository_handles self.map = db.get_raw_repository_data @@ -92,8 +92,8 @@ class RepositoryModel(FlatBaseModel): self.column_tag_color ] - FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, - sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, scol, order, search=search, + skip=skip, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/sourcemodel.py b/gramps/gui/views/treemodels/sourcemodel.py index 05644f0ea..6a76064ef 100644 --- a/gramps/gui/views/treemodels/sourcemodel.py +++ b/gramps/gui/views/treemodels/sourcemodel.py @@ -49,8 +49,8 @@ from gramps.gen.const import GRAMPS_LOCALE as glocale #------------------------------------------------------------------------- class SourceModel(FlatBaseModel): - def __init__(self, db, scol=0, order=Gtk.SortType.ASCENDING, search=None, - skip=set(), sort_map=None): + def __init__(self, db, uistate, scol=0, order=Gtk.SortType.ASCENDING, + search=None, skip=set(), sort_map=None): self.map = db.get_raw_source_data self.gen_cursor = db.get_source_cursor self.fmap = [ @@ -75,8 +75,8 @@ class SourceModel(FlatBaseModel): self.sort_change, self.column_tag_color ] - FlatBaseModel.__init__(self, db, scol, order, search=search, skip=skip, - sort_map=sort_map) + FlatBaseModel.__init__(self, db, uistate, scol, order, search=search, + skip=skip, sort_map=sort_map) def destroy(self): """ diff --git a/gramps/gui/views/treemodels/treebasemodel.py b/gramps/gui/views/treemodels/treebasemodel.py index 7b1c3d2ec..d997afba6 100644 --- a/gramps/gui/views/treemodels/treebasemodel.py +++ b/gramps/gui/views/treemodels/treebasemodel.py @@ -274,12 +274,9 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): secondary object type. """ - def __init__(self, db, - search=None, skip=set(), - scol=0, order=Gtk.SortType.ASCENDING, sort_map=None, - nrgroups = 1, - group_can_have_handle = False, - has_secondary=False): + def __init__(self, db, uistate, search=None, skip=set(), scol=0, + order=Gtk.SortType.ASCENDING, sort_map=None, nrgroups = 1, + group_can_have_handle = False, has_secondary=False): cput = time.clock() GObject.GObject.__init__(self) BaseModel.__init__(self) @@ -295,6 +292,7 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): self.prev_handle = None self.prev_data = None + self.uistate = uistate self.__reverse = (order == Gtk.SortType.DESCENDING) self.scol = scol self.nrgroups = nrgroups @@ -530,11 +528,11 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): Rebuild the data map for a single Gramps object type, where a search condition is applied. """ - pmon = progressdlg.ProgressMonitor(progressdlg.GtkProgressDialog, - popup_time=2) - status = progressdlg.LongOpStatus(msg=_("Building View"), - total_steps=items, interval=items//20, - can_cancel=True) + pmon = progressdlg.ProgressMonitor( + progressdlg.StatusProgress, (self.uistate,), popup_time=2, + title=_("Loading items...")) + status = progressdlg.LongOpStatus(total_steps=items, + interval=items // 20) pmon.add_op(status) with gen_cursor() as cursor: for handle, data in cursor: @@ -542,16 +540,13 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): if not isinstance(handle, str): handle = handle.decode('utf-8') status.heartbeat() - if status.should_cancel(): - break self.__total += 1 if not (handle in skip or (dfilter and not dfilter.match(handle, self.db))): _LOG.debug(" add %s %s" % (handle, data)) self.__displayed += 1 add_func(handle, data) - if not status.was_cancelled(): - status.end() + status.end() def _rebuild_filter(self, dfilter, dfilter2, skip): """ @@ -581,28 +576,29 @@ class TreeBaseModel(GObject.GObject, Gtk.TreeModel, BaseModel): Rebuild the data map for a single Gramps object type, where a filter is applied. """ - pmon = progressdlg.ProgressMonitor(progressdlg.GtkProgressDialog, - popup_time=2) - status = progressdlg.LongOpStatus(msg=_("Building View"), - total_steps=3, interval=1) - pmon.add_op(status) - status_ppl = progressdlg.LongOpStatus(msg=_("Loading items..."), - total_steps=items, interval=items//10) + pmon = progressdlg.ProgressMonitor( + progressdlg.StatusProgress, (self.uistate,), popup_time=2, + title=_("Loading items...")) + status_ppl = progressdlg.LongOpStatus(total_steps=items, + interval=items // 20) pmon.add_op(status_ppl) self.__total += items + assert not skip + if dfilter: + for handle in dfilter.apply(self.db, + cb_progress=status_ppl.heartbeat): + data = data_map(handle) + add_func(handle, data) + self.__displayed += 1 + else: + with gen_cursor() as cursor: + for handle, data in cursor: + status_ppl.heartbeat() + add_func(handle, data) + self.__displayed += 1 - with gen_cursor() as cursor: - for handle, data in cursor: - if not isinstance(handle, str): - handle = handle.decode('utf-8') - status_ppl.heartbeat() - if not handle in skip: - if not dfilter or dfilter.match(handle, self.db): - add_func(handle, data) - self.__displayed += 1 status_ppl.end() - status.end() def add_node(self, parent, child, sortkey, handle, add_parent=True, secondary=False): diff --git a/gramps/gui/widgets/progressdialog.py b/gramps/gui/widgets/progressdialog.py index f522a002d..6c64f4b1f 100644 --- a/gramps/gui/widgets/progressdialog.py +++ b/gramps/gui/widgets/progressdialog.py @@ -591,6 +591,118 @@ class GtkProgressDialog(Gtk.Dialog): def close(self): self.destroy() + +#------------------------------------------------------------------------- +# +# Gramps main status bar Progress indicator +# +#------------------------------------------------------------------------- +class StatusProgress: + """ + A gtk progress in main Gramps window status bar to display the status + of a long running process. + """ + + def __init__(self, window_params, title): + """ + :param title: The title to display on the top of the window. + :type title: string + """ + # self.set_title(title) + self.uistate = window_params[0] + self.title = title + self._old_val = -1 + self._progress_bars = False + + def add(self, long_op_status): + """ + Add a new status object to the statusbar progress. + + :param long_op_status: the status object. + :type long_op_status: :class:`.LongOpStatus` + :returns: a key that can be used as the ``pbar_idx`` to the other + methods. + :rtype: int + """ + assert(not self._progress_bars) + self._pbar = self.uistate.progress + + self._pbar_max = (long_op_status.get_total_steps() / + long_op_status.get_interval()) + self._pbar_index = 0.0 + self._pbar.set_fraction( + ((100 / float(long_op_status.get_total_steps()) * + float(long_op_status.get_interval()))) / 100.0) + + self.uistate.status.push( + self.uistate.status_id, self.title) + self._pbar.show() + + return True + + def remove(self, pbar_idx): + """ + Remove the specified status object from the progress dialog. + + :param pbar_idx: the index as returned from :meth:`add` (not used) + :type pbar_idx: int + """ + self._progress_bars = False + self._pbar.hide() + + def step(self, pbar_idx): + """ + Click the progress bar over to the next value. Be paranoid + and insure that it doesn't go over 100%. + + :param pbar_idx: the index as returned from :meth:`add` (not used) + :type pbar_idx: int + """ + + self._pbar_index = self._pbar_index + 1.0 + + if self._pbar_index > self._pbar_max: + self._pbar_index = self._pbar_max + + try: + val = int(100 * self._pbar_index / self._pbar_max) + except ZeroDivisionError: + val = 0 + + if val != self._old_val: + self._pbar.set_text("%d%%" % val) + self._pbar.set_fraction(val / 100.0) + self._pbar.old_val = val + + self._process_events() + + def _process_events(self): + while Gtk.events_pending(): + Gtk.main_iteration() + + def show(self): + """ + Show the dialog and process any events. + """ + self._pbar.show() + self._process_events() + + def hide(self): + """ + Hide the dialog and process any events. + """ + self._pbar.hide() + self.uistate.status.pop( + self.uistate.status_id) + self._process_events() + + def _warn(self, x, y): + return True + + def close(self): + # self.destroy() + pass + if __name__ == '__main__': def test(a, b): diff --git a/gramps/plugins/db/dbapi/dbapi.py b/gramps/plugins/db/dbapi/dbapi.py index 571c5c27e..cac044184 100644 --- a/gramps/plugins/db/dbapi/dbapi.py +++ b/gramps/plugins/db/dbapi/dbapi.py @@ -128,6 +128,8 @@ class DBAPI(DbGeneric): """ Create and update schema. """ + self.dbapi.begin() + # make sure schema is up to date: self.dbapi.execute('CREATE TABLE person ' '(' @@ -261,6 +263,7 @@ class DBAPI(DbGeneric): self.dbapi.execute('CREATE INDEX reference_obj_handle ' 'ON reference(obj_handle)') + self.dbapi.commit() def _close(self): self.dbapi.close() diff --git a/gramps/plugins/importer/importgeneweb.py b/gramps/plugins/importer/importgeneweb.py index 201f132c0..3afba25dd 100644 --- a/gramps/plugins/importer/importgeneweb.py +++ b/gramps/plugins/importer/importgeneweb.py @@ -909,7 +909,7 @@ class GeneWebParser: LOG.warning(_( "Invalid date {date} in {gw_snippet}, " "preserving date as text." - ).format(date=e.date.to_struct(), gw_snippet=field)) + ).format(date=e.date.__dict__, gw_snippet=field)) date.set(modifier=Date.MOD_TEXTONLY, text=field) return date else: diff --git a/gramps/plugins/importer/importxml.py b/gramps/plugins/importer/importxml.py index 20b068168..7ccc5fd5e 100644 --- a/gramps/plugins/importer/importxml.py +++ b/gramps/plugins/importer/importxml.py @@ -2499,7 +2499,7 @@ class GrampsParser(UpdateCallback): # TRANSLATORS: leave the {date} and {xml} untranslated in the format string, # but you may re-order them if needed. LOG.warning(_("Invalid date {date} in XML {xml}, preserving XML as text" - ).format(date=date_error.date.to_struct(), xml=xml)) + ).format(date=date_error.date.__dict__, xml=xml)) date_value.set(modifier=Date.MOD_TEXTONLY, text=xml) def start_datestr(self, attrs): diff --git a/gramps/plugins/quickview/quickview.gpr.py b/gramps/plugins/quickview/quickview.gpr.py index f151359fa..86567dcb4 100644 --- a/gramps/plugins/quickview/quickview.gpr.py +++ b/gramps/plugins/quickview/quickview.gpr.py @@ -207,7 +207,7 @@ refitems = [(CATEGORY_QR_PERSON, 'person', _("Person")), (CATEGORY_QR_MEDIA, 'media', _("Media")), (CATEGORY_QR_NOTE, 'note', _("Note")), (CATEGORY_QR_CITATION, 'citation', _("Citation")), - (CATEGORY_QR_SOURCE_OR_CITATION, 'source or citation', + (CATEGORY_QR_SOURCE_OR_CITATION, 'source_or_citation', _("Source or Citation")) ] diff --git a/gramps/plugins/test/test_imports.py b/gramps/plugins/test/test_imports.py index 1b1507243..0d6ec18d1 100644 --- a/gramps/plugins/test/test_imports.py +++ b/gramps/plugins/test/test_imports.py @@ -30,7 +30,7 @@ from unittest.mock import patch #import logging from gramps.gen.db.utils import import_as_dict -from gramps.gen.merge.diff import diff_dbs +from gramps.gen.merge.diff import diff_dbs, to_struct from gramps.gen.simple import SimpleAccess from gramps.gen.utils.id import set_det_id from gramps.cli.user import User @@ -75,8 +75,8 @@ class CompleteCheck(unittest.TestCase): if diffs: for diff in diffs: obj_type, item1, item2 = diff - msg = self._report_diff(obj_type, item1.to_struct(), - item2.to_struct()) + msg = self._report_diff(obj_type, to_struct(item1), + to_struct(item2)) if msg != "": if hasattr(item1, "gramps_id"): self.msg += "%s: %s handle=%s\n" % \ diff --git a/gramps/plugins/tool/check.py b/gramps/plugins/tool/check.py index f609e7526..327f5d6ab 100644 --- a/gramps/plugins/tool/check.py +++ b/gramps/plugins/tool/check.py @@ -116,7 +116,7 @@ def cross_table_duplicates(db, uistate): parent = uistate.window else: parent = None - progress = ProgressMeter(_('Checking Database'), '', parent) + progress = ProgressMeter(_('Checking Database'), '', parent=parent) progress.set_pass(_('Looking for cross table duplicates'), 9) logging.info('Looking for cross table duplicates') total_nr_handles = 0 diff --git a/gramps/plugins/tool/dumpgenderstats.py b/gramps/plugins/tool/dumpgenderstats.py index fd0dc5844..bafdf3d59 100644 --- a/gramps/plugins/tool/dumpgenderstats.py +++ b/gramps/plugins/tool/dumpgenderstats.py @@ -24,12 +24,23 @@ Tools/Debug/Dump Gender Statistics """ + +#------------------------------------------------------------------------- +# +# GTK/Gnome modules +# +#------------------------------------------------------------------------- +from gi.repository import Gtk + +#------------------------------------------------------------------------- +# +# Gramps modules +# +#------------------------------------------------------------------------- from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.gettext -from gi.repository import Gtk from gramps.gui.listmodel import ListModel, INTEGER from gramps.gui.managedwindow import ManagedWindow - from gramps.gui.plug import tool _GENDER = [ _('female'), _('male'), _('unknown') ] @@ -45,9 +56,6 @@ class DumpGenderStats(tool.Tool, ManagedWindow): uistate = user.uistate self.label = _("Gender Statistics tool") tool.Tool.__init__(self, dbstate, options_class, name) - if uistate: - ManagedWindow.__init__(self,uistate,[], - self.__class__) stats_list = [] for name, value in dbstate.db.genderStats.stats.items(): @@ -58,33 +66,51 @@ class DumpGenderStats(tool.Tool, ManagedWindow): ) if uistate: - titles = [ - (_('Name'),0,100), - (_('Male'),1,70,INTEGER), - (_('Female'),2,70,INTEGER), - (_('Unknown'),3,70,INTEGER), - (_('Guess'),4,70) - ] + ManagedWindow.__init__(self, uistate, [], self.__class__) + + titles = [(_('Name'), 0, 100), + (_('Male'), 1, 70, INTEGER), + (_('Female'), 2, 70, INTEGER), + (_('Unknown'), 3, 90, INTEGER), + (_('Guess'), 4, 70)] treeview = Gtk.TreeView() model = ListModel(treeview, titles) for entry in sorted(stats_list): model.add(entry, entry[0]) - window = Gtk.Window() # TODO there needs to be a way to "close" it s = Gtk.ScrolledWindow() s.add(treeview) - window.add(s) - window.show_all() - self.set_window(window, None, self.label) - self.setup_configs('interface.dumpgenderstats', 400, 300) + dialog = Gtk.Dialog() + dialog.add_button(_('_Close'), Gtk.ResponseType.CLOSE) + dialog.connect('response', self._response) + dialog.vbox.pack_start(s, expand=True, fill=True, padding=0) + self.set_window(dialog, None, self.label) + self.setup_configs('interface.dumpgenderstats', 420, 300) self.show() else: - print('\t%s'*5 % ('Name','Male','Female','Unknown','Guess')) + if len(_('Name')) < 16: + print('%s%s%s' % (_('Name'), + " " * (16 - len(_('Name'))), + _('Male')), + '\t%s'*3 % (_('Female'), _('Unknown'), _('Guess'))) + else: + print(_('Name'), '\t%s'*4 % (_('Male'), _('Female'), + _('Unknown'), _('Guess'))) print() - for entry in stats_list: - print('\t%s'*5 % entry) + for entry in sorted(stats_list): + if len(entry[0]) < 16: + print('%s%s%s' % (entry[0], + " " * (16 - len(entry[0])), + entry[1]), + '\t%s'*3 % (entry[2:])) + else: + print(entry[0], '\t%s'*4 % (entry[1:])) + + def _response(self, obj, response_id): + if response_id == Gtk.ResponseType.CLOSE: + self.close() def build_menu_names(self, obj): return (self.label,None) diff --git a/gramps/plugins/tool/mediamanager.py b/gramps/plugins/tool/mediamanager.py index cb1326b29..9108cad80 100644 --- a/gramps/plugins/tool/mediamanager.py +++ b/gramps/plugins/tool/mediamanager.py @@ -57,6 +57,7 @@ from gramps.gen.utils.file import media_path_full, relative_path, media_path from gramps.gen.const import GRAMPS_LOCALE as glocale _ = glocale.translation.sgettext from gramps.gen.mime import get_type, is_image_type +from gramps.gui.managedwindow import ManagedWindow #------------------------------------------------------------------------- # @@ -71,23 +72,24 @@ WIKI_HELP_SEC = _('manual|Media_Manager...') # This is an Assistant implementation to guide the user # #------------------------------------------------------------------------- -class MediaMan(tool.Tool): +class MediaMan(ManagedWindow, tool.Tool): def __init__(self, dbstate, user, options_class, name, callback=None): uistate = user.uistate tool.Tool.__init__(self, dbstate, options_class, name) - self.uistate = uistate + ManagedWindow.__init__(self, uistate, [], self.__class__) self.callback = uistate.pulse_progressbar self.batch_ops = [] self.build_batch_ops() self.assistant = Gtk.Assistant() + self.set_window(self.assistant, None, _('Media Manager')) + self.setup_configs('interface.mediaman', 780, 600) - self.assistant.set_title(_('Gramps Media Manager')) - self.assistant.connect('close', self.close) - self.assistant.connect('cancel', self.close) + self.assistant.connect('close', self.do_close) + self.assistant.connect('cancel', self.do_close) self.assistant.connect('apply', self.run) self.assistant.connect('prepare', self.prepare) @@ -104,14 +106,21 @@ class MediaMan(tool.Tool): self.conclusion = ConclusionPage(self.assistant) self.add_page(self.conclusion, Gtk.AssistantPageType.SUMMARY) - self.assistant.show() + self.show() self.assistant.set_forward_page_func(self.forward_page, None) - def close(self, assistant): + def build_menu_names(self, obj): + """Override :class:`.ManagedWindow` method.""" + return (_('Media Manager'), None) + + def do_close(self, assistant): """ Close the assistant. """ + position = self.window.get_position() # crock self.assistant.hide() + self.window.move(position[0], position[1]) + self.close() def forward_page(self, page, data): """ diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 3cd332f29..37ad9abe6 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -164,6 +164,7 @@ gramps/gen/lib/repo.py gramps/gen/lib/reporef.py gramps/gen/lib/researcher.py gramps/gen/lib/secondaryobj.py +gramps/gen/lib/serialize.py gramps/gen/lib/src.py gramps/gen/lib/srcbase.py gramps/gen/lib/srcref.py diff --git a/po/ru.po b/po/ru.po index 246f98e35..010f425bc 100644 --- a/po/ru.po +++ b/po/ru.po @@ -16,9 +16,10 @@ msgid "" msgstr "" "Project-Id-Version: gramps50\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2017-01-16 09:54-0300\n" -"PO-Revision-Date: 2017-01-16 10:08-0300\n" +"POT-Creation-Date: 2017-01-21 09:07-0300\n" +"PO-Revision-Date: 2017-01-21 09:10-0300\n" "Last-Translator: Ivan Komaritsyn \n" +"Language-Team: Russian\n" "Language: ru\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" @@ -411,8 +412,8 @@ msgid "" "The Family View
The Family View is used to display a typical " "family unit as two parents and their children." msgstr "" -"Вид «Семьи»
Вид «Семьи» служит для показа обычной семейной " -"ячейки---родителей, супругов и детей лица." +"Вид «Семьи»
Вид «Семьи» служит для отображения обычной семейной " +"ячейки - пара родителей и их дети." #: ../data/tips.xml.in.h:10 msgid "" @@ -669,9 +670,9 @@ msgid "" msgstr "" "Улучшение Gramps
Пользователи заинтересованные в " "усовершенствовании Gramps могут оставить пожелания через других " -"пользователей Gramps или через список зассылки gramps-devel, а также через " +"пользователей Gramps или через список рассылки gramps-devel, а также через " "http://bugs.gramps-project.org, где можно оставить запрос на введение какого " -"либо усовершенствования. Добавления запроса на усовершенствование " +"либо усовершенствования. Добавление запроса на усовершенствование " "предпочтительней, т.к. можно обсудить вашу идею." #: ../data/tips.xml.in.h:30 @@ -1743,7 +1744,9 @@ msgstr "Заблокировано %s" #: ../gramps/plugins/textreport/indivcomplete.py:86 #: ../gramps/plugins/textreport/indivcomplete.py:913 #: ../gramps/plugins/tool/check.py:2356 ../gramps/plugins/tool/check.py:2382 -#: ../gramps/plugins/tool/dumpgenderstats.py:65 +#: ../gramps/plugins/tool/dumpgenderstats.py:74 +#: ../gramps/plugins/tool/dumpgenderstats.py:97 +#: ../gramps/plugins/tool/dumpgenderstats.py:100 #: ../gramps/plugins/view/geoclose.py:521 #: ../gramps/plugins/view/geofamclose.py:271 #: ../gramps/plugins/view/geofamclose.py:712 @@ -4888,11 +4891,11 @@ msgstr "" #. TODO no-parent #: ../gramps/gen/filters/rules/person/_deeprelationshippathbetween.py:141 msgid "Finding relationship paths" -msgstr "Определяю родственные связи" +msgstr "Поиск родственных связей" #: ../gramps/gen/filters/rules/person/_deeprelationshippathbetween.py:142 msgid "Evaluating people" -msgstr "Выбираю людей" +msgstr "Обрабатываются люди" #: ../gramps/gen/filters/rules/person/_disconnected.py:44 msgid "Disconnected people" @@ -4962,7 +4965,7 @@ msgstr "Выбирает людей с данным значением личн #: ../gramps/gen/filters/rules/person/_hasbirth.py:49 msgid "People with the " -msgstr "Люди с <данными о·рождении>" +msgstr "Люди с <данными о рождении>" #: ../gramps/gen/filters/rules/person/_hasbirth.py:50 msgid "Matches people with birth data of a particular value" @@ -5047,7 +5050,7 @@ msgstr "Выбирает объекты с данным значением се #: ../gramps/gen/filters/rules/person/_hasfamilyevent.py:52 msgid "People with the family " -msgstr "Люди с семейными <событиями>" +msgstr "Люди с семейным <событием>" #: ../gramps/gen/filters/rules/person/_hasfamilyevent.py:53 msgid "Matches people with a family event of a particular value" @@ -6410,7 +6413,7 @@ msgstr "Воспитанник" #: ../gramps/gui/merge/mergeperson.py:64 #: ../gramps/gui/views/treemodels/peoplemodel.py:97 #: ../gramps/plugins/textreport/indivcomplete.py:648 -#: ../gramps/plugins/tool/dumpgenderstats.py:35 +#: ../gramps/plugins/tool/dumpgenderstats.py:46 #: ../gramps/plugins/view/relview.py:648 #: ../gramps/plugins/webreport/narrativeweb.py:6331 msgid "unknown" @@ -7425,7 +7428,7 @@ msgstr "Личное" #: ../gramps/gui/plug/report/_bookdialog.py:373 #: ../gramps/gui/selectors/selectperson.py:93 #: ../gramps/gui/selectors/selectplace.py:70 -#: ../gramps/gui/views/bookmarks.py:240 ../gramps/gui/views/tags.py:408 +#: ../gramps/gui/views/bookmarks.py:270 ../gramps/gui/views/tags.py:408 #: ../gramps/gui/views/treemodels/peoplemodel.py:616 #: ../gramps/plugins/export/exportcsv.py:285 #: ../gramps/plugins/gramplet/ancestor.py:63 @@ -7441,7 +7444,11 @@ msgstr "Личное" #: ../gramps/plugins/textreport/tagreport.py:160 #: ../gramps/plugins/textreport/tagreport.py:426 #: ../gramps/plugins/textreport/tagreport.py:654 -#: ../gramps/plugins/tool/dumpgenderstats.py:62 +#: ../gramps/plugins/tool/dumpgenderstats.py:71 +#: ../gramps/plugins/tool/dumpgenderstats.py:93 +#: ../gramps/plugins/tool/dumpgenderstats.py:94 +#: ../gramps/plugins/tool/dumpgenderstats.py:95 +#: ../gramps/plugins/tool/dumpgenderstats.py:99 #: ../gramps/plugins/tool/notrelated.py:126 #: ../gramps/plugins/tool/removeunused.py:201 #: ../gramps/plugins/tool/verify.py:577 ../gramps/plugins/view/repoview.py:85 @@ -9850,7 +9857,7 @@ msgstr "%(west_longitude)s З" #: ../gramps/gui/filters/sidebar/_personsidebarfilter.py:89 #: ../gramps/gui/merge/mergeperson.py:64 #: ../gramps/gui/views/treemodels/peoplemodel.py:97 -#: ../gramps/plugins/tool/dumpgenderstats.py:35 +#: ../gramps/plugins/tool/dumpgenderstats.py:46 #: ../gramps/plugins/webreport/narrativeweb.py:6329 msgid "male" msgstr "мужской" @@ -9859,7 +9866,7 @@ msgstr "мужской" #: ../gramps/gui/filters/sidebar/_personsidebarfilter.py:89 #: ../gramps/gui/merge/mergeperson.py:64 #: ../gramps/gui/views/treemodels/peoplemodel.py:97 -#: ../gramps/plugins/tool/dumpgenderstats.py:35 +#: ../gramps/plugins/tool/dumpgenderstats.py:46 #: ../gramps/plugins/webreport/narrativeweb.py:6330 msgid "female" msgstr "женский" @@ -10003,7 +10010,7 @@ msgstr "" #: ../gramps/gui/clipboard.py:69 msgid "manual|Using_the_Clipboard" -msgstr "" +msgstr "Использование_буфера_обмена" #. We encounter a PLAC, having previously encountered an ADDR #: ../gramps/gui/clipboard.py:303 ../gramps/gui/configure.py:517 @@ -10288,14 +10295,15 @@ msgstr "Показать «Редактор имён»" #: ../gramps/gui/glade/displaystate.glade:23 #: ../gramps/gui/glade/plugins.glade:22 ../gramps/gui/glade/rule.glade:24 #: ../gramps/gui/glade/rule.glade:1024 ../gramps/gui/glade/tipofday.glade:117 -#: ../gramps/gui/glade/updateaddons.glade:26 ../gramps/gui/plug/_windows.py:105 +#: ../gramps/gui/glade/updateaddons.glade:25 ../gramps/gui/plug/_windows.py:105 #: ../gramps/gui/plug/_windows.py:691 ../gramps/gui/plug/_windows.py:747 #: ../gramps/gui/plug/quick/_textbufdoc.py:60 ../gramps/gui/undohistory.py:90 #: ../gramps/gui/viewmanager.py:512 ../gramps/gui/viewmanager.py:1692 -#: ../gramps/gui/views/bookmarks.py:258 ../gramps/gui/views/tags.py:430 +#: ../gramps/gui/views/bookmarks.py:287 ../gramps/gui/views/tags.py:430 #: ../gramps/gui/widgets/grampletbar.py:635 #: ../gramps/gui/widgets/grampletpane.py:236 #: ../gramps/plugins/lib/maps/placeselection.py:108 +#: ../gramps/plugins/tool/dumpgenderstats.py:85 msgid "_Close" msgstr "_Закрыть" @@ -10596,7 +10604,7 @@ msgstr "_Правка" #: ../gramps/gui/editors/displaytabs/webembedlist.py:117 #: ../gramps/gui/editors/editfamily.py:151 #: ../gramps/gui/plug/report/_bookdialog.py:622 -#: ../gramps/gui/views/bookmarks.py:254 ../gramps/gui/views/listview.py:212 +#: ../gramps/gui/views/bookmarks.py:283 ../gramps/gui/views/listview.py:212 #: ../gramps/gui/views/tags.py:424 ../gramps/plugins/lib/libpersonview.py:391 msgid "_Remove" msgstr "_Удалить" @@ -10992,7 +11000,7 @@ msgstr "Выбрать каталог документов" #: ../gramps/gui/configure.py:1541 ../gramps/gui/configure.py:1564 #: ../gramps/gui/configure.py:1589 ../gramps/gui/dbloader.py:397 -#: ../gramps/gui/editors/edittaglist.py:117 +#: ../gramps/gui/editors/edittaglist.py:119 #: ../gramps/gui/glade/addmedia.glade:22 #: ../gramps/gui/glade/baseselector.glade:24 #: ../gramps/gui/glade/configure.glade:23 ../gramps/gui/glade/dialog.glade:417 @@ -11038,7 +11046,7 @@ msgstr "Выбрать каталог документов" #: ../gramps/gui/plug/_guioptions.py:1728 ../gramps/gui/plug/_windows.py:440 #: ../gramps/gui/plug/report/_fileentry.py:64 #: ../gramps/gui/plug/report/_reportdialog.py:161 ../gramps/gui/utils.py:178 -#: ../gramps/gui/viewmanager.py:1826 ../gramps/gui/views/listview.py:1023 +#: ../gramps/gui/viewmanager.py:1826 ../gramps/gui/views/listview.py:1022 #: ../gramps/gui/views/navigationview.py:362 ../gramps/gui/views/tags.py:645 #: ../gramps/gui/widgets/progressdialog.py:437 #: ../gramps/plugins/lib/maps/geography.py:1006 @@ -11199,7 +11207,7 @@ msgstr "_Извлечь" msgid "Database Information" msgstr "Информация о базе данных" -#: ../gramps/gui/dbman.py:121 ../gramps/gui/editors/edittaglist.py:118 +#: ../gramps/gui/dbman.py:121 ../gramps/gui/editors/edittaglist.py:120 #: ../gramps/gui/glade/addmedia.glade:38 #: ../gramps/gui/glade/baseselector.glade:40 ../gramps/gui/glade/book.glade:482 #: ../gramps/gui/glade/book.glade:554 ../gramps/gui/glade/configure.glade:39 @@ -11602,7 +11610,7 @@ msgstr "Не выбран объект" #: ../gramps/gui/editors/addmedia.py:70 msgid "manual|Select_a_media_selector" -msgstr "" +msgstr "Выбор_документов" #: ../gramps/gui/editors/addmedia.py:104 msgid "Select a media object" @@ -11733,7 +11741,7 @@ msgstr "Атрибуты" #: ../gramps/gui/selectors/selectplace.py:71 #: ../gramps/gui/selectors/selectrepository.py:70 #: ../gramps/gui/selectors/selectsource.py:71 -#: ../gramps/gui/views/bookmarks.py:240 +#: ../gramps/gui/views/bookmarks.py:270 #: ../gramps/gui/views/navigationview.py:357 #: ../gramps/plugins/gramplet/locations.py:88 #: ../gramps/plugins/lib/libpersonview.py:99 @@ -12403,7 +12411,7 @@ msgstr "_Перейти к" #: ../gramps/gui/editors/editaddress.py:65 msgid "manual|Address_Editor_dialog" -msgstr "Редактор адресов" +msgstr "Редактор_адресов" #: ../gramps/gui/editors/editaddress.py:92 #: ../gramps/gui/editors/editaddress.py:167 @@ -12412,7 +12420,7 @@ msgstr "Редактор адресов" #: ../gramps/gui/editors/editattribute.py:62 msgid "manual|Attribute_Editor_dialog" -msgstr "Редактор атрибутов" +msgstr "Редактор_атрибутов" #: ../gramps/gui/editors/editattribute.py:94 #: ../gramps/gui/editors/editattribute.py:137 @@ -12434,7 +12442,7 @@ msgstr "Тип атрибута не может быть пустым" #: ../gramps/gui/editors/editchildref.py:66 msgid "manual|Child_Reference_Editor" -msgstr "Редактор родства ребёнка" +msgstr "Редактор_ссылок_на_ребёнка" #: ../gramps/gui/editors/editchildref.py:99 #: ../gramps/gui/editors/editchildref.py:195 @@ -12447,7 +12455,7 @@ msgstr "Родство ребёнка" #: ../gramps/gui/editors/editcitation.py:69 msgid "manual|New_Citation_dialog" -msgstr "Новая цитата" +msgstr "Новая_цитата" #: ../gramps/gui/editors/editcitation.py:128 #: ../gramps/gui/editors/editcitation.py:134 @@ -12550,7 +12558,7 @@ msgstr "Вычислено" #: ../gramps/gui/editors/editdate.py:99 msgid "manual|Editing_dates" -msgstr "Редактирование дат" +msgstr "Редактирование_дат" #: ../gramps/gui/editors/editdate.py:126 ../gramps/gui/editors/editdate.py:279 msgid "Date selection" @@ -12563,7 +12571,7 @@ msgstr "Исправьте дату, или переключите с «{cur_mod #: ../gramps/gui/editors/editevent.py:64 msgid "manual|New_Event_dialog" -msgstr "Новое событие" +msgstr "Новое_событие" #: ../gramps/gui/editors/editevent.py:98 #: ../gramps/gui/editors/editeventref.py:261 @@ -12626,7 +12634,7 @@ msgstr "Удалить событие (%s)" #: ../gramps/gui/editors/editeventref.py:57 msgid "manual|Event_Reference_Editor_dialog" -msgstr "Редактор ссылки на событие" +msgstr "Редактор_ссылки_на_событие" #: ../gramps/gui/editors/editeventref.py:76 #: ../gramps/gui/editors/editeventref.py:264 @@ -12651,7 +12659,7 @@ msgstr "Добавить событие" #: ../gramps/gui/editors/editfamily.py:91 msgid "manual|Family_Editor_dialog" -msgstr "" +msgstr "Редактор_семьи" #: ../gramps/gui/editors/editfamily.py:111 msgid "Create a new person and add the child to the family" @@ -12906,7 +12914,7 @@ msgstr "Добавить семью" #: ../gramps/gui/editors/editldsord.py:67 msgid "manual|LDS_Ordinance_Editor" -msgstr "" +msgstr "Редактор_процедур_СПД" #: ../gramps/gui/editors/editldsord.py:158 #: ../gramps/gui/editors/editldsord.py:315 @@ -12940,7 +12948,7 @@ msgstr "Процедура СПД" #: ../gramps/gui/editors/editlink.py:49 msgid "manual|Link_Editor" -msgstr "Редактор ссылок" +msgstr "Редактор_ссылок" #: ../gramps/gui/editors/editlink.py:87 ../gramps/gui/editors/editlink.py:237 msgid "Link Editor" @@ -12956,7 +12964,7 @@ msgstr "Редактор мест" #: ../gramps/gui/editors/editmedia.py:68 msgid "manual|New_Media_dialog" -msgstr "" +msgstr "Новый_документ" #: ../gramps/gui/editors/editmedia.py:99 #: ../gramps/gui/editors/editmediaref.py:406 @@ -13020,7 +13028,7 @@ msgstr "Удалить документ" #: ../gramps/gui/editors/editmediaref.py:71 msgid "manual|Media_Reference_Editor_dialog" -msgstr "" +msgstr "Редактор_ссылки_на_документ" #: ../gramps/gui/editors/editmediaref.py:93 #: ../gramps/gui/editors/editmediaref.py:409 @@ -13040,7 +13048,7 @@ msgstr "Редактор имён" #: ../gramps/gui/editors/editname.py:162 msgid "manual|Name_Editor" -msgstr "" +msgstr "Редактор_имён" #: ../gramps/gui/editors/editname.py:174 #: ../gramps/gui/editors/editperson.py:327 @@ -13094,9 +13102,8 @@ msgid "Group this name only" msgstr "Группировать только это имя" #: ../gramps/gui/editors/editnote.py:67 -#, fuzzy msgid "manual|Editing_information_about_notes" -msgstr "Редактирование информации о событиях" +msgstr "Изменение_информации_о_заметках" #: ../gramps/gui/editors/editnote.py:150 #, python-format @@ -13164,11 +13171,8 @@ msgid "New Person" msgstr "Новое лицо" #: ../gramps/gui/editors/editperson.py:245 -#, fuzzy msgid "manual|Editing_information_about_people" -msgstr "" -".D0.98.D0.B7.D0.BC.D0.B5.D0.BD.D0.B5.D0.BD.D0.B8.D0.B5_.D0.B8.D0.BD.D1.84.D0." -"BE.D1.80.D0.BC.D0.B0.D1.86.D0.B8.D0.B8_.D0.BE_.D0.BB.D1.8E.D0.B4.D1.8F.D1.85" +msgstr "Изменение_информации_о_людях" #: ../gramps/gui/editors/editperson.py:606 #: ../gramps/plugins/view/geofamily.py:426 @@ -13256,9 +13260,8 @@ msgid "_Unknown" msgstr "Неизвестно" #: ../gramps/gui/editors/editpersonref.py:67 -#, fuzzy msgid "manual|Person_Reference_Editor" -msgstr "Редактор ссылки на лицо" +msgstr "Редактор_ссылки_на_лицо" #: ../gramps/gui/editors/editpersonref.py:93 #: ../gramps/gui/editors/editpersonref.py:222 @@ -13279,7 +13282,7 @@ msgstr "Выберите лицо или отмените правку" #: ../gramps/gui/editors/editplace.py:69 msgid "manual|Place_Editor_dialog" -msgstr "" +msgstr "Редактор_местоположений" #: ../gramps/gui/editors/editplace.py:91 #: ../gramps/gui/glade/editplace.glade:288 ../gramps/gui/merge/mergeplace.py:55 @@ -13355,12 +13358,12 @@ msgstr "Удалить место (%s)" #: ../gramps/gui/editors/editplacename.py:49 msgid "manual|Place_Name_Editor_dialog" -msgstr "" +msgstr "Редактор_названия_местоположений" #: ../gramps/gui/editors/editplacename.py:101 #: ../gramps/gui/editors/editplacename.py:134 msgid "Place Name Editor" -msgstr "Редактор местоположений" +msgstr "Редактор названия местоположения" #: ../gramps/gui/editors/editplacename.py:125 msgid "Invalid ISO code" @@ -13433,7 +13436,7 @@ msgstr "Добавить хранилище" #: ../gramps/gui/editors/editrepository.py:60 msgid "manual|New_Repositories_dialog" -msgstr "" +msgstr "Новые_хранилища" #: ../gramps/gui/editors/editrepository.py:92 msgid "Edit Repository" @@ -13466,7 +13469,7 @@ msgstr "Удалить хранилище (%s)" #: ../gramps/gui/editors/editsource.py:64 msgid "manual|New_Source_dialog" -msgstr "" +msgstr "Новый_источник" #: ../gramps/gui/editors/editsource.py:88 msgid "New Source" @@ -13506,25 +13509,14 @@ msgstr "Удалить источник (%s)" #: ../gramps/gui/editors/edittaglist.py:48 msgid "manual|Tag_selection_dialog" -msgstr "" +msgstr "Выбор_меток" -#: ../gramps/gui/editors/edittaglist.py:68 -#: ../gramps/gui/editors/edittaglist.py:126 +#: ../gramps/gui/editors/edittaglist.py:70 +#: ../gramps/gui/editors/edittaglist.py:127 msgid "Tag selection" msgstr "Выбор метки" -#. pylint: disable-msg=E1101 -#: ../gramps/gui/editors/edittaglist.py:100 -#: ../gramps/gui/views/bookmarks.py:227 ../gramps/gui/views/tags.py:638 -#, python-format -msgid "%(title)s - Gramps" -msgstr "%(title)s - Gramps" - -#: ../gramps/gui/editors/edittaglist.py:100 -msgid "Edit Tags" -msgstr "Редактировать метки" - -#: ../gramps/gui/editors/edittaglist.py:107 +#: ../gramps/gui/editors/edittaglist.py:109 #: ../gramps/gui/filters/sidebar/_citationsidebarfilter.py:116 #: ../gramps/gui/filters/sidebar/_eventsidebarfilter.py:110 #: ../gramps/gui/filters/sidebar/_familysidebarfilter.py:118 @@ -13540,7 +13532,7 @@ msgstr "Редактировать метки" msgid "Tag" msgstr "Метка" -#: ../gramps/gui/editors/edittaglist.py:116 +#: ../gramps/gui/editors/edittaglist.py:118 #: ../gramps/gui/glade/addmedia.glade:55 #: ../gramps/gui/glade/baseselector.glade:56 #: ../gramps/gui/glade/clipboard.glade:21 ../gramps/gui/glade/dbman.glade:150 @@ -13583,7 +13575,7 @@ msgstr "Метка" #: ../gramps/gui/logger/_errorview.py:143 #: ../gramps/gui/plug/report/_reportdialog.py:158 #: ../gramps/gui/undohistory.py:82 ../gramps/gui/viewmanager.py:490 -#: ../gramps/gui/views/bookmarks.py:259 ../gramps/gui/views/tags.py:431 +#: ../gramps/gui/views/bookmarks.py:288 ../gramps/gui/views/tags.py:431 #: ../gramps/gui/views/tags.py:644 ../gramps/gui/widgets/grampletbar.py:641 #: ../gramps/gui/widgets/grampletpane.py:240 #: ../gramps/plugins/tool/testcasegenerator.py:329 @@ -13592,7 +13584,7 @@ msgstr "_Справка" #: ../gramps/gui/editors/editurl.py:47 msgid "manual|Internet_Address_Editor" -msgstr "Редактор интернет-адресов" +msgstr "Редактор_интернет-адресов" #: ../gramps/gui/editors/editurl.py:68 ../gramps/gui/editors/editurl.py:103 msgid "Internet Address Editor" @@ -13600,15 +13592,15 @@ msgstr "Редактор интернет-адресов" #: ../gramps/gui/editors/filtereditor.py:83 msgid "manual|Add_Rule_dialog" -msgstr "" +msgstr "Добавление_правила" #: ../gramps/gui/editors/filtereditor.py:84 msgid "manual|Define_Filter_dialog" -msgstr "" +msgstr "Установка_фильтра" #: ../gramps/gui/editors/filtereditor.py:85 msgid "manual|Custom_Filters" -msgstr "Специальные фильтры" +msgstr "Специальные_фильтры" #: ../gramps/gui/editors/filtereditor.py:89 msgid "Person Filters" @@ -13947,8 +13939,8 @@ msgstr "%s не" msgid "%s does not contain" msgstr "%s не содержит" -#: ../gramps/gui/filters/_searchbar.py:168 ../gramps/gui/views/listview.py:1154 -#: ../gramps/gui/views/listview.py:1174 +#: ../gramps/gui/filters/_searchbar.py:168 ../gramps/gui/views/listview.py:1153 +#: ../gramps/gui/views/listview.py:1173 msgid "Updating display..." msgstr "Обновление экрана..." @@ -14285,7 +14277,7 @@ msgstr "Закрыть _без сохранения" #. widget #: ../gramps/gui/glade/dialog.glade:859 #: ../gramps/gui/plug/report/_bookdialog.py:625 -#: ../gramps/gui/views/listview.py:1024 +#: ../gramps/gui/views/listview.py:1023 #: ../gramps/gui/widgets/grampletpane.py:578 #: ../gramps/plugins/tool/eventcmp.py:400 msgid "_Save" @@ -15726,7 +15718,7 @@ msgid "Note 2" msgstr "Заметка №2" #: ../gramps/gui/glade/mergenote.glade:278 -#: ../gramps/gui/glade/mergenote.glade:294 ../gramps/gui/views/listview.py:1028 +#: ../gramps/gui/glade/mergenote.glade:294 ../gramps/gui/views/listview.py:1027 msgid "Format:" msgstr "Формат:" @@ -16247,16 +16239,16 @@ msgstr "_Показывать при запуске" msgid "_Forward" msgstr "_Вперёд" -#: ../gramps/gui/glade/updateaddons.glade:42 +#: ../gramps/gui/glade/updateaddons.glade:41 msgid "Install Selected _Addons" msgstr "Установить выбранные _модули" -#: ../gramps/gui/glade/updateaddons.glade:73 +#: ../gramps/gui/glade/updateaddons.glade:72 #: ../gramps/gui/plug/_windows.py:1078 msgid "Available Gramps Updates for Addons" msgstr "Доступны обновления для дополнений" -#: ../gramps/gui/glade/updateaddons.glade:90 +#: ../gramps/gui/glade/updateaddons.glade:89 msgid "" "Gramps comes with a core set of plugins which provide all of the necessary " "features. However, you can extend this functionality with additional Addons. " @@ -16274,11 +16266,11 @@ msgstr "" "установлены на вашем компьютере. Если вы закроете это окно, вы можете " "установить новые модули позже через меню Правка -> Настройки." -#: ../gramps/gui/glade/updateaddons.glade:106 +#: ../gramps/gui/glade/updateaddons.glade:105 msgid "_Select All" msgstr "Выбрать _все" -#: ../gramps/gui/glade/updateaddons.glade:121 +#: ../gramps/gui/glade/updateaddons.glade:120 msgid "Select _None" msgstr "_Отменить выбор" @@ -16603,7 +16595,7 @@ msgstr "" # !!!FIXME!!! #: ../gramps/gui/logger/_errorview.py:45 msgid "manual|Error_Report" -msgstr "Сообщение об ошибке" +msgstr "Сообщение_об_ошибке" # !!!FIXME!!! #: ../gramps/gui/logger/_errorview.py:83 @@ -16643,7 +16635,7 @@ msgstr "Создано %(year)4d/%(month)02d/%(day)02d" #: ../gramps/gui/merge/mergecitation.py:46 msgid "manual|Merge_Citations" -msgstr "Объединение цитат" +msgstr "Объединение_цитат" #: ../gramps/gui/merge/mergecitation.py:68 #: ../gramps/plugins/tool/tools.gpr.py:442 @@ -16652,7 +16644,7 @@ msgstr "Объединить цитаты" #: ../gramps/gui/merge/mergeevent.py:45 msgid "manual|Merge_Events" -msgstr "Объединение событий" +msgstr "Объединение_событий" #: ../gramps/gui/merge/mergeevent.py:67 msgid "Merge Events" @@ -16660,7 +16652,7 @@ msgstr "Объединить события" #: ../gramps/gui/merge/mergefamily.py:46 msgid "manual|Merge_Families" -msgstr "Объединение семей" +msgstr "Объединение_семей" #: ../gramps/gui/merge/mergefamily.py:68 msgid "Merge Families" @@ -16674,11 +16666,11 @@ msgstr "Ошибка объединения людей" #: ../gramps/gui/merge/mergemedia.py:44 msgid "manual|Merge_Media_Objects" -msgstr "Объединение документов" +msgstr "Объединение_документов" #: ../gramps/gui/merge/mergenote.py:44 msgid "manual|Merge_Notes" -msgstr "Объединение заметок" +msgstr "Объединение_заметок" #: ../gramps/gui/merge/mergenote.py:94 msgid "flowed" @@ -16690,7 +16682,7 @@ msgstr "свёрстанный" #: ../gramps/gui/merge/mergeperson.py:58 msgid "manual|Merge_People" -msgstr "Объединение людей" +msgstr "Объединение_людей" #. translators: needed for French, ignore otherwise #: ../gramps/gui/merge/mergeperson.py:62 @@ -16789,15 +16781,15 @@ msgstr "" #: ../gramps/gui/merge/mergeplace.py:53 msgid "manual|Merge_Places" -msgstr "Объединение мест" +msgstr "Объединение_мест" #: ../gramps/gui/merge/mergerepository.py:44 msgid "manual|Merge_Repositories" -msgstr "Объединение хранилищ" +msgstr "Объединение_хранилищ" #: ../gramps/gui/merge/mergesource.py:45 msgid "manual|Merge_Sources" -msgstr "Объединение источников" +msgstr "Объединение_источников" #: ../gramps/gui/merge/mergesource.py:67 msgid "Merge Sources" @@ -17049,24 +17041,24 @@ msgstr "Главное окно" msgid "%(adjective)s: %(addon)s" msgstr "%(adjective)s: %(addon)s" -#: ../gramps/gui/plug/_windows.py:1175 +#: ../gramps/gui/plug/_windows.py:1173 msgid "Downloading and installing selected addons..." msgstr "Скачиваем и устанавливаем выбранные дополнения..." -#: ../gramps/gui/plug/_windows.py:1210 +#: ../gramps/gui/plug/_windows.py:1208 msgid "Installation Errors" msgstr "Ошибки при установке" -#: ../gramps/gui/plug/_windows.py:1211 +#: ../gramps/gui/plug/_windows.py:1209 msgid "The following addons had errors: " msgstr "Следующие дополнения имели ошибки: " -#: ../gramps/gui/plug/_windows.py:1215 ../gramps/gui/plug/_windows.py:1223 +#: ../gramps/gui/plug/_windows.py:1213 ../gramps/gui/plug/_windows.py:1221 msgid "Done downloading and installing addons" msgstr "Скачивание и установка дополнений завершена" #. translators: leave all/any {...} untranslated -#: ../gramps/gui/plug/_windows.py:1217 +#: ../gramps/gui/plug/_windows.py:1215 #, python-brace-format msgid "{number_of} addon was installed." msgid_plural "{number_of} addons were installed." @@ -17074,11 +17066,11 @@ msgstr[0] "{number_of} дополнение было установлено." msgstr[1] "{number_of} дополнения было установлено." msgstr[2] "{number_of} дополнений было установлено." -#: ../gramps/gui/plug/_windows.py:1220 +#: ../gramps/gui/plug/_windows.py:1218 msgid "If you have installed a 'Gramps View', you will need to restart Gramps." msgstr "Если был установлен Вид Gramps необходимо перезапустить программу." -#: ../gramps/gui/plug/_windows.py:1224 +#: ../gramps/gui/plug/_windows.py:1222 msgid "No addons were installed." msgstr "Никакие дополнения не были установлены." @@ -17104,7 +17096,7 @@ msgid "Select save file" msgstr "Выберите файл для записи" #: ../gramps/gui/plug/export/_exportassistant.py:358 -#: ../gramps/plugins/tool/mediamanager.py:103 +#: ../gramps/plugins/tool/mediamanager.py:105 msgid "Final confirmation" msgstr "Окончательное подтверждение" @@ -17501,12 +17493,12 @@ msgid "Please select a book item to configure." msgstr "Выберите элемент книги для настройки." #: ../gramps/gui/plug/report/_bookdialog.py:619 -#: ../gramps/gui/views/bookmarks.py:252 ../gramps/gui/views/tags.py:420 +#: ../gramps/gui/views/bookmarks.py:281 ../gramps/gui/views/tags.py:420 msgid "_Up" msgstr "_Вверх" #: ../gramps/gui/plug/report/_bookdialog.py:620 -#: ../gramps/gui/views/bookmarks.py:253 ../gramps/gui/views/tags.py:421 +#: ../gramps/gui/views/bookmarks.py:282 ../gramps/gui/views/tags.py:421 msgid "_Down" msgstr "В_низ" @@ -17816,7 +17808,7 @@ msgstr "Для работы этого инструмента необходим #: ../gramps/gui/selectors/selectcitation.py:51 msgid "manual|Select_Source_or_Citation_selector" -msgstr "" +msgstr "Выбор_источника_или_цитаты" #: ../gramps/gui/selectors/selectcitation.py:67 msgid "Select Source or Citation" @@ -17841,7 +17833,7 @@ msgstr "Последнее изменение" #: ../gramps/gui/selectors/selectevent.py:46 msgid "manual|Select_Event_selector" -msgstr "" +msgstr "Выбор_события" #: ../gramps/gui/selectors/selectevent.py:62 msgid "Select Event" @@ -17849,11 +17841,11 @@ msgstr "Выберите событие" #: ../gramps/gui/selectors/selectfamily.py:46 msgid "manual|Select_Family_selector" -msgstr "" +msgstr "Выбор_семьи" #: ../gramps/gui/selectors/selectnote.py:49 msgid "manual|Select_Note_selector" -msgstr "" +msgstr "Выбор_заметки" #: ../gramps/gui/selectors/selectnote.py:67 msgid "Select Note" @@ -17861,7 +17853,7 @@ msgstr "Выберите заметку" #: ../gramps/gui/selectors/selectobject.py:60 msgid "manual|Select_Media_Object_selector" -msgstr "" +msgstr "Выбор_документа" #: ../gramps/gui/selectors/selectobject.py:70 msgid "Select Media Object" @@ -17869,19 +17861,19 @@ msgstr "Выберите документ" #: ../gramps/gui/selectors/selectperson.py:54 msgid "manual|Select_Child_selector" -msgstr "" +msgstr "Выбор_ребёнка" #: ../gramps/gui/selectors/selectperson.py:56 msgid "manual|Select_Father_selector" -msgstr "" +msgstr "Выбор_отца" #: ../gramps/gui/selectors/selectperson.py:58 msgid "manual|Select_Mother_selector" -msgstr "" +msgstr "Выбор_матери" #: ../gramps/gui/selectors/selectplace.py:47 msgid "manual|Select_Place_selector" -msgstr "" +msgstr "Выбор_места" #: ../gramps/gui/selectors/selectplace.py:63 msgid "Select Place" @@ -17982,23 +17974,23 @@ msgstr "Первоначальное время" msgid "Action" msgstr "Действие" -#: ../gramps/gui/undohistory.py:197 +#: ../gramps/gui/undohistory.py:196 msgid "Delete confirmation" msgstr "Подтверждение удаления" -#: ../gramps/gui/undohistory.py:198 +#: ../gramps/gui/undohistory.py:197 msgid "Are you sure you want to clear the Undo history?" msgstr "Вы уверены, что хотите очистить историю откатов?" -#: ../gramps/gui/undohistory.py:199 ../gramps/plugins/gramplet/eval.py:80 +#: ../gramps/gui/undohistory.py:198 ../gramps/plugins/gramplet/eval.py:80 msgid "Clear" msgstr "Очистить" -#: ../gramps/gui/undohistory.py:235 +#: ../gramps/gui/undohistory.py:234 msgid "Database opened" msgstr "База данных открыта" -#: ../gramps/gui/undohistory.py:237 +#: ../gramps/gui/undohistory.py:236 msgid "History cleared" msgstr "История очищена" @@ -18401,16 +18393,18 @@ msgstr "Резервная копия сохранена в '%s'" msgid "Backup aborted" msgstr "Резервное копирование прервано" -#: ../gramps/gui/views/bookmarks.py:65 +#: ../gramps/gui/views/bookmarks.py:66 msgid "manual|Bookmarks" msgstr "Закладки" -#: ../gramps/gui/views/bookmarks.py:227 ../gramps/gui/views/bookmarks.py:234 +#. this is meaningless while it's modal +#: ../gramps/gui/views/bookmarks.py:253 ../gramps/gui/views/bookmarks.py:264 +#: ../gramps/gui/views/bookmarks.py:357 #: ../gramps/gui/views/navigationview.py:276 msgid "Organize Bookmarks" msgstr "Редактор закладок" -#: ../gramps/gui/views/bookmarks.py:433 +#: ../gramps/gui/views/bookmarks.py:460 msgid "Cannot bookmark this reference" msgstr "Не могу добавить закладку" @@ -18497,19 +18491,19 @@ msgstr "У_далить элемент" msgid "Column clicked, sorting..." msgstr "Выбран столбец, сортирую..." -#: ../gramps/gui/views/listview.py:1020 +#: ../gramps/gui/views/listview.py:1019 msgid "Export View as Spreadsheet" msgstr "Экспортировать вид в таблицу" -#: ../gramps/gui/views/listview.py:1033 +#: ../gramps/gui/views/listview.py:1032 msgid "CSV" msgstr "CSV" -#: ../gramps/gui/views/listview.py:1034 +#: ../gramps/gui/views/listview.py:1033 msgid "OpenDocument Spreadsheet" msgstr "Таблица OpenDocument" -#: ../gramps/gui/views/listview.py:1222 +#: ../gramps/gui/views/listview.py:1221 msgid "Columns" msgstr "Колонки" @@ -18614,11 +18608,11 @@ msgstr "Вид %(name)s: %(msg)s" #: ../gramps/gui/views/tags.py:87 msgid "manual|Organize_Tags_Window" -msgstr "Окно организации меток" +msgstr "Управление_метками" #: ../gramps/gui/views/tags.py:88 msgid "manual|New_Tag_dialog" -msgstr "Диалог новых меток" +msgstr "Новая_метка" #: ../gramps/gui/views/tags.py:227 msgid "New Tag..." @@ -18703,6 +18697,11 @@ msgstr "Редактировать метку (%s)" msgid "Tag Name:" msgstr "Имя метки:" +#: ../gramps/gui/views/tags.py:638 +#, python-format +msgid "%(title)s - Gramps" +msgstr "%(title)s - Gramps" + #: ../gramps/gui/views/tags.py:638 msgid "Pick a Color" msgstr "Выберите цвет" @@ -18714,12 +18713,8 @@ msgstr "Выберите цвет" msgid "Error in format" msgstr "Ошибка в формате" -#: ../gramps/gui/views/treemodels/treebasemodel.py:535 -#: ../gramps/gui/views/treemodels/treebasemodel.py:586 -msgid "Building View" -msgstr "Подготовка данных к отображению" - -#: ../gramps/gui/views/treemodels/treebasemodel.py:589 +#: ../gramps/gui/views/treemodels/treebasemodel.py:533 +#: ../gramps/gui/views/treemodels/treebasemodel.py:581 msgid "Loading items..." msgstr "Загрузка объектов..." @@ -30829,12 +30824,16 @@ msgid "Complete Individual Report" msgstr "Полный индивидуальный отчёт" #: ../gramps/plugins/textreport/indivcomplete.py:909 -#: ../gramps/plugins/tool/dumpgenderstats.py:63 +#: ../gramps/plugins/tool/dumpgenderstats.py:72 +#: ../gramps/plugins/tool/dumpgenderstats.py:96 +#: ../gramps/plugins/tool/dumpgenderstats.py:99 msgid "Male" msgstr "Мужской" #: ../gramps/plugins/textreport/indivcomplete.py:911 -#: ../gramps/plugins/tool/dumpgenderstats.py:64 +#: ../gramps/plugins/tool/dumpgenderstats.py:73 +#: ../gramps/plugins/tool/dumpgenderstats.py:97 +#: ../gramps/plugins/tool/dumpgenderstats.py:99 msgid "Female" msgstr "Женский" @@ -31471,7 +31470,7 @@ msgstr "_Принять изменения и закрыть" #: ../gramps/plugins/tool/changenames.py:64 msgid "manual|Fix_Capitalization_of_Family_Names" -msgstr "Исправление регистра в фамилиях" +msgstr "Исправление_регистра_в_фамилиях" #: ../gramps/plugins/tool/changenames.py:75 #: ../gramps/plugins/tool/changenames.py:236 @@ -32106,11 +32105,13 @@ msgstr "Модуль проверки дат" msgid "Pass" msgstr "Пройден" -#: ../gramps/plugins/tool/dumpgenderstats.py:46 +#: ../gramps/plugins/tool/dumpgenderstats.py:57 msgid "Gender Statistics tool" msgstr "Статистика полов" -#: ../gramps/plugins/tool/dumpgenderstats.py:66 +#: ../gramps/plugins/tool/dumpgenderstats.py:75 +#: ../gramps/plugins/tool/dumpgenderstats.py:97 +#: ../gramps/plugins/tool/dumpgenderstats.py:100 msgid "Guess" msgstr "Предположение" @@ -32132,7 +32133,7 @@ msgstr "Редактор фильтров поль_зователя" #: ../gramps/plugins/tool/eventcmp.py:70 msgid "manual|Compare_Individual_Events" -msgstr "Сравнить личные события" +msgstr "Сравнение_личных_событий" #: ../gramps/plugins/tool/eventcmp.py:138 msgid "Event comparison filter selection" @@ -32236,7 +32237,7 @@ msgstr "Средняя" #: ../gramps/plugins/tool/finddupes.py:66 msgid "manual|Find_Possible_Duplicate_People" -msgstr "Поиск возможных дубликатов лиц" +msgstr "Поиск_возможных_дубликатов_лиц" #: ../gramps/plugins/tool/finddupes.py:126 #: ../gramps/plugins/tool/tools.gpr.py:153 @@ -32303,7 +32304,7 @@ msgstr "Объединить людей" #: ../gramps/plugins/tool/findloop.py:56 msgid "manual|Find_database_loop" -msgstr "" +msgstr "Поиск_цикла_базы_данных" #: ../gramps/plugins/tool/findloop.py:70 #: ../gramps/plugins/tool/tools.gpr.py:465 @@ -32329,26 +32330,28 @@ msgstr "Предок" msgid "Descendant" msgstr "Потомок" -#: ../gramps/plugins/tool/mediamanager.py:67 +#: ../gramps/plugins/tool/mediamanager.py:68 msgid "manual|Media_Manager..." -msgstr "" +msgstr "Управление_документами..." #: ../gramps/plugins/tool/mediamanager.py:88 -msgid "Gramps Media Manager" -msgstr "Управление документами Gramps" +#: ../gramps/plugins/tool/mediamanager.py:114 +#: ../gramps/plugins/tool/tools.gpr.py:176 +msgid "Media Manager" +msgstr "Управление документами" -#: ../gramps/plugins/tool/mediamanager.py:95 +#: ../gramps/plugins/tool/mediamanager.py:97 #: ../gramps/plugins/webreport/narrativeweb.py:1871 #: ../gramps/plugins/webreport/narrativeweb.py:1994 #: ../gramps/plugins/webreport/narrativeweb.py:4669 msgid "Introduction" msgstr "Введение" -#: ../gramps/plugins/tool/mediamanager.py:98 +#: ../gramps/plugins/tool/mediamanager.py:100 msgid "Selection" msgstr "Выделение" -#: ../gramps/plugins/tool/mediamanager.py:220 +#: ../gramps/plugins/tool/mediamanager.py:229 #, python-format msgid "" "This tool allows batch operations on media objects stored in Gramps. An " @@ -32386,33 +32389,33 @@ msgstr "" "для исправления пути/имени изменённых файлов, чтобы документы содержали " "правильное положение файлов." -#: ../gramps/plugins/tool/mediamanager.py:331 +#: ../gramps/plugins/tool/mediamanager.py:340 msgid "Affected path" msgstr "Подпадающий путь" -#: ../gramps/plugins/tool/mediamanager.py:338 +#: ../gramps/plugins/tool/mediamanager.py:347 msgid "" "Press Apply to proceed, Cancel to abort, or Back to revisit your options." msgstr "" "Нажмите «Применить» для продолжения, «Отмена» для отказа, или «Назад» для " "пересмотра возможностей." -#: ../gramps/plugins/tool/mediamanager.py:376 +#: ../gramps/plugins/tool/mediamanager.py:385 msgid "Operation successfully finished" msgstr "Операция успешно завершена" -#: ../gramps/plugins/tool/mediamanager.py:378 +#: ../gramps/plugins/tool/mediamanager.py:387 msgid "" "The operation you requested has finished successfully. You may press Close " "now to continue." msgstr "" "Затребованная операция успешно завершена. Нажмите «Закрыть» для продолжения." -#: ../gramps/plugins/tool/mediamanager.py:381 +#: ../gramps/plugins/tool/mediamanager.py:390 msgid "Operation failed" msgstr "Операция не удалась" -#: ../gramps/plugins/tool/mediamanager.py:383 +#: ../gramps/plugins/tool/mediamanager.py:392 msgid "" "There was an error while performing the requested operation. You may try " "starting the tool again." @@ -32420,7 +32423,7 @@ msgstr "" "Ошибка при выполнении затребованной операции. Попробуйте запустить " "инструмент ещё раз." -#: ../gramps/plugins/tool/mediamanager.py:418 +#: ../gramps/plugins/tool/mediamanager.py:427 #, python-format msgid "" "The following action is to be performed:\n" @@ -32431,11 +32434,11 @@ msgstr "" "\n" "Операция:\t%s" -#: ../gramps/plugins/tool/mediamanager.py:475 +#: ../gramps/plugins/tool/mediamanager.py:484 msgid "Replace _substrings in the path" msgstr "Заменить _подстроку в пути" -#: ../gramps/plugins/tool/mediamanager.py:476 +#: ../gramps/plugins/tool/mediamanager.py:485 msgid "" "This tool allows replacing specified substring in the path of media objects " "with another substring. This can be useful when you move your media files " @@ -32445,19 +32448,19 @@ msgstr "" "подстроку. Это полезно при перемещении базы данных из одного каталога в " "другой" -#: ../gramps/plugins/tool/mediamanager.py:482 +#: ../gramps/plugins/tool/mediamanager.py:491 msgid "Replace substring settings" msgstr "Установки замены строк" -#: ../gramps/plugins/tool/mediamanager.py:495 +#: ../gramps/plugins/tool/mediamanager.py:504 msgid "_Replace:" msgstr "_Заменить:" -#: ../gramps/plugins/tool/mediamanager.py:505 +#: ../gramps/plugins/tool/mediamanager.py:514 msgid "_With:" msgstr "Н_а:" -#: ../gramps/plugins/tool/mediamanager.py:519 +#: ../gramps/plugins/tool/mediamanager.py:528 #, python-format msgid "" "The following action is to be performed:\n" @@ -32472,11 +32475,11 @@ msgstr "" "Заменить:\t%(src_fname)s\n" "На:\t\t%(dest_fname)s" -#: ../gramps/plugins/tool/mediamanager.py:560 +#: ../gramps/plugins/tool/mediamanager.py:569 msgid "Convert paths from relative to _absolute" msgstr "Преобразовать относительный путь в _абсолютный" -#: ../gramps/plugins/tool/mediamanager.py:561 +#: ../gramps/plugins/tool/mediamanager.py:570 msgid "" "This tool allows converting relative media paths to the absolute ones. It " "does this by prepending the base path as given in the Preferences, or if " @@ -32487,11 +32490,11 @@ msgstr "" "документов, заданного в настройках, или, если эта настройка не задана, " "домашнего каталога пользователя." -#: ../gramps/plugins/tool/mediamanager.py:594 +#: ../gramps/plugins/tool/mediamanager.py:603 msgid "Convert paths from absolute to r_elative" msgstr "Преобразовать абсолютный путь в о_тносительный" -#: ../gramps/plugins/tool/mediamanager.py:595 +#: ../gramps/plugins/tool/mediamanager.py:604 msgid "" "This tool allows converting absolute media paths to a relative path. The " "relative path is relative viz-a-viz the base path as given in the " @@ -32505,15 +32508,15 @@ msgstr "" "положение файла к базовому каталогу, который вы можете менять в соответствии " "со своими потребностями." -#: ../gramps/plugins/tool/mediamanager.py:631 +#: ../gramps/plugins/tool/mediamanager.py:640 msgid "Add images not included in database" msgstr "Добавить изображения, не включённые в базу данных" -#: ../gramps/plugins/tool/mediamanager.py:632 +#: ../gramps/plugins/tool/mediamanager.py:641 msgid "Check directories for images not included in database" msgstr "Проверить каталоги на наличие изображений отсутствующих в базе данных" -#: ../gramps/plugins/tool/mediamanager.py:633 +#: ../gramps/plugins/tool/mediamanager.py:642 msgid "" "This tool adds images in directories that are referenced by existing images " "in the database." @@ -32543,7 +32546,7 @@ msgstr "Игнорировать дату и достоверность" #: ../gramps/plugins/tool/mergecitations.py:83 msgid "manual|Merge_citations" -msgstr "Объединение цитат" +msgstr "Объединение_цитат" #: ../gramps/plugins/tool/mergecitations.py:133 msgid "" @@ -32582,7 +32585,7 @@ msgstr "_Метка" #: ../gramps/plugins/tool/notrelated.py:60 msgid "manual|Not_Related" -msgstr "Не связанные" +msgstr "Не_связанные" #: ../gramps/plugins/tool/notrelated.py:80 #, python-format @@ -32675,7 +32678,7 @@ msgstr "Правый клик для копирования из/в настро #: ../gramps/plugins/tool/ownereditor.py:56 msgid "manual|Edit_Database_Owner_Information" -msgstr "Редактировать информацию о владельце базы данных" +msgstr "Изменение_информации_о_владельце_базы_данных" #: ../gramps/plugins/tool/ownereditor.py:102 msgid "Database Owner Editor" @@ -32718,7 +32721,7 @@ msgstr "" #: ../gramps/plugins/tool/patchnames.py:63 msgid "manual|Extract_Information_from_Names" -msgstr "" +msgstr "Извлечение_информации_из_имён" #: ../gramps/plugins/tool/patchnames.py:106 msgid "Name and title extraction tool" @@ -33189,10 +33192,6 @@ msgstr "" "Просматривает всю базу данных в поиске записей, которые могут представлять " "одно и тоже лицо." -#: ../gramps/plugins/tool/tools.gpr.py:176 -msgid "Media Manager" -msgstr "Управление документами" - #: ../gramps/plugins/tool/tools.gpr.py:177 msgid "Manages batch operations on media files" msgstr "Управляет потоковыми операциями над документами" @@ -33367,7 +33366,7 @@ msgstr "Скр_ыть отмеченное" #: ../gramps/plugins/tool/verify.py:83 msgid "manual|Verify_the_Data" -msgstr "Проверка данных" +msgstr "Проверка_данных" #: ../gramps/plugins/tool/verify.py:295 msgid "Data Verify tool" @@ -36397,6 +36396,15 @@ msgstr "Небраска" msgid "No style sheet" msgstr "Без стилевого листа" +#~ msgid "Gramps Media Manager" +#~ msgstr "Управление документами Gramps" + +#~ msgid "Building View" +#~ msgstr "Подготовка данных к отображению" + +#~ msgid "Edit Tags" +#~ msgstr "Редактировать метки" + #~ msgid "You need to restart Gramps to use the new addons." #~ msgstr "" #~ "Необходимо перезапустить Gramps, чтобы использовать новые дополнения."