From 7080e59dc63f27d6e5c67aac5852ca91660903de Mon Sep 17 00:00:00 2001 From: kthoden Date: Thu, 23 Sep 2021 11:26:59 +0200 Subject: [PATCH] Use test suffix in filenames also --- build_frontmatter.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/build_frontmatter.py b/build_frontmatter.py index ae78438..34f2205 100644 --- a/build_frontmatter.py +++ b/build_frontmatter.py @@ -876,13 +876,15 @@ def get_types_dict(pub_type): testprefix = CONFIG["doi"]["testprefix"][1:-1] if use_test_repo: - batch_filename = str(out_dir) + f"/{eoa_publication}_doiupload_test.sh" + test_repo_string = "_test" doipublication = re.sub(r'(10\.[0-9]{4,})/',f'{testprefix}/', doipublication) api_url = "https://api.test.datacite.org/dois" else: - batch_filename = str(out_dir) + f"/{eoa_publication}_doiupload.sh" + test_repo_string = "" api_url = "https://api.datacite.org/dois" + batch_filename = str(out_dir) + f"/{eoa_publication}_doiupload{test_repo_string}.sh" + curl_command = 'curl --verbose --netrc --request POST --header "Content-Type: application/vnd.api+json"' chapter_files = get_chapters(eoa_pub_id, eoa_cursor, eoaclassic, include_pdfless=True) @@ -1102,7 +1104,7 @@ def get_types_dict(pub_type): json_dict = {"data" : data_dict} json_object = json.dumps(json_dict) - json_file = out_dir / f"{eoa_publication}_chap{chaptercounter:02}.json" + json_file = out_dir / f"{eoa_publication}_chap{chaptercounter:02}{test_repo_string}.json" write_json_file(json_object, json_file) command_file.write(f"{curl_command} -d @{json_file} {api_url}\n") chaptercounter += 1