Skip to content

Gram.py Refinements #668

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: maintenance/gramps60
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 27 additions & 1 deletion GrampyScript/datadict2.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ def flatten(lst):
result.append(item)
return result


class NoneData:

# def __setattr__(self, attr, value):
Expand All @@ -68,6 +69,9 @@ def __call__(self, *args, **kwargs):
# print(args, kwargs)
return ""

def __iter__(self):
return iter([])


class DataDict2(dict):
"""
Expand Down Expand Up @@ -234,7 +238,9 @@ def tags(self):
def citations(self):
return DataList2(
[
DataDict2(sa.dbase.get_raw_citation_data(handle), callback=self.callback)
DataDict2(
sa.dbase.get_raw_citation_data(handle), callback=self.callback
)
for handle in self.citation_list
],
)
Expand All @@ -252,6 +258,10 @@ def events(self):
],
)

@property
def reference(self):
return DataDict2(sa.dbase.get_raw_person_data(self.ref), callback=self.callback)

@property
def attributes(self):
return self.attribute_list
Expand All @@ -268,6 +278,22 @@ def lds_ords(self):
def references(self):
return self.person_ref_list

@property
def back_references(self):
retval = []
for obj_type, ohandle in sa.dbase.find_backlink_handles(self.handle):
obj = sa.dbase.method("get_%s_from_handle", obj_type)(ohandle)
retval.append(DataDict2(obj, callback=self.callback))
return DataList2(retval)

@property
def back_references_recursively(self):
retval = []
for obj_type, ohandle in self._object.get_referenced_handles_recursively():
obj = sa.dbase.method("get_%s_from_handle", obj_type)(ohandle)
retval.append(DataDict2(obj, callback=self.callback))
return DataList2(retval)

@property
def name(self):
if self["_class"] == "Person":
Expand Down