Skip to content
Snippets Groups Projects
Commit 61a1b1dd authored by Dennis Baurichter's avatar Dennis Baurichter
Browse files

commit: Fix hazard menu

Fix missing comma, reorder and rename entries.
Don't try to open multiple PDFs with one unique pdf viewer instance.

Fixes #90
parent b9c51df3
No related branches found
No related tags found
No related merge requests found
......@@ -175,21 +175,19 @@ folders=klausurarchiv.folders.FolderRegistry()
folders.load()
folders.load_database()
def openFile(fn):
def openFile(fn,unique=True):
fe=os.path.splitext(fn)[1].lower()
if fe==".pdf":
if pdfViewer=="qpdfview":
u="--unique --instance klausurarchiv" if unique else ""
os.system(
"qpdfview "
"--unique --instance klausurarchiv "
"%s "
">/dev/null 2>/dev/null &"%shlex.quote(fn))
"qpdfview %s %s "
">/dev/null 2>/dev/null &"%(u,shlex.quote(fn)))
elif pdfViewer=="okular":
u="--unique" if unique else ""
os.system(
"okular "
"--unique "
"%s "
">/dev/null 2>/dev/null &"%shlex.quote(fn))
"okular %s %s "
">/dev/null 2>/dev/null &"%(u,shlex.quote(fn)))
elif os.path.isdir(fn):
for fn1 in os.listdir(fn):
if os.path.splitext(fn1)[1]==".pdf":
......@@ -491,23 +489,19 @@ for base, ns, items in sorted(all_exams,key=lambda i:i[1].lectures[0]+i[1].date)
reiterate=False
while True:
opt=ask_option(
"Please open all items for me!\n"
"Please open all items for me!",
"There is no collision. Continue committing this exam!",
"Items do collide. Skip this exam and continue with the next!",
"Items do collide. Let me rename this one!")
"Items do collide. Let me rename this one!",
"Skip this exam and continue with the next!")
if opt==0:
for item in items:
if os.path.splitext(item)[1].lower()!=".pdf": continue
openFile(os.path.join(os.path.dirname(base),item))
openFile(os.path.join(os.path.dirname(base),item),unique=False)
for fn2,item2,ns2 in find_similar_items(item,ns):
openFile(fn2)
openFile(fn2,unique=False)
elif opt==1:
break
elif opt==2:
exam_processed=True
reiterate=True
break
elif opt==3:
for fn,trg,ctrl in klausurarchiv.renaming.renameFiles(
[base], callbackOpen=openFile,
defaultScheme=klausurarchiv.namingscheme.New):
......@@ -518,6 +512,10 @@ for base, ns, items in sorted(all_exams,key=lambda i:i[1].lectures[0]+i[1].date)
items={ "%s%s"%(base,os.path.splitext(v)[1]) for v in items }
reiterate=True
break
elif opt==3:
exam_processed=True
reiterate=True
break
if reiterate:
continue
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment