Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Read authors and description from .zenodo.json #1758

Merged
merged 1 commit into from Jul 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions MANIFEST.in
Expand Up @@ -2,3 +2,4 @@ exclude .*
prune .*
prune doc
prune tests
include .zenodo.json
36 changes: 23 additions & 13 deletions setup.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python
"""ESMValTool installation script."""
import json
import os
import re
import sys
Expand Down Expand Up @@ -78,16 +79,6 @@
}


def read_authors(citation_file):
"""Read the list of authors from .cff file."""
authors = re.findall(
r'family-names: (.*)$\s*given-names: (.*)',
Path(citation_file).read_text(),
re.MULTILINE,
)
return ', '.join(' '.join(author[::-1]) for author in authors)


def discover_python_files(paths, ignore):
"""Discover Python files."""
def _ignore(path):
Expand Down Expand Up @@ -162,11 +153,29 @@ def run(self):
sys.exit(errno)


def read_authors(filename):
"""Read the list of authors from .zenodo.json file."""
with Path(filename).open() as file:
info = json.load(file)
authors = []
for author in info['creators']:
name = ' '.join(author['name'].split(',')[::-1]).strip()
authors.append(name)
return ', '.join(authors)


def read_description(filename):
"""Read the description from .zenodo.json file."""
with Path(filename).open() as file:
info = json.load(file)
return info['description']


setup(
name='ESMValTool',
version=__version__,
author=read_authors('CITATION.cff'),
description='Earth System Models eValuation Tool',
author=read_authors('.zenodo.json'),
description=read_description('.zenodo.json'),
long_description=Path('README.md').read_text(),
long_description_content_type='text/markdown',
url='https://www.esmvaltool.org',
Expand All @@ -177,7 +186,8 @@ def run(self):
'Environment :: Console',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English', 'Operating System :: POSIX :: Linux',
'Natural Language :: English',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
Expand Down