コード例 #1
0
ファイル: server.py プロジェクト: yousefmoazzam/hebi
def get_framework_citations():
    """
    Return all citations of the Savu framework

    .. :quickref: Citation; Get Savu framework citations
    :>jsonarr string bibtex: citation in bibtex format
    :>jsonarr string endnote: citation in endnote format
    :>jsonarr string citation: title of paper that the citation belongs to
    :>jsonarr string description: brief description of the paper that the citation belongs to
    :>jsonarr string doi: DOI of the paper that the citation belongs to
    """
    # get the latest Savu DOI
    # this url always redirects to the latest Savu DOI
    url = 'https://doi.org/10.5281/zenodo.592215'
    r = requests.get(url)
    # get the specific DOI suffix that the url redirected to
    doi_suffix = r.url.split('/')[-1]
    ZENODO_PREFIX = '10.5281/zenodo.'
    savu_doi = ZENODO_PREFIX + doi_suffix

    framework_citations = fc.get_framework_citations()
    framework_citation_dicts = \
        [citation_information_to_dict(cite.short_name_article, cite) for cite
         in framework_citations.values()]

    for citation in framework_citation_dicts:
        if citation['citation'] == 'Savu':
            citation['doi'] = savu_doi

    return jsonify(framework_citation_dicts)
コード例 #2
0
ファイル: plugin_list.py プロジェクト: liushuili/Savu
    def _save_framework_citations(self, group):
        framework_cites = fc.get_framework_citations()
        for cite in framework_cites:
            citation_group = group.require_group(cite['name'].encode("ascii"))
            citation = CitationInformation()
            citation.name = cite["name"]
            citation.description = cite["description"]
            citation.bibtex = cite["bibtex"]
            citation.endnote = cite["endnote"]

            citation.write(citation_group)
コード例 #3
0
ファイル: plugin_list.py プロジェクト: DimitriosBellos/Savu
 def _save_framework_citations(self, group):
     framework_cites = fc.get_framework_citations()
     count = 0
     for cite in framework_cites:
         citation_group = group.create_group(cite['name'])
         citation = CitationInformation()
         del cite['name']
         for key, value in cite.iteritems():
             exec('citation.' + key + '= value')
         citation.write(citation_group)
         count += 1
コード例 #4
0
 def _save_framework_citations(self, group):
     framework_cites = fc.get_framework_citations()
     count = 0
     for cite in framework_cites:
         citation_group = group.create_group(cite['name'])
         citation = CitationInformation()
         del cite['name']
         for key, value in cite.iteritems():
             exec('citation.' + key + '= value')
         citation.write(citation_group)
         count += 1
コード例 #5
0
ファイル: server.py プロジェクト: DiamondLightSource/hebi
def get_framework_citations():
    # get the latest Savu DOI
    # this url always redirects to the latest Savu DOI
    url = 'https://doi.org/10.5281/zenodo.592215'
    r = requests.get(url)
    # get the specific DOI suffix that the url redirected to
    doi_suffix = r.url.split('/')[-1]
    ZENODO_PREFIX = '10.5281/zenodo.'
    savu_doi = ZENODO_PREFIX + doi_suffix

    framework_citations = fc.get_framework_citations()
    for citation in framework_citations:
        if citation['short_name_article'] == 'Savu':
            citation['doi'] = savu_doi

    return jsonify(framework_citations)
コード例 #6
0
ファイル: server.py プロジェクト: DiamondLightSource/hebi
def download_framework_citations():
    citation_type = request.args.get(const.KEY_QUERY)
    contents = ''
    framework_citations = fc.get_framework_citations()

    for citation in framework_citations:
        if citation_type == 'bibtex':
            contents += citation['bibtex'].rstrip('\n') + '\n\n'
        elif citation_type == 'endnote':
            contents += citation['endnote'].rstrip('\n') + '\n\n'

    if citation_type == 'bibtex':
        filename = 'framework_citations.bibtex'
    elif citation_type == 'endnote':
        filename = 'framework_citations.endnote'

    f = BytesIO(contents.encode('utf-8'))

    return send_file(f, mimetype='text', as_attachment=True,
        attachment_filename=filename)