doi2cff/cli.py
def init(doi, cff_fn):
    """Generate CITATION.cff file based on a Zenodo DOI of a Github release.

    * DOI, The Digital Object Identifier (DOI) name of a Zenodo upload of a GitHub release
    """
    template = '''# YAML 1.2
# Metadata for citation of this software according to the CFF format (https://citation-file-format.github.io/)
cff-version: 1.0.3
message: If you use this software, please cite it using these metadata.
# FIXME title as repository name might not be the best name, please make human readable
title: x
doi: 10.5281/zenodo.xxxxxx
# FIXME splitting of full names is error prone, please check if given/family name are correct
authors: []
version: x
date-released: yyyy-mm-dd
repository-code: x
license: x
    '''

    if not doi_is_from_zenodo(doi):
        raise click.UsageError('Unable to process DOI name, only accept DOI name which is a Zenodo upload')

    zenodo_record = fetch_zenodo_by_doiurl(doi)

    if not is_software_zenodo(zenodo_record):
        raise click.UsageError('Unable to process DOI name, only accept DOI name which is a Zenodo upload of type software')

    yaml = ruamel.yaml.YAML()
    data = yaml.load(template)
    data['title'] = zenodo_record['metadata']['title']
    data['doi'] = zenodo_record['doi']
    tagurl = tagurl_of_zenodo(zenodo_record)
    if 'version' in zenodo_record['metadata']:
        data['version'] = re.sub('^(v)', '', zenodo_record['metadata']['version'])
    else:
        data['version'] = tagurl2version(tagurl)
    data['license'] = zenodo_record['metadata']['license']['id']
    data['date-released'] = datetime.strptime(zenodo_record['metadata']['publication_date'], "%Y-%m-%d").date()
    data['repository-code'] = tagurl2repo(tagurl)
    data['authors'] = authors_of_zenodo(zenodo_record)
    references = references_of_zenodo(zenodo_record)
    fixme = 'FIXME generic is too generic, ' \
            'see https://citation-file-format.github.io/1.0.3/specifications/#/reference-types for more specific types'
    if references:
        data['references'] = yaml.seq(references)
        for idx, r in enumerate(references):
            if r['type'] == 'generic':
                data['references'].yaml_add_eol_comment(fixme, idx)

    yaml.dump(data, cff_fn)

    click.echo('{0} file has been written'.format(cff_fn.name))
Generate CITATION.cff file based on a Zenodo DOI of a Github release.

    * DOI, The Digital Object Identifier (DOI) name of a Zenodo upload of a GitHub release
    
Generate CITATION.cff file based on a Zenodo DOI of a Github release.
DOI, The Digital Object Identifier (DOI) name of a Zenodo upload of a GitHub release
Generate CITATION . cff file based on a Zenodo DOI of a Github release . DOI The Digital Object Identifier ( DOI ) name of a Zenodo upload of a GitHub release
def init(doi, cff_fn):
    template = '''# YAML 1.2
# Metadata for citation of this software according to the CFF format (https://citation-file-format.github.io/)
cff-version: 1.0.3
message: If you use this software, please cite it using these metadata.
# FIXME title as repository name might not be the best name, please make human readable
title: x
doi: 10.5281/zenodo.xxxxxx
# FIXME splitting of full names is error prone, please check if given/family name are correct
authors: []
version: x
date-released: yyyy-mm-dd
repository-code: x
license: x
    '''
    if not doi_is_from_zenodo(doi):
        raise click.UsageError('Unable to process DOI name, only accept DOI name which is a Zenodo upload')
    zenodo_record = fetch_zenodo_by_doiurl(doi)
    if not is_software_zenodo(zenodo_record):
        raise click.UsageError('Unable to process DOI name, only accept DOI name which is a Zenodo upload of type software')
    yaml = ruamel.yaml.YAML()
    data = yaml.load(template)
    data['title'] = zenodo_record['metadata']['title']
    data['doi'] = zenodo_record['doi']
    tagurl = tagurl_of_zenodo(zenodo_record)
    if 'version' in zenodo_record['metadata']:
        data['version'] = re.sub('^(v)', '', zenodo_record['metadata']['version'])
    else:
        data['version'] = tagurl2version(tagurl)
    data['license'] = zenodo_record['metadata']['license']['id']
    data['date-released'] = datetime.strptime(zenodo_record['metadata']['publication_date'], "%Y-%m-%d").date()
    data['repository-code'] = tagurl2repo(tagurl)
    data['authors'] = authors_of_zenodo(zenodo_record)
    references = references_of_zenodo(zenodo_record)
    fixme = 'FIXME generic is too generic, ' \
            'see https://citation-file-format.github.io/1.0.3/specifications/#/reference-types for more specific types'
    if references:
        data['references'] = yaml.seq(references)
        for idx, r in enumerate(references):
            if r['type'] == 'generic':
                data['references'].yaml_add_eol_comment(fixme, idx)
    yaml.dump(data, cff_fn)
    click.echo('{0} file has been written'.format(cff_fn.name))
