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


Python bibformat_engine.BibFormatObject类代码示例

本文整理汇总了Python中invenio.bibformat_engine.BibFormatObject的典型用法代码示例。如果您正苦于以下问题:Python BibFormatObject类的具体用法?Python BibFormatObject怎么用?Python BibFormatObject使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: format

def format(bfo):
    """
    List the 'featured' records
    """
    args = parse_url_string(bfo.user_info['uri'])
    journal_name = args["journal_name"]
    featured_records = get_featured_records(journal_name)
    lines = []
    for (recid, img_url) in featured_records:
        featured_record = BibFormatObject(recid)
        if bfo.lang == 'fr':
            title = featured_record.field('246_1a')
            if title == '':
                # No French translation, get it in English
                title = featured_record.field('245__a')
        else:
            title = featured_record.field('245__a')

        lines.append('''
        <a href="%s/record/%s?ln=%s" style="display:block">
            <img src="%s" alt="" width="100" class="phr" />
            %s
        </a>
        ''' % (CFG_SITE_URL, recid, bfo.lang, img_url, title))

    return  '<br/><br/>'.join(lines)
开发者ID:flannery,项目名称:invenio-flannery,代码行数:26,代码来源:bfe_webjournal_widget_featureRecord.py

示例2: format_element

def format_element(bfo):
    """
    Formats comments header using the post's name and
    the date in which the comment was added
    """

    this_recid = bfo.control_field('001')

    post_recid = get_parent_post(this_recid)
    post_rec = BibFormatObject(post_recid)
    try:
        post_title = post_rec.fields('245__a')[0]
    except:
        post_title = 'Untitled'

    try:
        addition_date = bfo.fields('269__c')[0]
    except:
        addition_date = ""

    out = '<div id="top"><div id="topbanner">&nbsp;</div>'
    out += '<div id="mainmenu"><table width="100%">'
    out += '<tr><td class="left" style = "font-size: 1em;">Go to post: <a href="%s/record/%s?%s">%s</a>' % \
                (CFG_SITE_URL, post_recid, bfo.lang, post_title)

    out += '<td class="right">%s</td>' % addition_date
    out += '</td></tr></table></div></div>'
    out += '<div id="mainphoto"></div>'

    return out
开发者ID:vbanos,项目名称:blogforever,代码行数:30,代码来源:bfe_comment_header.py

示例3: get_bfx_record

def get_bfx_record(recID):
    '''
    Get a record with a specific recID.
    @param recID: the ID of the record
    @return: a record in the structure defined here
    '''
    bfo = BibFormatObject(recID)
    return convert_record(bfo.get_record())
开发者ID:pombredanne,项目名称:invenio,代码行数:8,代码来源:bibformat_bfx_engine.py

示例4: _get_report_numbers

def _get_report_numbers(record_id):
        from invenio.bibformat_engine import BibFormatObject
        bfo = BibFormatObject(record_id)
        fields = bfo.fields('037__')
        report_numbers = []
        for field in fields:
            if 'a' in field:
                report_numbers.append(field['a'])
        return report_numbers
开发者ID:fschwenn,项目名称:inspire,代码行数:9,代码来源:reference_update.py

示例5: isAuthority

    def isAuthority(self, recid):
        record = BibFormatObject(recid)
        values = []
        for value in record.fields_ordered("980"):
            values.extend(value)

        leader = record.control_field("000")

        if "AUTHORITY" in values or (len(leader) > 7 and leader[6] == "z"):
            return True
        else:
            return False
开发者ID:aw-bib,项目名称:tind-invenio,代码行数:12,代码来源:BibIndexDefaultAuthorityTokenizer.py

示例6: format_element

def format_element(bfo):
    """
    Creates a navigation for comments.
    """

    # get variables
    this_recid = bfo.control_field('001')
    try:
        this_content = bfo.fields('520__a')[0]
    except:
        return ""
    try:
        this_author = bfo.fields('100__a')[0]
    except:
        return ""

    this_limit_content = get_contextual_content(this_content,
                                                [],
                                                max_lines=2)[0]
    menu_recids = []
    current_language = bfo.lang

    post_recid = get_parent_post(this_recid)

    menu_recids = get_comments(post_recid, newest_first=True)

    try:
        menu_out = '<h4>%s</h4>' % cfg_messages["in_issue"][current_language]
    except:
        menu_out = '<h4>%s</h4>' % cfg_messages["in_issue"]['en']

    for recid in menu_recids:
        if str(this_recid) == str(recid):
            menu_out += '<div class="active"><div class="litem"><b>%s</b>: %s [...]</div></div>' % (this_author, this_limit_content)
        else:
            temp_rec = BibFormatObject(recid)
            content = temp_rec.fields('520__a')[0]
            limit_content = get_contextual_content(content,
                                                   [],
                                                   max_lines=1)[0]

            try:
                author = temp_rec.fields('100__a')[0]
            except:
                author = 'Anonymous'
            menu_out += '<div class="litem"><a href="%s/record/%s%s"><b>%s</b>: %s [...]</a></div>' % (CFG_SITE_URL,
                                                                                                recid,
                                                                                                (bfo.lang=="fr") and "?ln=fr" or "?ln=en",
                                                                                                author, limit_content)
            

        
    return menu_out
开发者ID:vbanos,项目名称:blogforever,代码行数:53,代码来源:bfe_comment_navigation.py

示例7: schemaorg_type

    def schemaorg_type(recid=None, bfo=None):
        if recid:
            from invenio.bibformat_engine import BibFormatObject
            bfo = BibFormatObject(recid)

        if bfo:
            from invenio.openaire_deposit_config import CFG_OPENAIRE_SCHEMAORG_MAP
            collections = bfo.fields('980__')
            for c in collections:
                a = c.get('a', None)
                b = c.get('b', None)
                res = CFG_OPENAIRE_SCHEMAORG_MAP.get(b if b else a, None)
                if res:
                    return res
        return 'http://schema.org/CreativeWork'
