本文整理汇总了Python中gramps.gen.simple.SimpleAccess类的典型用法代码示例。如果您正苦于以下问题:Python SimpleAccess类的具体用法?Python SimpleAccess怎么用?Python SimpleAccess使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SimpleAccess类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_mother
def run_mother(database, document, person):
""" Function writing the mother lineage quick report
"""
sa = SimpleAccess(database)
sd = SimpleDoc(document)
# display the results
# feature request 2356: avoid genitive form
sd.title(_("Mother lineage for %s") % sa.name(person))
sd.paragraph("")
sd.paragraph(_(""
"This report shows the mother lineage, also called matronymic lineage "
"mtDNA lineage."
" People in this lineage all share the same Mitochondrial DNA (mtDNA)."
))
sd.paragraph("")
stab = QuickTable(sa)
stab.columns(_("Name Mother"), _("Birth"), _("Death Date"), _("Remark"))
make_details(Person.FEMALE, person, sa, sd, database, stab)
stab.write(sd)
sd.paragraph("")
if person.gender == Person.MALE :
return
sd.header2((_("Direct line female descendants")))
sd.paragraph("")
make_details_child(Person.FEMALE, person, sa, sd, database)
示例2: get_sources
def get_sources(database, person):
"""
Create list of sources for person's events
"""
sources = list()
sa = SimpleAccess(database)
events = sa.events(person)
# Get family events also
for family in sa.parent_in(person):
for event in sa.events(family):
events.append(event)
for event in events:
for handle in event.citation_list:
citation = database.get_citation_from_handle(handle)
page = citation.page
source = database.get_source_from_handle(citation.source_handle)
title = source.title
author = source.author
if author:
source_desc = '* {}, {} - {}'.format(author, title, page)
else:
source_desc = '* {} - {}'.format(title, page)
if source_desc not in sources:
sources.append(source_desc)
return sources
示例3: run
def run(database, document, person):
"""
Output a text biography of active person
"""
sa = SimpleAccess(database)
sd = SimpleDoc(document)
sd.title("Biography for %s" % sa.name(person))
sd.paragraph('')
narrator = Narrator(database, verbose=True,
use_call_name=True, use_fulldate=True)
narrator.set_subject(person)
# Birth Details
text = narrator.get_born_string()
if text:
sd.paragraph(text)
text = narrator.get_baptised_string()
if text:
sd.paragraph(text)
text = narrator.get_christened_string()
if text:
sd.paragraph(text)
text = get_parents_desc(database, person)
if text:
sd.paragraph(text)
sd.paragraph('')
# Family Details
for family in sa.parent_in(person):
text = narrator.get_married_string(family)
if text:
sd.paragraph(text)
sd.paragraph('')
# Death Details
text = narrator.get_died_string(True)
if text:
sd.paragraph(text)
text = narrator.get_buried_string()
if text:
sd.paragraph(text)
sd.paragraph('')
# Sources
sd.header1('Sources')
for source in get_sources(database, person):
sd.paragraph(source)
示例4: run
def run(database, document, date):
"""
Display people probably alive and their ages on a particular date.
"""
# setup the simple access functions
sdb = SimpleAccess(database)
sdoc = SimpleDoc(document)
stab = QuickTable(sdb)
if not date.get_valid():
sdoc.paragraph("Date is not a valid date.")
return
# display the title
if date.get_day_valid():
sdoc.title(_("People and their ages the %s") %
displayer.display(date))
else:
sdoc.title(_("People and their ages on %s") %
displayer.display(date))
stab.columns(_("Person"), _("Age"), _("Status")) # Actual Date makes column unicode
alive_matches = 0
dead_matches = 0
for person in sdb.all_people():
alive, birth, death, explain, relative = \
probably_alive(person, database, date, return_range=True)
# Doesn't show people probably alive but no way of figuring an age:
if alive:
if birth:
diff_span = (date - birth)
stab.row(person, str(diff_span), _("Alive: %s") % explain)
stab.row_sort_val(1, int(diff_span))
else:
stab.row(person, "", _("Alive: %s") % explain)
stab.row_sort_val(1, 0)
alive_matches += 1
else: # not alive
if birth:
diff_span = (date - birth)
stab.row(person, str(diff_span), _("Deceased: %s") % explain)
stab.row_sort_val(1, int(diff_span))
else:
stab.row(person, "", _("Deceased: %s") % explain)
stab.row_sort_val(1, 1)
dead_matches += 1
document.has_data = (alive_matches + dead_matches) > 0
sdoc.paragraph(_("\nLiving matches: %(alive)d, "
"Deceased matches: %(dead)d\n") %
{'alive' : alive_matches, 'dead' : dead_matches})
if document.has_data:
stab.write(sdoc)
sdoc.paragraph("")
示例5: make_tooltip_from_link
def make_tooltip_from_link(self, link_tag):
"""
Return a string useful for a tooltip given a LinkTag object.
"""
from gramps.gen.simple import SimpleAccess
win_obj = find_parent_with_attr(self, attr="dbstate")
display = link_tag.data
if win_obj:
simple_access = SimpleAccess(win_obj.dbstate.db)
url = link_tag.data
if url.startswith("gramps://"):
obj_class, prop, value = url[9:].split("/")
display = simple_access.display(obj_class, prop, value) or url
return display
示例6: main
def main(self):
database = self.dbstate.db
simple_a = SimpleAccess(database)
# stime = time.perf_counter()
counts_list = {}
count = 0
self.model.clear()
for person in database.iter_people():
if count == 200:
count = 0
yield True
count += 1
result = len(countem(database, person, counts_list))
self.model.append((simple_a.describe(person), result,
person.handle))
self.set_has_data(len(self.model) > 0)
示例7: __init__
def __init__(self, database, document, person):
self.database = database
self.person = person
self.sdb = SimpleAccess(database)
self.sdoc = SimpleDoc(document)
self.rel_class = get_relationship_calculator(glocale)
self.msg_list = []
示例8: run
def run(database, document, person):
"""
Loops through the families that the person is a child in, and displays
the information about the other children.
"""
# setup the simple access functions
sdb = SimpleAccess(database)
sdoc = SimpleDoc(document)
stab = QuickTable(sdb)
if isinstance(person, Person):
surname = sdb.surname(person)
rsurname = person.get_primary_name().get_group_name()
else:
surname = person
rsurname = person
# display the title
sdoc.title(_("People sharing the surname '%s'") % surname)
sdoc.paragraph("")
stab.columns(_("Person"), _("Birth Date"), _("Name type"))
filter = GenericFilterFactory('Person')()
if rsurname != '':
rule = SameSurname([rsurname])
else:
rule = IncompleteSurname([])
filter.add_rule(rule)
people = filter.apply(database,
database.iter_person_handles())
matches = 0
for person_handle in people:
person = database.get_person_from_handle(person_handle)
stab.row(person, sdb.birth_or_fallback(person),
str(person.get_primary_name().get_type()))
matches += 1
document.has_data = matches > 0
sdoc.paragraph(
# translators: leave all/any {...} untranslated
ngettext("There is {number_of} person "
"with a matching name, or alternate name.\n",
"There are {number_of} people "
"with a matching name, or alternate name.\n", matches
).format(number_of=matches) )
stab.write(sdoc)
示例9: __init__
def __init__(self, dbstate, uistate, track, url, callback):
self.url = url
self.dbstate = dbstate
self.simple_access = SimpleAccess(self.dbstate.db)
self.callback = callback
ManagedWindow.__init__(self, uistate, track, url)
self._local_init()
self._connect_signals()
self.show()
示例10: run
def run(database, document, person):
"""
Display a person's timeline.
"""
sa = SimpleAccess(database)
sd = SimpleDoc(document)
sd.title(_("Timeline for %s") % sa.name(person))
sd.paragraph("")
stab = QuickTable(sa)
stab.columns(_("Date"),
_("Event"),
_("Age"),
_("Place"),
_("People involved"))
stab.set_link_col(4)
handled = {}
birth_ref = gramps.gen.lib.Person.get_birth_ref(person)
birth_date = get_event_date_from_ref(database, birth_ref)
event_list = []
process(database, sa, event_list, handled, person, False, person)
for (event, obj, desc) in sorted(event_list, key=by_date):
edate = sa.event_date_obj(event)
span_str, span_int = format_date(birth_date, edate, obj == person)
if desc == None:
desc = event
stab.row(edate,
desc,
span_str,
sa.event_place(event),
obj)
stab.row_sort_val(2, span_int)
today = Today()
span_str, span_int = format_date(birth_date, today, False)
stab.row(today, _("Today"), span_str, "", person)
stab.row_sort_val(2, span_int)
stab.write(sd)
sd.paragraph("")
示例11: run
def run(database, document, obj):
"""
Display link references for this note.
"""
# setup the simple access functions
sdb = SimpleAccess(database)
sdoc = SimpleDoc(document)
stab = QuickTable(sdb)
# display the title
sdoc.title(_("Link References for this note"))
sdoc.paragraph("\n")
stab.columns(_("Type"), _("Reference"), _("Link check"))
for (ldomain, ltype, lprop, lvalue) in obj.get_links():
if ldomain == "gramps":
tagtype = _(ltype)
ref_obj = sdb.get_link(ltype, lprop, lvalue)
if ref_obj:
tagvalue = ref_obj
tagcheck = _("Ok")
else:
tagvalue = lvalue
tagcheck = _("Failed: missing object")
else:
tagtype = _("Internet")
tagvalue = lvalue
tagcheck = ""
stab.row(tagtype, tagvalue, tagcheck)
if stab.get_row_count() > 0:
stab.write(sdoc)
document.has_data = True
else:
sdoc.paragraph(_("No link references for this note"))
sdoc.paragraph("")
document.has_data = False
sdoc.paragraph("")
示例12: query
def query(self, query):
self.parse(query)
self.select = 0
start_time = time.time()
class Table():
results = []
def row(self, *args, **kwargs):
self.results.append([args, kwargs])
def get_rows(self):
return [list(item[0]) for item in self.results]
table = Table()
self.sdb = SimpleAccess(self.database)
self.process_table(table) # a class that has .row(1, 2, 3, ...)
print(_("%d rows processed in %s seconds.\n") % (self.select, time.time() - start_time))
return table
示例13: get_parents_desc
def get_parents_desc(database, person):
"""
Return text describing person's parents
"""
sa = SimpleAccess(database)
narrator = Narrator(database, verbose=True,
use_call_name=True, use_fulldate=True)
narrator.set_subject(person)
family_handle = person.get_main_parents_family_handle()
if family_handle:
family = database.get_family_from_handle(family_handle)
mother_handle = family.get_mother_handle()
father_handle = family.get_father_handle()
if mother_handle:
mother = database.get_person_from_handle(mother_handle)
mother_name = sa.name(mother)
else:
mother_name = ""
if father_handle:
father = database.get_person_from_handle(father_handle)
father_name = sa.name(father)
else:
father_name = ""
return narrator.get_child_string(father_name, mother_name)
示例14: eval
def eval(self):
"""
Execute the query.
"""
self.sdb = SimpleAccess(self.database)
self.stab = QuickTable(self.sdb)
self.select = 0
start_time = time.time()
self.process_table(self.stab) # a class that has .row(1, 2, 3, ...)
if self.select > 0:
self.stab.columns(*self.clean_titles(self.columns))
self.sdoc = SimpleDoc(self.document)
self.sdoc.title(self.query_text)
self.sdoc.paragraph("\n")
self.sdoc.paragraph("%d rows processed in %s seconds.\n" % (self.select, time.time() - start_time))
self.stab.write(self.sdoc)
self.sdoc.paragraph("")
return _("%d rows processed in %s seconds.\n") % (self.select, time.time() - start_time)
示例15: run
def run(database, document, person):
"""
Loops through the families that the person is a child in, and display
the information about the other children.
"""
# setup the simple access functions
sdb = SimpleAccess(database)
sdoc = SimpleDoc(document)
stab = QuickTable(sdb)
rel_class = get_relationship_calculator(glocale)
# display the title
# feature request 2356: avoid genitive form
sdoc.title(_("Siblings of %s") % sdb.name(person))
sdoc.paragraph("")
stab.columns(_("Sibling"), _("Gender"), _("Birth Date"), _("Type"))
# grab our current id (self):
gid = sdb.gid(person)
# loop through each family in which the person is a child
document.has_data = False
for family in sdb.child_in(person):
# loop through each child in the family
for child in sdb.children(family):
# only display if this child is not the active person
if sdb.gid(child) != gid:
rel_str = rel_class.get_sibling_relationship_string(
rel_class.get_sibling_type(database, person, child),
person.get_gender(), child.get_gender())
else:
rel_str = _('self')
# pass row the child object to make link:
stab.row(child,
sdb.gender(child),
sdb.birth_or_fallback(child),
rel_str)
document.has_data = True
if document.has_data:
stab.write(sdoc)
else:
sdoc.header1(_("Not found") + "\n")