Skip to content

Commit

Permalink
Refactor json_gen.py to remove DOI handling
Browse files Browse the repository at this point in the history
  • Loading branch information
iishiishii committed Feb 21, 2025
1 parent a788817 commit f41bbac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/upload_containers_simg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ mv log.txt cvmfs

cd cvmfs
echo "[Debug] generate applist.json file for website"
python json_gen.py --application=$IMAGENAME_BUILDDATE --doi_url=$DOI_URL #this generates the applist.json for the website
python json_gen.py #this generates the applist.json for the website
# these files will be committed via uses: stefanzweifel/git-auto-commit-action@v4


Expand Down
20 changes: 3 additions & 17 deletions cvmfs/json_gen.py
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()

0 comments on commit f41bbac

Please sign in to comment.