sort and pretty print dataverse.json

so that we can track changes and only update the lines of the files that need updating
pull/796/head
Daniel Nüst 2019-09-18 08:54:48 +02:00
rodzic bfbec349c2
commit 3bdf7041dc
3 zmienionych plików z 643 dodań i 4 usunięć

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -10,7 +10,14 @@ from ..utils import copytree, deep_get
class Dataverse(DoiProvider):
"""Provide contents of a Dataverse dataset."""
"""
Provide contents of a Dataverse dataset.
This class loads a a list of existing Dataverse installations from the internal
file dataverse.json. This file is manually updated with the following command:
python setup.py generate_dataverse_file
"""
def __init__(self):
data_file = os.path.join(os.path.dirname(__file__), "dataverse.json")

Wyświetl plik

@ -31,8 +31,13 @@ class GenerateDataverseInstallationsFileCommand(Command):
data = json.loads(resp_body.decode("utf-8"))
if "installations" not in data:
raise ValueError("Malformed installation map.")
with open("repo2docker/contentproviders/dataverse.json", "wb") as fp:
fp.write(resp_body)
def get_identifier(json):
return int(json["id"])
data["installations"].sort(key=get_identifier)
with open("repo2docker/contentproviders/dataverse.json", "w") as fp:
json.dump(data, fp, indent=4, sort_keys=True)
__cmdclass = versioneer.get_cmdclass()