diff --git a/codemeta.json b/codemeta.json index bc9bdc885a7935946fa87d45e5d3313726b0bb64..385c35c8b4035dcef8fa3889039759d68824763b 100644 --- a/codemeta.json +++ b/codemeta.json @@ -1,115 +1,117 @@ - { - "@context": "https://doi.org/10.5063/schema/codemeta-2.0", - "@type": "SoftwareSourceCode", - "name": "eossr", - "description": "ESCAPE OSSR library", - "license": "https://spdx.org/licenses/MIT", - "softwareVersion": "v0.3.3", - "codeRepository": "https://gitlab.in2p3.fr/escape2020/wp3/eossr", - "developmentStatus": "active", - "isAccessibleForFree": true, - "isPartOf": [ - "https://gitlab.in2p3.fr/escape2020", - "https://projectescape.eu/" - ], - "contIntegration": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/pipelines", - "buildInstructions": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/blob/master/README.md", - "issueTracker": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/issues", - "readme": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/blob/master/README.md", - "programmingLanguage": [ - { - "@type": "ComputerLanguage", - "name": "Python", - "url": "https://www.python.org/" - } - ], - "softwareRequirements": [ - { - "@type": "SoftwareApplication", - "identifier": "requests", - "name": "requests", - "softwareVersion": ">=3.6" +{ + "@context": "https://doi.org/10.5063/schema/codemeta-2.0", + "@type": "SoftwareSourceCode", + "name": "eossr", + "description": "<p><img alt=\"eOSSR\" src=\"docs/images/eossr_logo.png\" /></p><h2>The ESCAPE OSSR library</h2><p>The eOSSR Python library gathers all the developments made for the OSSR. In particular, it includes:- an API to programmatically access the OSSR, retrieve records and publish content- functions to map and crosswalk metadata between the CodeMeta schema adopted for the OSSR and Zenodo internal schema- functions to help developers automatically contribute to the OSSR, in particular using their continuous integration (see also code snippets)</p><p>Code: <a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr\">https://gitlab.in2p3.fr/escape2020/wp3/eossr</a> <br />Documentation: <a href=\"https://escape2020.pages.in2p3.fr/wp3/eossr/\">https://escape2020.pages.in2p3.fr/wp3/eossr/</a></p><p><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/commits/master\"><img alt=\"pipeline status\" src=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/badges/master/pipeline.svg\" /></a><a href=\"https://opensource.org/licenses/MIT\"><img alt=\"License: MIT\" src=\"https://img.shields.io/badge/License-MIT-blue.svg\" /></a><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/commits/master\"><img alt=\"coverage report\" src=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/badges/master/coverage.svg\" /></a><a href=\"https://doi.org/10.5281/zenodo.5524912\"><img alt=\"DOI\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5524912.svg\" /></a><a href=\"https://mybinder.org/v2/git/https%3A%2F%2Fgitlab.in2p3.fr%2Fescape2020%2Fwp3%2Feossr/HEAD\"><img alt=\"Binder\" src=\"https://mybinder.org/badge_logo.svg\" /></a></p><h2>Stable versions</h2><ul><li>v0.3.3: <a href=\"https://doi.org/10.5281/zenodo.5592584\"><img alt=\"DOI\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5592584.svg\" /></a></li><li>v0.2 : <a href=\"https://doi.org/10.5281/zenodo.5524913\"><img alt=\"DOI\" src=\"https://zenodo.org/badge/DOI/10.5281/zenodo.5524913.svg\" /></a></li></ul><h2>Install</h2><p>Commands to be run in your terminal.</p><h3>For users</h3><pre><code>pip install eossr</code></pre><p>You can also run it with docker:</p><pre><code>docker run -it gitlab-registry.in2p3.fr/escape2020/wp3/eossr:latest</code></pre><p><a href=\"https://gitlab.in2p3.fr/escape2020/wp3/eossr/container_registry\">Visit our registry</a> to see the available docker containers.</p><p>Note that <code>latest</code> tag always point to the latest stable released container.</p><h3>For developers</h3><pre><code>git clone https://gitlab.in2p3.fr/escape2020/wp3/eossr.gitpip install -e eossr</code></pre><h4>Running tests</h4><p>To run tests locally, run:</p><pre><code>pip install pytestpytest eossr</code></pre><p>Some tests will be skiped if <code>SANDBOX_ZENODO_TOKEN</code> is not defined in your environment variables.If you want to run these tests, you will need to create a <a href=\"https://sandbox.zenodo.org/account/settings/applications/tokens/new/\">sandbox zenodo token</a> and add it to your env:</p><pre><code>export SANDBOX_ZENODO_TOKEN="your_sandbox_token"</code></pre><h2>Cite</h2><p>To cite this library, use the cite module in <a href=\"https://zenodo.org/record/5524913#.YWBq79kzZB0\">the Zenodo page</a>.</p>", + "license": "https://spdx.org/licenses/MIT", + "softwareVersion": "v0.3.3", + "codeRepository": "https://gitlab.in2p3.fr/escape2020/wp3/eossr", + "developmentStatus": "active", + "isAccessibleForFree": true, + "isPartOf": [ + "https://gitlab.in2p3.fr/escape2020", + "https://projectescape.eu/" + ], + "contIntegration": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/pipelines", + "buildInstructions": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/blob/master/README.md", + "issueTracker": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/issues", + "readme": "https://gitlab.in2p3.fr/escape2020/wp3/eossr/-/blob/master/README.md", + "programmingLanguage": [ + { + "@type": "ComputerLanguage", + "name": "Python", + "url": "https://www.python.org/" + } + ], + "softwareRequirements": [ + { + "@type": "SoftwareApplication", + "identifier": "requests", + "name": "requests", + "softwareVersion": ">=3.6" + }, + { + "@type": "SoftwareApplication", + "identifier": "pytest", + "name": "pytest", + "softwareVersion": ">=5.4.2" + } + ], + "keywords": [ + "jupyter-notebook" + ], + "runtimePlatform": "", + "downloadUrl": "", + "installUrl": "", + "releaseNotes": "Bug fix in the CI and much lighter docker container", + "dateCreated": "2021-08-31", + "datePublished": "2021-12-02", + "dateModified": "2021-12-02", + "operatingSystem": "", + "maintainer": { + "@type": "Person", + "@id": "https://orcid.org/0000-0003-2224-4594", + "givenName": "Enrique", + "familyName": "Garcia", + "email": "garcia@lapp.in2p3.fr", + "affiliation": { + "@type": "Organization", + "name": "Univ. Savoie Mont Blanc, CNRS, LAPP" + } }, - { - "@type": "SoftwareApplication", - "identifier": "pytest", - "name": "pytest", - "softwareVersion": ">=5.4.2" - } - ], - "keywords": ["jupyter-notebook"], - "runtimePlatform": "", - "downloadUrl": "", - "installUrl": "", - "releaseNotes": "Bug fix in the CI and much lighter docker container", - "dateCreated": "2021-08-31", - "datePublished": "2021-10-22", - "dateModified": "2021-10-22", - "operatingSystem": "", - "maintainer": { - "@type": "Person", - "@id": "https://orcid.org/0000-0003-2224-4594", - "givenName": "Enrique", - "familyName": "Garcia", - "email": "garcia@lapp.in2p3.fr", - "affiliation": { - "@type": "Organization", - "name": "Univ. Savoie Mont Blanc, CNRS, LAPP" - } - }, - "author": [ - { - "@type": "Person", - "@id": "https://orcid.org/0000-0002-5686-2078", - "givenName": "Thomas", - "familyName": "Vuillaume", - "email": "vuillaume@lapp.in2p3.fr", - "affiliation": { - "@type": "Organization", - "name": "Univ. Savoie Mont Blanc, CNRS, LAPP" - } - }, - { - "@type": "Person", - "@id": "https://orcid.org/0000-0003-2224-4594", - "givenName": "Enrique", - "familyName": "Garcia", - "email": "garcia@lapp.in2p3.fr", - "affiliation": { - "@type": "Organization", - "name": "Univ. Savoie Mont Blanc, CNRS, LAPP" - } - } - ], - "contributor": [ - { - "@type": "Person", - "@id": "https://orcid.org/0000-0002-5321-8404", - "givenName": "Christian", - "familyName": "Tacke", - "affiliation": { - "@type": "Organization", - "name": "GSI" - } - }, - { - "@type": "Person", - "@id": "https://orcid.org/0000-0001-7821-8673", - "givenName": "Tamás", - "familyName": "Gál", - "email": "tamas.gal@fau.de", - "affiliation": { - "@type": "Organization", - "name": "ECAP, FAU (Nuremberg, Germany)" - } - } - ], - "funder":[ - { - "@type": "Organization", - "name": "European Commission", - "@id": "https://doi.org/10.13039/501100000780" - } - ], - "funding": "824064" -} + "author": [ + { + "@type": "Person", + "@id": "https://orcid.org/0000-0002-5686-2078", + "givenName": "Thomas", + "familyName": "Vuillaume", + "email": "vuillaume@lapp.in2p3.fr", + "affiliation": { + "@type": "Organization", + "name": "Univ. Savoie Mont Blanc, CNRS, LAPP" + } + }, + { + "@type": "Person", + "@id": "https://orcid.org/0000-0003-2224-4594", + "givenName": "Enrique", + "familyName": "Garcia", + "email": "garcia@lapp.in2p3.fr", + "affiliation": { + "@type": "Organization", + "name": "Univ. Savoie Mont Blanc, CNRS, LAPP" + } + } + ], + "contributor": [ + { + "@type": "Person", + "@id": "https://orcid.org/0000-0002-5321-8404", + "givenName": "Christian", + "familyName": "Tacke", + "affiliation": { + "@type": "Organization", + "name": "GSI" + } + }, + { + "@type": "Person", + "@id": "https://orcid.org/0000-0001-7821-8673", + "givenName": "Tam\u00e1s", + "familyName": "G\u00e1l", + "email": "tamas.gal@fau.de", + "affiliation": { + "@type": "Organization", + "name": "ECAP, FAU (Nuremberg, Germany)" + } + } + ], + "funder": [ + { + "@type": "Organization", + "name": "European Commission", + "@id": "https://doi.org/10.13039/501100000780" + } + ], + "funding": "824064" +} \ No newline at end of file diff --git a/eossr/scripts/update_codemeta.py b/eossr/scripts/update_codemeta.py new file mode 100644 index 0000000000000000000000000000000000000000..8ca2162a52faf7d43dc6000629626b123f32dc6d --- /dev/null +++ b/eossr/scripts/update_codemeta.py @@ -0,0 +1,21 @@ +import argparse +from pathlib import Path +from eossr.utils import update_codemeta +from eossr import ROOT_DIR + + + + +if __name__ == '__main__': + + parser = argparse.ArgumentParser(description="Update Codemeta") + + parser.add_argument('--codemeta_path', '-c', type=str, + dest='codemeta_path', + help='Path to codemeta.json', + default=Path(ROOT_DIR).joinpath('codemeta.json'), + required=False) + + args = parser.parse_args() + html = update_codemeta(codemeta_path=args.codemeta_path) + diff --git a/eossr/tests/test_utils.py b/eossr/tests/test_utils.py index c8b414c3f67a0c22bca136a5364e90f5e39c3022..927dbcdd9ccfa1847366b98f90343d66916f4a70 100644 --- a/eossr/tests/test_utils.py +++ b/eossr/tests/test_utils.py @@ -43,3 +43,13 @@ def test_zip_repository(): assert 'test_zip_repo.zip' not in [Path(f).name for f in zo.namelist()] assert os.path.join(os.path.join(os.path.basename(tmpdir), os.path.basename(subtmpdir)), os.path.basename(tmpfile)) in zo.namelist() + + +def test_readme_to_html(): + from eossr.utils import readme_to_html + readme_to_html() + + +def test_update_codemeta(): + from eossr.utils import update_codemeta + update_codemeta(overwrite=False) \ No newline at end of file diff --git a/eossr/utils.py b/eossr/utils.py index 55cf49aea3b4c8362cc4a864c2317edc02620694..de75eefb92c5513f04dfd7ae2ffbb67e3e8af92d 100644 --- a/eossr/utils.py +++ b/eossr/utils.py @@ -4,6 +4,9 @@ import shutil from io import BytesIO from zipfile import ZipFile from pathlib import Path +from markdown import markdown +from datetime import date +from . import ROOT_DIR __all__ = [ 'ZipUrl', @@ -95,3 +98,41 @@ def zip_repository(directory, zip_filename=None): print(f"Zipping done: {zip_filename}.zip") return zip_filename + '.zip' + + +def readme_to_html(readme_path=Path(ROOT_DIR).joinpath('README.md').as_posix()): + """ + Read README.md and return html transcript + :param readme_path: str + :return: str + text in readme converted to html + """ + html = markdown(open(readme_path).read(), extensions=['fenced_code']) + html = html.replace('\n', '') + return html + + +def update_codemeta(codemeta_path=Path(ROOT_DIR).joinpath('codemeta.json').as_posix(), published=True, overwrite=True): + """ + Update codemeta.json file for dates and description based on README.md + + :param codemeta_path: Path + :param published: boolean + if True, datePublished is updated. + :param overwrite: boolean + overwrite codemeta file + :return: + """ + with open(codemeta_path) as file: + metadata = json.load(file) + metadata['description'] = readme_to_html() + metadata['dateModified'] = f'{date.today()}' + + if published: + metadata['datePublished'] = f'{date.today()}' + + if overwrite: + with open(codemeta_path, 'w') as file: + json.dump(metadata, file, indent=4) + return metadata + diff --git a/setup.py b/setup.py index e9733a5cc6ecbb733c8d0ab8b6d70992a12cdcd2..7749532b7d36a1e69f0bc691f80979f609c6f5ae 100644 --- a/setup.py +++ b/setup.py @@ -33,6 +33,7 @@ setup( install_requires=[ "requests", "bs4", + "markdown" ], packages=find_packages(), scripts=['eossr/scripts/gitlab_prepare_upload_zenodo.sh'],