diff --git a/question.py b/question.py index 4bf6549..f289ce5 100644 --- a/question.py +++ b/question.py @@ -13,9 +13,11 @@ class Questions(object): QUESTION_TYPES = ["Text", "Image", "Music", "Code", "Video"] QUESTION_KEYS = ["Name", "Question", "Answer", "Type", "Double-Jeopardy", "Audio"] - def __init__(self, qfile): + def __init__(self, qfile, appendPath=False): self.qfile = qfile self._questions = None + self._appendPath = appendPath + self._basedir = os.path.dirname(qfile) self._read_questions() def get_sections(self): @@ -90,6 +92,8 @@ class Questions(object): # check if file for music/image questions exist if q["Type"] in ("Music", "Image", "Video"): + if self._appendPath: + q["Question"] = os.path.join(self._basedir, q["Question"]) if not os.path.isfile(q["Question"]): raise QuestionException("File for question %d, section %d (%s) not found" % (j, i, sec["Section"])) diff --git a/seopardy.py b/seopardy.py index 60e17c7..f8422d1 100755 --- a/seopardy.py +++ b/seopardy.py @@ -17,6 +17,7 @@ def _parser(): parser = argparse.ArgumentParser(description="Sebas jeopardy/beopardy clone") parser.add_argument("--gamestate", action="store", default=None, help="Gamestate to load to recover a crashed game") parser.add_argument("--conf", action="store", default="seopardy.conf", help="Path to config file") + parser.add_argument("--no-cwd", action="store_true", default=False, help="Do not change working directory to question folder") parser.add_argument("questions", action="store", help="Path to questionfile") return parser @@ -27,7 +28,7 @@ if __name__ == '__main__': questions = None try: - questions = Questions(args.questions) + questions = Questions(args.questions, appendPath=not args.no_cwd) except QuestionException as e: print(str(e), file=sys.stderr) sys.exit(1)