本文整理汇总了Python中gramps.plugins.lib.libnarrate.Narrator类的典型用法代码示例。如果您正苦于以下问题:Python Narrator类的具体用法?Python Narrator怎么用?Python Narrator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Narrator类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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)
示例2: __init__
def __init__(self, database, options, user):
"""
Create the AncestorReport object that produces the Ahnentafel report.
The arguments are:
database - the Gramps database instance
options - instance of the Options class for this report
user - a gen.user.User() instance
This report needs the following parameters (class variables)
that come in the options class.
gen - Maximum number of generations to include.
pagebbg - Whether to include page breaks between generations.
name_format - Preferred format to display names
incl_private - Whether to include private data
namebrk - Whether a line break should follow the name
inc_id - Whether to include Gramps IDs
living_people - How to handle living people
years_past_death - Consider as living this many years after death
"""
Report.__init__(self, database, options, user)
self.map = {}
menu = options.menu
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database)
self.max_generations = menu.get_option_by_name('maxgen').get_value()
self.pgbrk = menu.get_option_by_name('pagebbg').get_value()
self.opt_namebrk = menu.get_option_by_name('namebrk').get_value()
self.want_ids = menu.get_option_by_name('inc_id').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = self.database.get_person_from_gramps_id(pid)
if self.center_person is None:
raise ReportError(_("Person %s is not in the Database") % pid)
stdoptions.run_name_format_option(self, menu)
self.__narrator = Narrator(self.database, use_fulldate=True,
nlocale=self._locale)
示例3: 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)
示例4: __init__
def __init__(self, database, options, user):
"""
Create the AncestorReport object that produces the Ahnentafel report.
The arguments are:
database - the GRAMPS database instance
options - instance of the Options class for this report
user - a gen.user.User() instance
This report needs the following parameters (class variables)
that come in the options class.
gen - Maximum number of generations to include.
pagebbg - Whether to include page breaks between generations.
name_format - Preferred format to display names
incl_private - Whether to include private data
"""
Report.__init__(self, database, options, user)
self.map = {}
menu = options.menu
stdoptions.run_private_data_option(self, menu)
self.max_generations = menu.get_option_by_name('maxgen').get_value()
self.pgbrk = menu.get_option_by_name('pagebbg').get_value()
self.opt_namebrk = menu.get_option_by_name('namebrk').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid)
if (self.center_person == None) :
raise ReportError(_("Person %s is not in the Database") % pid )
lang = menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
stdoptions.run_name_format_option(self, menu)
self.__narrator = Narrator(self.database, use_fulldate=True,
nlocale=rlocale)
示例5: __init__
#.........这里部分代码省略.........
fulldates - Whether to use full dates instead of just year.
listc - Whether to list children.
incnotes - Whether to include notes.
usecall - Whether to use the call name as the first name.
repplace - Whether to replace missing Places with ___________.
repdate - Whether to replace missing Dates with ___________.
computeage - Whether to compute age.
omitda - Whether to omit duplicate ancestors
(e.g. when distant cousins marry).
verbose - Whether to use complete sentences.
numbering - The descendancy numbering system to be utilized.
desref - Whether to add descendant references in child list.
incphotos - Whether to include images.
incnames - Whether to include other names.
incevents - Whether to include events.
incaddresses - Whether to include addresses.
incsrcnotes - Whether to include source notes in the Endnotes
section. Only works if Include sources is selected.
incmates - Whether to include information about spouses
incattrs - Whether to include attributes
incpaths - Whether to include the path of descendancy
from the start-person to each descendant.
incssign - Whether to include a sign ('+') before the
descendant number in the child-list
to indicate a child has succession.
pid - The Gramps ID of the center person for the report.
name_format - Preferred format to display names
incmateref - Whether to print mate information or reference
incl_private - Whether to include private data
"""
Report.__init__(self, database, options, user)
self.map = {}
self._user = user
menu = options.menu
get_option_by_name = menu.get_option_by_name
get_value = lambda name: get_option_by_name(name).get_value()
stdoptions.run_private_data_option(self, menu)
self.db = self.database
self.max_generations = get_value('gen')
self.pgbrk = get_value('pagebbg')
self.pgbrkenotes = get_value('pageben')
self.fulldate = get_value('fulldates')
use_fulldate = self.fulldate
self.listchildren = get_value('listc')
self.inc_notes = get_value('incnotes')
use_call = get_value('usecall')
blankplace = get_value('repplace')
blankdate = get_value('repdate')
self.calcageflag = get_value('computeage')
self.dubperson = get_value('omitda')
self.verbose = get_value('verbose')
self.numbering = get_value('numbering')
self.childref = get_value('desref')
self.addimages = get_value('incphotos')
self.inc_names = get_value('incnames')
self.inc_events = get_value('incevents')
self.inc_addr = get_value('incaddresses')
self.inc_sources = get_value('incsources')
self.inc_srcnotes = get_value('incsrcnotes')
self.inc_mates = get_value('incmates')
self.inc_attrs = get_value('incattrs')
self.inc_paths = get_value('incpaths')
self.inc_ssign = get_value('incssign')
self.inc_materef = get_value('incmateref')
pid = get_value('pid')
self.center_person = self.db.get_person_from_gramps_id(pid)
if (self.center_person == None) :
raise ReportError(_("Person %s is not in the Database") % pid )
self.gen_handles = {}
self.prev_gen_handles = {}
self.gen_keys = []
self.dnumber = {}
self.dmates = {}
if blankdate:
empty_date = EMPTY_ENTRY
else:
empty_date = ""
if blankplace:
empty_place = EMPTY_ENTRY
else:
empty_place = ""
self._locale = self.set_locale(get_value('trans'))
stdoptions.run_name_format_option(self, menu)
self.__narrator = Narrator(self.db, self.verbose,
use_call, use_fulldate,
empty_date, empty_place,
nlocale=self._locale,
get_endnote_numbers=self.endnotes)
self.bibli = Bibliography(Bibliography.MODE_DATE|Bibliography.MODE_PAGE)
示例6: DetDescendantReport
#.........这里部分代码省略.........
self.inc_addr = get_value('incaddresses')
self.inc_sources = get_value('incsources')
self.inc_srcnotes = get_value('incsrcnotes')
self.inc_mates = get_value('incmates')
self.inc_attrs = get_value('incattrs')
self.inc_paths = get_value('incpaths')
self.inc_ssign = get_value('incssign')
self.inc_materef = get_value('incmateref')
pid = get_value('pid')
self.center_person = self.db.get_person_from_gramps_id(pid)
if (self.center_person == None) :
raise ReportError(_("Person %s is not in the Database") % pid )
self.gen_handles = {}
self.prev_gen_handles = {}
self.gen_keys = []
self.dnumber = {}
self.dmates = {}
if blankdate:
empty_date = EMPTY_ENTRY
else:
empty_date = ""
if blankplace:
empty_place = EMPTY_ENTRY
else:
empty_place = ""
self._locale = self.set_locale(get_value('trans'))
stdoptions.run_name_format_option(self, menu)
self.__narrator = Narrator(self.db, self.verbose,
use_call, use_fulldate,
empty_date, empty_place,
nlocale=self._locale,
get_endnote_numbers=self.endnotes)
self.bibli = Bibliography(Bibliography.MODE_DATE|Bibliography.MODE_PAGE)
def apply_henry_filter(self,person_handle, index, pid, cur_gen=1):
if (not person_handle) or (cur_gen > self.max_generations):
return
self.dnumber[person_handle] = pid
self.map[index] = person_handle
if len(self.gen_keys) < cur_gen:
self.gen_keys.append([index])
else:
self.gen_keys[cur_gen-1].append(index)
person = self.db.get_person_from_handle(person_handle)
index = 0
for family_handle in person.get_family_handle_list():
family = self.db.get_family_from_handle(family_handle)
for child_ref in family.get_child_ref_list():
ix = max(self.map)
self.apply_henry_filter(child_ref.ref, ix+1,
pid+HENRY[index], cur_gen+1)
index += 1
# Filter for d'Aboville numbering
def apply_daboville_filter(self,person_handle, index, pid, cur_gen=1):
if (not person_handle) or (cur_gen > self.max_generations):
return
示例7: AncestorReport
class AncestorReport(Report):
"""
Ancestor Report class
"""
def __init__(self, database, options, user):
"""
Create the AncestorReport object that produces the Ahnentafel report.
The arguments are:
database - the GRAMPS database instance
options - instance of the Options class for this report
user - a gen.user.User() instance
This report needs the following parameters (class variables)
that come in the options class.
gen - Maximum number of generations to include.
pagebbg - Whether to include page breaks between generations.
name_format - Preferred format to display names
incl_private - Whether to include private data
"""
Report.__init__(self, database, options, user)
self.map = {}
menu = options.menu
stdoptions.run_private_data_option(self, menu)
self.max_generations = menu.get_option_by_name('maxgen').get_value()
self.pgbrk = menu.get_option_by_name('pagebbg').get_value()
self.opt_namebrk = menu.get_option_by_name('namebrk').get_value()
pid = menu.get_option_by_name('pid').get_value()
self.center_person = database.get_person_from_gramps_id(pid)
if (self.center_person == None) :
raise ReportError(_("Person %s is not in the Database") % pid )
lang = menu.get_option_by_name('trans').get_value()
rlocale = self.set_locale(lang)
stdoptions.run_name_format_option(self, menu)
self.__narrator = Narrator(self.database, use_fulldate=True,
nlocale=rlocale)
def apply_filter(self, person_handle, index, generation=1):
"""
Recursive function to walk back all parents of the current person.
When max_generations are hit, we stop the traversal.
"""
# check for end of the current recursion level. This happens
# if the person handle is None, or if the max_generations is hit
if not person_handle or generation > self.max_generations:
return
# store the person in the map based off their index number
# which is passed to the routine.
self.map[index] = person_handle
# retrieve the Person instance from the database from the
# passed person_handle and find the parents from the list.
# Since this report is for natural parents (birth parents),
# we have to handle that parents may not
person = self.database.get_person_from_handle(person_handle)
father_handle = None
mother_handle = None
for family_handle in person.get_parent_family_handle_list():
family = self.database.get_family_from_handle(family_handle)
# filter the child_ref_list to find the reference that matches
# the passed person. There should be exactly one, but there is
# nothing that prevents the same child in the list multiple times.
ref = [ c for c in family.get_child_ref_list()
if c.get_reference_handle() == person_handle]
if ref:
# If the father_handle is not defined and the relationship is
# BIRTH, then we have found the birth father. Same applies to
# the birth mother. If for some reason, the we have multiple
# people defined as the birth parents, we will select based on
# priority in the list
if not father_handle and \
ref[0].get_father_relation() == ChildRefType.BIRTH:
father_handle = family.get_father_handle()
if not mother_handle and \
ref[0].get_mother_relation() == ChildRefType.BIRTH:
mother_handle = family.get_mother_handle()
# Recursively call the function. It is okay if the handle is None,
# since routine handles a handle of None
self.apply_filter(father_handle, index*2, generation+1)
self.apply_filter(mother_handle, (index*2)+1, generation+1)
#.........这里部分代码省略.........
示例8: __init__
#.........这里部分代码省略.........
This report needs the following parameters (class variables)
that come in the options class.
gen - Maximum number of generations to include.
inc_id - Whether to include Gramps IDs
pagebgg - Whether to include page breaks between generations.
pageben - Whether to include page break before End Notes.
firstName - Whether to use first names instead of pronouns.
fulldate - Whether to use full dates instead of just year.
listchildren - Whether to list children.
list_children_spouses - Whether to list the spouses of the children
includenotes - Whether to include notes.
incattrs - Whether to include attributes
blankplace - Whether to replace missing Places with ___________.
blankDate - Whether to replace missing Dates with ___________.
calcageflag - Whether to compute age.
dupperson - Whether to omit duplicate ancestors
(e.g. when distant cousins marry).
verbose - Whether to use complete sentences
childref - Whether to add descendant references in child list.
addimages - Whether to include images.
pid - The Gramps ID of the center person for the report.
name_format - Preferred format to display names
other_events - Whether to include other events.
incl_private - Whether to include private data
living_people - How to handle living people
years_past_death - Consider as living this many years after death
"""
Report.__init__(self, database, options, user)
self.map = {}
self._user = user
menu = options.menu
get_option_by_name = menu.get_option_by_name
get_value = lambda name: get_option_by_name(name).get_value()
self.set_locale(menu.get_option_by_name('trans').get_value())
stdoptions.run_date_format_option(self, menu)
stdoptions.run_private_data_option(self, menu)
stdoptions.run_living_people_option(self, menu, self._locale)
self.database = CacheProxyDb(self.database)
self._db = self.database
self.max_generations = get_value('gen')
self.pgbrk = get_value('pagebbg')
self.pgbrkenotes = get_value('pageben')
self.fulldate = get_value('fulldates')
use_fulldate = self.fulldate
self.listchildren = get_value('listc')
self.list_children_spouses = get_value('listc_spouses')
self.includenotes = get_value('incnotes')
use_call = get_value('usecall')
blankplace = get_value('repplace')
blankdate = get_value('repdate')
self.calcageflag = get_value('computeage')
self.dupperson = get_value('omitda')
self.verbose = get_value('verbose')
self.childref = get_value('desref')
self.addimages = get_value('incphotos')
self.inc_names = get_value('incnames')
self.inc_events = get_value('incevents')
self.inc_addr = get_value('incaddresses')
self.inc_sources = get_value('incsources')
self.inc_srcnotes = get_value('incsrcnotes')
self.inc_attrs = get_value('incattrs')
self.initial_sosa = get_value('initial_sosa')
self.want_ids = get_value('inc_id')
pid = get_value('pid')
self.other_events = get_value('incotherevents')
self.center_person = self._db.get_person_from_gramps_id(pid)
if self.center_person is None:
raise ReportError(_("Person %s is not in the Database") % pid)
stdoptions.run_name_format_option(self, menu)
self._nd = self._name_display
self.gen_handles = {}
self.prev_gen_handles = {}
if blankdate:
empty_date = EMPTY_ENTRY
else:
empty_date = ""
if blankplace:
empty_place = EMPTY_ENTRY
else:
empty_place = ""
self.__narrator = Narrator(self._db, self.verbose, use_call,
use_fulldate, empty_date, empty_place,
nlocale=self._locale,
get_endnote_numbers=self.endnotes)
self.bibli = Bibliography(Bibliography.MODE_DATE|Bibliography.MODE_PAGE)
示例9: DetAncestorReport
#.........这里部分代码省略.........
self.childref = get_value('desref')
self.addimages = get_value('incphotos')
self.inc_names = get_value('incnames')
self.inc_events = get_value('incevents')
self.inc_addr = get_value('incaddresses')
self.inc_sources = get_value('incsources')
self.inc_srcnotes = get_value('incsrcnotes')
self.inc_attrs = get_value('incattrs')
self.initial_sosa = get_value('initial_sosa')
self.want_ids = get_value('inc_id')
pid = get_value('pid')
self.other_events = get_value('incotherevents')
self.center_person = self._db.get_person_from_gramps_id(pid)
if self.center_person is None:
raise ReportError(_("Person %s is not in the Database") % pid)
stdoptions.run_name_format_option(self, menu)
self._nd = self._name_display
self.gen_handles = {}
self.prev_gen_handles = {}
if blankdate:
empty_date = EMPTY_ENTRY
else:
empty_date = ""
if blankplace:
empty_place = EMPTY_ENTRY
else:
empty_place = ""
self.__narrator = Narrator(self._db, self.verbose, use_call,
use_fulldate, empty_date, empty_place,
nlocale=self._locale,
get_endnote_numbers=self.endnotes)
self.bibli = Bibliography(Bibliography.MODE_DATE|Bibliography.MODE_PAGE)
def apply_filter(self, person_handle, index):
""" recurse up through the generations """
if (not person_handle) or (index >= 2**self.max_generations):
return
self.map[index] = person_handle
person = self._db.get_person_from_handle(person_handle)
family_handle = person.get_main_parents_family_handle()
if family_handle:
family = self._db.get_family_from_handle(family_handle)
self.apply_filter(family.get_father_handle(), index*2)
self.apply_filter(family.get_mother_handle(), (index*2)+1)
def write_report(self):
self.apply_filter(self.center_person.get_handle(), 1)
name = self._nd.display_name(self.center_person.get_primary_name())
if not name:
name = self._("Unknown")
self.doc.start_paragraph("DAR-Title")
# feature request 2356: avoid genitive form
title = self._("Ancestral Report for %s") % name
mark = IndexMark(title, INDEX_TYPE_TOC, 1)
self.doc.write_text(title, mark)
self.doc.end_paragraph()