本文整理汇总了Python中gramps.gen.lib.Citation.set_reference_handle方法的典型用法代码示例。如果您正苦于以下问题:Python Citation.set_reference_handle方法的具体用法?Python Citation.set_reference_handle怎么用?Python Citation.set_reference_handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gramps.gen.lib.Citation
的用法示例。
在下文中一共展示了Citation.set_reference_handle方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_event
# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import set_reference_handle [as 别名]
def create_event(self, description=_("Estimated date"),
type=None, date=None, source=None,
note_text="", modifier=None):
event = Event()
event.set_description(description)
note = Note()
note.handle = create_id()
note.type.set(NoteType.EVENT)
note.set(note_text)
self.db.add_note(note, self.trans)
event.add_note(note.handle)
if type:
event.set_type(EventType(type))
if date:
if modifier:
date.set_modifier(modifier)
date.set_quality(Date.QUAL_ESTIMATED)
date.set_yr_mon_day(date.get_year(), 0, 0)
event.set_date_object(date)
if source:
citation = Citation()
citation.set_reference_handle(source.get_handle())
self.db.add_citation(citation, self.trans)
event.add_citation(citation.get_handle())
self.db.commit_source(source, self.trans)
self.db.add_event(event, self.trans)
return event
示例2: get_or_create_source
# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import set_reference_handle [as 别名]
def get_or_create_source(self,source_name):
source = None
if source_name in self.skeys:
source = self.db.get_source_from_handle(self.skeys[source_name])
else:
source = Source()
source.set_title(source_name)
self.db.add_source(source,self.trans)
self.db.commit_source(source,self.trans)
self.skeys[source_name] = source.get_handle()
citation = Citation()
citation.set_reference_handle(source.get_handle())
self.db.add_citation(citation, self.trans)
self.db.commit_citation(citation, self.trans)
return citation
示例3: _add_source
# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import set_reference_handle [as 别名]
def _add_source(self,repos=None):
# Add a Source
with DbTxn("Add Source and Citation", self._db) as tran:
source = Source()
if repos is not None:
repo_ref = RepoRef()
repo_ref.set_reference_handle(repos.get_handle())
source.add_repo_reference(repo_ref)
self._db.add_source(source, tran)
self._db.commit_source(source, tran)
citation = Citation()
citation.set_reference_handle(source.get_handle())
self._db.add_citation(citation, tran)
self._db.commit_citation(citation, tran)
return citation
示例4: find_and_set_citation
# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import set_reference_handle [as 别名]
def find_and_set_citation(self, obj, source):
# look for the source in the existing citations for the object
LOG.debug("find_and_set_citation: looking for source: %s",
source.get_gramps_id())
for citation_handle in obj.get_citation_list():
citation = self.db.get_citation_from_handle(citation_handle)
LOG.debug("find_and_set_citation: existing citation: %s",
citation.get_gramps_id())
poss_source = self.db.get_source_from_handle(
citation.get_reference_handle())
LOG.debug(" compare source %s == %s", source.get_gramps_id(),
poss_source.get_gramps_id())
if poss_source.get_handle() == source.get_handle():
# The source is already cited
LOG.debug(" source already cited")
return
# we couldn't find an appropriate citation, so we have to create one.
citation = Citation()
LOG.debug(" creating citation")
citation.set_reference_handle(source.get_handle())
self.db.add_citation(citation, self.trans)
LOG.debug(" created citation, citation %s %s" %
(citation, citation.get_gramps_id()))
obj.add_citation(citation.get_handle())
示例5: on_res_ok_clicked
# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import set_reference_handle [as 别名]
def on_res_ok_clicked(self, dummy):
""" Accept changes displayed and commit to place.
Also find or create a new enclosing place from parent. """
# do the names
namelist = []
for row in self.alt_store:
if row[0] == 'P':
self.place.name = self.newplace.names[row[4]]
elif row[0] == '\u2714':
namelist.append(self.newplace.names[row[4]])
self.place.alt_names = namelist
# Lat/lon/ID/code/type
self.place.lat = self.top.get_object('latitude').get_text()
self.place.long = self.top.get_object('longitude').get_text()
self.place.gramps_id = self.top.get_object('grampsid').get_text()
self.place.code = self.top.get_object('postal').get_text()
self.place.place_type.set(self.type_combo.get_values())
# Add in URLs if wanted
if self.keepweb:
for url in self.newplace.links:
self.place.add_url(url)
# Enclose in the next level place
next_place = False
parent = None
if not self.keep_enclosure or not self.place.placeref_list:
if self.newplace.parent_ids:
# we might have a parent with geo id 'GEO12345'
parent = self.dbstate.db.get_place_from_gramps_id(
self.newplace.parent_ids[0])
if not parent and self.newplace.parent_names:
# make one, will have to be examined/cleaned later
parent = Place()
parent.title = ', '.join(self.newplace.parent_names)
name = PlaceName()
name.value = parent.title
parent.name = name
parent.gramps_id = self.newplace.parent_ids[0]
with DbTxn(_("Add Place (%s)") % parent.title,
self.dbstate.db) as trans:
self.dbstate.db.add_place(parent, trans)
next_place = True
if parent:
if located_in(self.dbstate.db, parent.handle,
self.place.handle):
# attempting to create a place loop, not good!
ErrorDialog(_('Place cycle detected'),
msg2=_("The place you chose is enclosed in the"
" place you are workin on!\n"
"Please cancel and choose another "
"place."),
parent=self.uistate.window)
return
# check to see if we already have the enclosing place
already_there = False
for pref in self.place.placeref_list:
if parent.handle == pref.ref:
already_there = True
break
if not already_there:
placeref = PlaceRef()
placeref.set_reference_handle(parent.handle)
self.place.set_placeref_list([placeref])
# Add in Citation/Source if wanted
if self.addcitation and self.newplace.geoid:
src_hndl = self.find_or_make_source()
cit = Citation()
cit.set_reference_handle(src_hndl)
cit.set_page("GeoNames ID: %s" %
self.newplace.geoid.replace('GEO', ''))
with DbTxn(_("Add Citation (%s)") % "GeoNames",
self.dbstate.db) as trans:
self.dbstate.db.add_citation(cit, trans)
self.place.add_citation(cit.handle)
# We're finally ready to commit the updated place
with DbTxn(_("Edit Place (%s)") % self.place.title,
self.dbstate.db) as trans:
self.dbstate.db.commit_place(self.place, trans)
# Jump to enclosing place to clean it if necessary
if next_place:
self.set_active('Place', parent.handle)
self.place = parent
# if geoparse fails, leave us at main view
if self.newplace.parent_ids and \
self.geoparse(self.newplace.parent_ids[0],
_(", ").join(self.newplace.parent_names),
self.newplace.parent_ids,
self.newplace.parent_names):
# geoparse worked, lets put up the results view
self.gui.get_child().remove(self.mainwin)
self.gui.get_child().add(self.results_win)
self.res_gui()
return
self.reset_main()
if self.gui.get_child().get_child() == self.results_win:
self.gui.get_child().remove(self.results_win)
self.gui.get_child().add(self.mainwin)
示例6: CensusEditor
# 需要导入模块: from gramps.gen.lib import Citation [as 别名]
# 或者: from gramps.gen.lib.Citation import set_reference_handle [as 别名]
#.........这里部分代码省略.........
self.gallery_list = GalleryTab(self.dbstate,
self.uistate,
self.track,
self.citation.get_media_list())
self._add_tab(notebook, self.gallery_list)
vbox.pack_start(tab, expand=False, fill=True, padding=10)
vbox.pack_start(notebook, expand=True, fill=True, padding=0)
vbox.pack_end(button_box, expand=False, fill=True, padding=10)
root.add(vbox)
root.show_all()
notebook.set_current_page(0)
return root
def __populate_gui(self, event):
"""
Populate the GUI for a given census event.
"""
census_combo = self.widgets['census_combo']
for pos, row in enumerate(census_combo.get_model()):
if row[0] == self.citation.get_reference_handle():
census_combo.set_active(pos)
date_text = self.widgets['date_text']
date_text.set_text(get_date(event))
def __census_changed(self, combo):
"""
Called when the user selects a new census from the combo box.
"""
model = combo.get_model()
index = combo.get_active()
census_id = model[index][2]
# Set date
census_date = get_census_date(census_id)
date_text = self.widgets['date_text']
date_text.set_text(displayer.display(census_date))
self.event.set_date_object(census_date)
self.citation.set_date_object(census_date)
# Set source
self.citation.set_reference_handle(model[index][0])
# Set new columns
columns = get_census_columns(census_id)
report_columns = get_report_columns(census_id)
self.details.create_table(columns, report_columns)
heading_list = get_census_headings(census_id)
self.headings.create_table(heading_list)
def save(self, button):
"""
Called when the user clicks the OK button.
"""
if self.widgets['census_combo'].get_active() == -1:
ErrorDialog(_('Census Editor'),
_('Cannot save this census. First select '
'a census from the drop-down list.'))
return
with DbTxn(self.get_menu_title(), self.db) as trans:
if not self.event.get_handle():
self.db.add_event(self.event, trans)
self.headings.save()
self.details.save(trans)
citation_handle = self.citation.get_handle()
if not citation_handle:
citation_handle = self.db.add_citation(self.citation, trans)
self.event.add_citation(citation_handle)
else:
self.db.commit_citation(self.citation, trans)
self.db.commit_event(self.event, trans)
self.close()
def close(self, *args):
"""
Close the editor window.
"""
(width, height) = self.window.get_size()
self._config.set('interface.census-width', width)
self._config.set('interface.census-height', height)
self._config.save()
self.details.entry_grid.clean_up()
self.details.clean_up()
self.gallery_list.clean_up()
ManagedWindow.close(self)
def help_clicked(self, obj):
"""
Display the relevant portion of GRAMPS manual
"""
display_help(webpage='Census_Addons')