aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Liodden <eriklio@stud.ntnu.no>2017-09-21 23:36:04 +0200
committerErik Liodden <eriklio@stud.ntnu.no>2017-09-21 23:36:04 +0200
commitb0b8e93ce1f74c3711498e6a3a0b4c83b962b679 (patch)
treeac147e457c265b251bf4747396810f321e5a031d
parent735a5f0df0b810b22d38b8c0566eb02f1a23060b (diff)
downloadboil-me-baby-b0b8e93ce1f74c3711498e6a3a0b4c83b962b679.tar.gz
user can specify output directory
added the --out <dir> option that enables the user to specify an output directory for the files.
-rw-r--r--boil_me_baby.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/boil_me_baby.py b/boil_me_baby.py
index d8a4452..545b29f 100644
--- a/boil_me_baby.py
+++ b/boil_me_baby.py
@@ -6,6 +6,8 @@ parser = argparse.ArgumentParser(prog='lf-fetch', usage='%(prog)s [options]',
description='ls-parser searches and fetches .pdfs from math courses.')
parser.add_argument('-s', '--semester', default="all",
help='which semester. eg \'2017h\' or \'2015v\' or \'all\'')
+parser.add_argument('-o', '--out', default="./out",
+ help='output directory')
parser.add_argument('--lf-only', action='store_true', default=False,
help='only fetch lfs')
parser.add_argument('--list-courses', action='store_true', default=False,
@@ -94,7 +96,7 @@ def get_course_years(courses):
continue
def get_site_with_exercises(courses):
- call(["mkdir", "-p", "out"])
+ call(["mkdir", "-p", args.out])
a = "https://wiki.math.ntnu.no/"
b = "https://www.math.ntnu.no/emner/"
sites = [
@@ -127,10 +129,10 @@ def get_site_with_exercises(courses):
if ("forslag" in pdf or "lf" in pdf or "sol" in pdf or
"answer" in pdf or "losn" in pdf):
call(["wget", "-nc", "-q", "--show-progress", "-P",
- "out/" + code + '/' + year, pdf])
+ args.out + '/' + code + '/' + year, pdf])
else:
call(["wget", "-nc", "-q", "--show-progress", "-P",
- "out/" + code + '/' + year, pdf])
+ args.out + '/' + code + '/' + year, pdf])
def list_courses(courses):
if (args.semester != "all"):