-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor json_gen.py to remove DOI handling
- Loading branch information
1 parent
a788817
commit f41bbac
Showing
2 changed files
with
4 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,17 @@ | ||
import json | ||
import argparse | ||
|
||
def process_text_to_json(application, doi_url): | ||
def process_text_to_json(): | ||
my_dict = {} | ||
val = [] | ||
|
||
with open("log.txt") as f: | ||
for line in f: | ||
line = line.split() | ||
|
||
# Find the matching application and update its DOI | ||
if application in line[0]: | ||
val.append({"application": line[0], "categories": ' '.join(line[1:]).replace("categories:","").rstrip(',').split(","), "doi": doi_url}) | ||
else: | ||
val.append({"application": line[0], "categories": ' '.join(line[1:]).replace("categories:","").rstrip(',').split(",")}) | ||
val.append({"application": line[0], "categories": ' '.join(line[1:]).replace("categories:","").rstrip(',').split(",")}) | ||
my_dict['list'] = val | ||
|
||
with open('applist.json', 'w') as fp: | ||
json.dump(my_dict, fp, sort_keys=True, indent=4) | ||
|
||
if __name__ == '__main__': | ||
parser = argparse.ArgumentParser( | ||
prog="Update DOI for app list", | ||
) | ||
parser.add_argument("--application", type=str, required=True, help="Application name and version") | ||
parser.add_argument("--doi_url", type=str, required=True, help="DOI URL") | ||
|
||
args = parser.parse_args() | ||
|
||
process_text_to_json(args.application, args.doi_url) | ||
process_text_to_json() |