Skip to content

Instantly share code, notes, and snippets.

@sharmaeklavya2
Created November 19, 2020 08:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharmaeklavya2/4452ce0d0fa18196b33ae17d6deb4ab5 to your computer and use it in GitHub Desktop.
Save sharmaeklavya2/4452ce0d0fa18196b33ae17d6deb4ab5 to your computer and use it in GitHub Desktop.
Download the files needed to compile a LaTeX paper for SoCG21
#!/usr/bin/env python3
"""Downloads all the files necessary to compile a LaTeX paper
as per the instructions of SOCG21."""
import sys
import os
from urllib.request import urlopen
from zipfile import ZipFile
SOCG_WRAPPER_URL = 'http://www.computational-geometry.org/guidelines/socg-lipics-v2019.cls'
SOCG_WRAPPER_FNAME = 'socg-lipics-v2019.cls'
LIPICS_ZIP_URL = 'https://submission.dagstuhl.de/styles/download-tag/lipics/v2019.2/authors/zip'
LIPICS_ZIP_FNAME = 'authors-lipics-v2019.zip'
LIPICS_FILES = """
lipics-v2019.cls
lipics-logo-bw.pdf
cc-by.pdf
orcid.pdf
""".split()
def already_exists(fname):
return os.path.exists(fname)
def check_and_download(fname, url):
if already_exists(fname):
print(fname, 'found', file=sys.stderr)
else:
print('downloading', url, file=sys.stderr)
with urlopen(url) as fp:
data = fp.read()
with open(fname, 'wb') as fp:
fp.write(data)
def get_lipics():
found = True
for fname in LIPICS_FILES:
if not already_exists(fname):
found = False
print(fname, 'not found; extraction needed', file=sys.stderr)
break
if found:
print('all lipics files found', file=sys.stderr)
return
check_and_download(LIPICS_ZIP_FNAME, LIPICS_ZIP_URL)
with ZipFile(LIPICS_ZIP_FNAME) as zfp:
for fname in LIPICS_FILES:
with zfp.open(fname, 'r') as fp:
data = fp.read()
with open(fname, 'wb') as fp:
fp.write(data)
if __name__ == '__main__':
check_and_download(SOCG_WRAPPER_FNAME, SOCG_WRAPPER_URL)
get_lipics()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment