Commit ebad41f8 authored by Matthieu Haefele's avatar Matthieu Haefele
Browse files

fix online presentation support by the archive script

parent 2776933e
......@@ -118,18 +118,31 @@ def truncate(dest_dir):
return truncated
def online_pres(url_support):
# Considered as an online presentation if not an archive nor a pdf
ext = os.path.splitext(url_support)
not_online_ext = [".tgz", ".gz", ".bz2", ".pdf"]
res = True
for e in not_online_ext:
res = res and e != ext
return res
def treat_support(line_orig, url_support, dest_dir, support_id):
import urllib.request
response = urllib.request.urlopen(url_support)
content = response.read()
root, ext = os.path.splitext(url_support)
new_support = os.path.join(dest_dir, 'support%02d%s'%(support_id, ext))
f = open(new_support, "wb")
f.write(content)
f.close()
rst_support = os.path.join(truncate(dest_dir), 'support%02d%s'%(support_id, ext))
new_line = line_orig.split('(')[0] + '(' + rst_support + ')\n'
new_line = ""
new_support = None
if online_pres(url_support):
new_line = line_orig.split('(')[0] + '(' + url_support + ')\n'
else:
response = urllib.request.urlopen(url_support)
content = response.read()
root, ext = os.path.splitext(url_support)
new_support = os.path.join(dest_dir, 'support%02d%s'%(support_id, ext))
f = open(new_support, "wb")
f.write(content)
f.close()
rst_support = os.path.join(truncate(dest_dir), 'support%02d%s'%(support_id, ext))
new_line = line_orig.split('(')[0] + '(' + rst_support + ')\n'
return new_line, new_support
......@@ -150,8 +163,9 @@ def fetch_supports(content_with_prog, evt_orig):
print("Treating %s"%res.group(1))
new_line, new_support = treat_support(l, res.group(1), dest_dir, support_id)
content_with_prog[i] = new_line
git_helper_str += "%s \\\n"%new_support
support_id += 1
if new_support != None:
git_helper_str += "%s \\\n"%new_support
support_id += 1
return git_helper_str, content_with_prog
......@@ -180,6 +194,7 @@ python3 %s path/to/evt_to_archive.rst nb_participants"""%(sys.argv[0]))
evt_content = fetch_content(evt_to_treat)
content_with_prog = gen_rst_evt_with_program(evt_content, nb_participants)
user_msg, prog_to_insert = fetch_supports(content_with_prog, evt_to_treat)
#write_content(content_with_prog, "pok")
write_content(content_with_prog, evt_to_treat)
print("\nrst file modified and supports downloaded. Please add them to the repository.\n\n%s"%user_msg)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment