当前位置: 首页>>代码示例>>Python>>正文


Python SimpleAccess.get_link方法代码示例

本文整理汇总了Python中gramps.gen.simple.SimpleAccess.get_link方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleAccess.get_link方法的具体用法?Python SimpleAccess.get_link怎么用?Python SimpleAccess.get_link使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gramps.gen.simple.SimpleAccess的用法示例。


在下文中一共展示了SimpleAccess.get_link方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from gramps.gen.simple import SimpleAccess [as 别名]
# 或者: from gramps.gen.simple.SimpleAccess import get_link [as 别名]
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("")
开发者ID:DaAwesomeP,项目名称:gramps,代码行数:41,代码来源:linkreferences.py

示例2: write_report

# 需要导入模块: from gramps.gen.simple import SimpleAccess [as 别名]
# 或者: from gramps.gen.simple.SimpleAccess import get_link [as 别名]
    def write_report(self):
        """
        The routine that actually creates the report.
        At this point, the document is opened and ready for writing.
        """
        sdb = SimpleAccess(self.database)

        self.doc.start_paragraph("NoteLink-Title")
        title = _("Note Link Check Report")
        mark = IndexMark(title, INDEX_TYPE_TOC, 1)
        self.doc.write_text(title, mark)
        self.doc.end_paragraph()
        self.doc.start_table('NoteLinkTable','NoteLink-Table')

        self.doc.start_row()

        self.doc.start_cell('NoteLink-TableCell')
        self.doc.start_paragraph('NoteLink-Normal-Bold')
        self.doc.write_text(_("Note ID"))
        self.doc.end_paragraph()
        self.doc.end_cell()

        self.doc.start_cell('NoteLink-TableCell')
        self.doc.start_paragraph('NoteLink-Normal-Bold')
        self.doc.write_text(_("Link Type"))
        self.doc.end_paragraph()
        self.doc.end_cell()
        
        self.doc.start_cell('NoteLink-TableCell')
        self.doc.start_paragraph('NoteLink-Normal-Bold')
        self.doc.write_text(_("Links To"))
        self.doc.end_paragraph()
        self.doc.end_cell()

        self.doc.start_cell('NoteLink-TableCell')
        self.doc.start_paragraph('NoteLink-Normal-Bold')
        self.doc.write_text(_("Status"))
        self.doc.end_paragraph()
        self.doc.end_cell()

        self.doc.end_row()

        for note in self.database.iter_notes():
            for (ldomain, ltype, lprop, lvalue) in note.get_links():
                    if ldomain == "gramps":
                        tagtype = _(ltype)
                        ref_obj = sdb.get_link(ltype, lprop, lvalue)
                        if ref_obj:
                            tagvalue = sdb.describe(ref_obj)
                            tagcheck = _("Ok")
                        else:
                            tagvalue = "%s://%s/%s/%s" % (ldomain, ltype, lprop, lvalue)
                            tagcheck = _("Failed")
                    else:
                        tagtype = _("Internet")
                        tagvalue = lvalue
                        tagcheck = ""
        
                    self.doc.start_row()

                    self.doc.start_cell('NoteLink-TableCell')
                    self.doc.start_paragraph('NoteLink-Normal')
                    self.doc.write_text(note.gramps_id)
                    self.doc.end_paragraph()
                    self.doc.end_cell()

                    self.doc.start_cell('NoteLink-TableCell')
                    self.doc.start_paragraph('NoteLink-Normal')
                    self.doc.write_text(tagtype)
                    self.doc.end_paragraph()
                    self.doc.end_cell()

                    self.doc.start_cell('NoteLink-TableCell')
                    self.doc.start_paragraph('NoteLink-Normal')
                    self.doc.write_text(tagvalue)
                    self.doc.end_paragraph()
                    self.doc.end_cell()

                    self.doc.start_cell('NoteLink-TableCell')
                    self.doc.start_paragraph('NoteLink-Normal')
                    self.doc.write_text(tagcheck)
                    self.doc.end_paragraph()
                    self.doc.end_cell()

                    self.doc.end_row()

        self.doc.end_table()
开发者ID:nblock,项目名称:gramps,代码行数:89,代码来源:notelinkreport.py


注:本文中的gramps.gen.simple.SimpleAccess.get_link方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。