Commit 491880ae authored by Deb's avatar Deb
Browse files

iss8 folder struc reform + improvements

parent dfcb68bf
Pipeline #455412 failed with stage
in 44 seconds
......@@ -47,12 +47,9 @@ def main(args):
PDFs in input folder are encrypted and stored in output folder.
Alongside with a CSV file mapping passwords to each PDF.
''')
parser.add_argument("-i", "--infolder", default="./pdfs_watermarked",
help="Input PDF folder. Default: ./pdfs_watermarked")
parser.add_argument("infolder", help="Input PDF folder.")
parser.add_argument("-o", "--outfolder", default="./pdfs_encrypted",
help="Output folder storing encrypted PDFs. " +
"Default: ./pdfs_encrypted")
parser.add_argument("outfolder", help="Output folder storing encrypted PDFs. ")
parser.add_argument("-p", "--password", default="",
help="Common password for all encrypted PDFs. " +
......@@ -78,13 +75,18 @@ def main(args):
pdf_folder = os.listdir(infolder)
pdf_files = [_ for _ in pdf_folder
if _.lower().endswith(".pdf")]
print("""
if len(pdf_files)>0:
print("""
Available PDFs to be encrypted:
- {}
Files in output folder {} will be overwritten during this process.
""".format("\n- ".join(pdf_files), outfolder))
else:
print ("""
There are no PDFs in the given directory.
Exiting now.""")
return
# Encrypt all PDFs in input folder
csv_lines = []
enc_files = []
......@@ -100,7 +102,9 @@ Files in output folder {} will be overwritten during this process.
password = pwgen.pwgen(8)
else:
password = args.password
if not os.path.exists(outfolder):
os.makedirs(outfolder)
# Encrypt
in_file = os.path.join(infolder, pdf_file)
enc_file = os.path.splitext(pdf_file)[0] + '_aes.pdf'
......
......@@ -52,12 +52,8 @@ def main(args):
Attention: zip-archive 'out' will be overwritten in the following!
''')
parser.add_argument(
"-i", "--infolder", default="./pdfs_encrypted",
help="Input folder with PDFs. Default: ./pdfs_encrypted")
parser.add_argument(
"-c", "--csv", default="./Bewertungen.csv",
help="Moodle grading sheet. Default: ./Bewertungen.csv")
parser.add_argument("infolder", help="Input folder with PDFs.")
parser.add_argument("csv", help="Moodle grading sheet.")
parser.add_argument(
"--csvdelim", default=",", help="CSV delimiter. Default: ','")
parser.add_argument(
......@@ -66,9 +62,7 @@ def main(args):
"--csvenc", default="utf-8", help="CSV encoding scheme. " +
"Typical encodings:'utf-8', 'utf-8-sig', or 'cp1252' (Windows). " +
"Default: 'utf-8'")
parser.add_argument(
"-o", "--outzip", default="./moodle_feedbacks.zip",
help="Zip archive. Default: ./moodle_feedbacks.zip")
parser.add_argument("outzip", help="Zip archive.")
parser.add_argument(
"-d", "--dry", action='store_true', help="Flag for dry run.")
parser.add_argument(
......@@ -115,6 +109,9 @@ Processing {} students'''.format(num_students))
allfiles = os.listdir(infolder)
allfiles.sort()
allpdfs = []
if (len(allfiles) == 0):
print(""" There are no PDFs in the given directory. Exiting now.""")
return
for f in allfiles:
if f.lower().endswith('.pdf') and matnum_utils.starts_with_matnum(f):
allpdfs.append(f)
......
Markdown is supported
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