Publish index
This commit is contained in:
parent
a0f470a5dd
commit
9966d52a8a
@ -38,21 +38,46 @@ index = SRC_DIR / "index.json"
|
|||||||
with index.open("r") as f:
|
with index.open("r") as f:
|
||||||
index = json.load(f)
|
index = json.load(f)
|
||||||
|
|
||||||
|
new_index = []
|
||||||
for handout in index:
|
for handout in index:
|
||||||
title = handout["title"]
|
title = handout["title"]
|
||||||
group = handout["group"]
|
group = handout["group"]
|
||||||
h_file = SRC_DIR/handout["handout_file"]
|
h_file = SRC_DIR/handout["handout_file"]
|
||||||
s_file = SRC_DIR/handout["handout_file"]
|
s_file = SRC_DIR/handout["handout_file"]
|
||||||
|
|
||||||
|
h_url = None
|
||||||
|
s_url = None
|
||||||
|
|
||||||
target = f"{group} - {title}.pdf"
|
target = f"{group} - {title}.pdf"
|
||||||
requests.put(
|
requests.put(
|
||||||
f"{URL}/api/packages/{USER}/generic/{PACKAGE}/{VERSION}/{target}",
|
f"{URL}/api/packages/{USER}/generic/{PACKAGE}/{VERSION}/{target}",
|
||||||
auth=AUTH, data=h_file.open('rb').read())
|
auth=AUTH,
|
||||||
|
data=h_file.open('rb').read()
|
||||||
|
)
|
||||||
|
h_url = f"{URL}/api/packages/{USER}/generic/ormc-handouts/{VERSION}/{target}"
|
||||||
|
|
||||||
|
|
||||||
if s_file is not None:
|
if s_file is not None:
|
||||||
target = f"{group} - {title}.sols.pdf"
|
target = f"{group} - {title}.sols.pdf"
|
||||||
requests.put(
|
requests.put(
|
||||||
f"{URL}/api/packages/{USER}/generic/{PACKAGE}/{VERSION}/{target}",
|
f"{URL}/api/packages/{USER}/generic/{PACKAGE}/{VERSION}/{target}",
|
||||||
auth=AUTH, data=s_file.open('rb').read())
|
auth=AUTH,
|
||||||
|
data=s_file.open('rb').read()
|
||||||
|
)
|
||||||
|
s_url = f"{URL}/api/packages/{USER}/generic/ormc-handouts/{VERSION}/{target}"
|
||||||
|
|
||||||
|
|
||||||
log(f"Published {title}")
|
log(f"Published {title}")
|
||||||
|
|
||||||
|
new_index.append({
|
||||||
|
"title": title,
|
||||||
|
"group": group,
|
||||||
|
"handout": h_url,
|
||||||
|
"solutions": s_url
|
||||||
|
})
|
||||||
|
|
||||||
|
requests.put(
|
||||||
|
f"{URL}/api/packages/{USER}/generic/{PACKAGE}/{VERSION}/index.json",
|
||||||
|
auth=AUTH,
|
||||||
|
data=json.dumps(new_index)
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user