def init ( doi , cff_fn ) : template = '''# YAML 1.2
# Metadata for citation of this software according to the CFF format (https://citation-file-format.github.io/)
cff-version: 1.0.3
message: If you use this software, please cite it using these metadata.
# FIXME title as repository name might not be the best name, please make human readable
title: x
doi: 10.5281/zenodo.xxxxxx
# FIXME splitting of full names is error prone, please check if given/family name are correct
authors: []
version: x
date-released: yyyy-mm-dd
repository-code: x
license: x
    ''' if not doi_is_from_zenodo ( doi ) : raise click . UsageError ( 'Unable to process DOI name, only accept DOI name which is a Zenodo upload' ) zenodo_record = fetch_zenodo_by_doiurl ( doi ) if not is_software_zenodo ( zenodo_record ) : raise click . UsageError ( 'Unable to process DOI name, only accept DOI name which is a Zenodo upload of type software' ) yaml = ruamel . yaml . YAML ( ) data = yaml . load ( template ) data [ 'title' ] = zenodo_record [ 'metadata' ] [ 'title' ] data [ 'doi' ] = zenodo_record [ 'doi' ] tagurl = tagurl_of_zenodo ( zenodo_record ) if 'version' in zenodo_record [ 'metadata' ] : data [ 'version' ] = re . sub ( '^(v)' , '' , zenodo_record [ 'metadata' ] [ 'version' ] ) else : data [ 'version' ] = tagurl2version ( tagurl ) data [ 'license' ] = zenodo_record [ 'metadata' ] [ 'license' ] [ 'id' ] data [ 'date-released' ] = datetime . strptime ( zenodo_record [ 'metadata' ] [ 'publication_date' ] , "%Y-%m-%d" ) . date ( ) data [ 'repository-code' ] = tagurl2repo ( tagurl ) data [ 'authors' ] = authors_of_zenodo ( zenodo_record ) references = references_of_zenodo ( zenodo_record ) fixme = 'FIXME generic is too generic, ' 'see https://citation-file-format.github.io/1.0.3/specifications/#/reference-types for more specific types' if references : data [ 'references' ] = yaml . seq ( references ) for idx , r in enumerate ( references ) : if r [ 'type' ] == 'generic' : data [ 'references' ] . yaml_add_eol_comment ( fixme , idx ) yaml . dump ( data , cff_fn ) click . echo ( '{0} file has been written' . format ( cff_fn . name ) )
Generate CITATION.cff file based on a Zenodo DOI of a Github release.
Generate CITATION . cff file based on a Zenodo DOI of a Github release .
"""Generate CITATION.cff file based on a Zenodo DOI of a Github release.

    * DOI, The Digital Object Identifier (DOI) name of a Zenodo upload of a GitHub release
    """
doi
cff_fn