开发者ID:gszpura,项目名称:zenodo,代码行数:15,代码来源:webinterface_handler_local.py

示例8: testLinks

 def testLinks(self):
     """testing INSPIRE Links"""
     from bfe_INSPIRE_links import format_element
     self.bfo=BibFormatObject('1')
     string = format_element(self.bfo, separator='</li>\n<li>', prefix="<ul><li>",suffix="</li></ul>")
     self.assert_(re.search(r'1012.0299">Abstract<',string))
     self.assert_(re.search(r'arXiv:1012.0299">PDF</a> from arXiv.org',string))
开发者ID:BeshoyAtef,项目名称:inspire,代码行数:7,代码来源:bfe_INSPIRE_tests.py

示例9: testAff

        def testAff(self):
            """testing Affs"""
            from bfe_CERN_authors import format_element
            self.bfo=BibFormatObject('7374')
            string =  format_element(self.bfo,limit="5",print_affiliations="yes")

            self.assert_(re.search(r'Farhi, E.</a>',string))
            self.assert_(re.search(r'</a> \(<a.*MIT',string))
开发者ID:traviscb,项目名称:inspire,代码行数:8,代码来源:bfe_INSPIRE_tests.py

示例10: testDate

 def testDate(self):
     """testing date"""
     from bfe_INSPIRE_date import format_element
     self.bfo=BibFormatObject('6194')
     string=format_element(self.bfo)
     print string
     string2=format_element(self.bfo,us="no")
     print string2
开发者ID:traviscb,项目名称:inspire,代码行数:8,代码来源:bfe_INSPIRE_tests.py

示例11: testLinks

 def testLinks(self):
     """testing Links"""
     from bfe_INSPIRE_links import format_element
     self.bfo=BibFormatObject('37650')
     string= format_element(self.bfo, separator='</li>\n<li>', prefix="<ul><li>",suffix="</li></ul>")
     print string
     self.assert_(re.search(r'065201">Journal',string))
     self.assert_(re.search(r'\?bibcode=2004',string))
开发者ID:traviscb,项目名称:inspire,代码行数:8,代码来源:bfe_INSPIRE_tests.py

示例12: testarXiv

 def testarXiv(self):
     """INSPIRE arXiv format"""
     from bfe_INSPIRE_arxiv import format_element
     self.bfo = BibFormatObject('1')
     string = format_element(self.bfo)
     self.assert_(re.search(r'0299',string))
     self.assert_(not re.search(r'CERN',string))
     self.assert_(re.search(r'hep-th',string))
开发者ID:BeshoyAtef,项目名称:inspire,代码行数:8,代码来源:bfe_INSPIRE_tests.py

示例13: testarX

 def testarX(self):
     """testing arXiv"""
     from bfe_INSPIRE_arxiv import format_element
     self.bfo=BibFormatObject('37650')
     string=format_element(self.bfo)
     print string
     self.assert_(re.search(r'3066',string))
     self.assert_(not re.search(r'CERN',string))
     self.assert_(re.search(r'hep-ph',string))
开发者ID:traviscb,项目名称:inspire,代码行数:9,代码来源:bfe_INSPIRE_tests.py

示例14: format_element

def format_element(bfo):
    """
    Prints the list of papers containing the dataset by title.
    """
    
    from invenio.bibformat_engine import BibFormatObject
    from invenio.config import CFG_BASE_URL, CFG_SITE_RECORD

    parent_recid = bfo.field("786__w")
    bfo_parent = BibFormatObject(parent_recid)
    
    title = bfo_parent.field("245__a")
    url = CFG_BASE_URL + '/' + CFG_SITE_RECORD + '/' + str(bfo_parent.recID) 

    out = "This dataset complements the following publication: <br />"
    out += "<a href=\"" + url + "\">" + title + "</a>" 
    
    return out
开发者ID:BessemAamira,项目名称:invenio,代码行数:18,代码来源:bfe_dataset_appears.py

示例15: format_element

def format_element(bfo):
    """
    Creates a navigation for articles in the same issue and category.
    """
    # get variables
    this_recid = bfo.control_field('001')
    menu_recids = []
    current_language = bfo.lang
    this_title = ""
    try:
        this_title = bfo.fields('245__a')[0]
    except:
        return ""

    blog_recid = get_parent_blog(this_recid)
    blog_rec = BibFormatObject(blog_recid)
    try:
        blog_title = blog_rec.fields('245__a')[0]
    except:
        blog_title = 'Untitled'

    menu_recids = get_posts(blog_recid, newest_first=True)

    try:
        menu_out = '<h4>%s</h4>' % cfg_messages["in_issue"][current_language]
    except: # in english by default
        menu_out = '<h4>%s</h4>' % cfg_messages["in_issue"]['en']

    for recid in menu_recids:
        if str(this_recid) == str(recid):
            menu_out += '<div class="active"><div class="litem">%s</div></div>' % this_title
        else:
            temp_rec = BibFormatObject(recid)
            try:
                title = temp_rec.fields('245__a')[0]
            except:
                title = 'Untitled'
            menu_out += '<div class="litem"><a href="%s/record/%s%s">%s</a></div>' % (CFG_SITE_URL,
                                                                                      recid,
                                                                                      (bfo.lang=="fr") and "?ln=fr" or "",
                                                                                      title)

    return menu_out
开发者ID:vbanos,项目名称:blogforever,代码行数:43,代码来源:bfe_blog_navigation.py


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