From e8be969e9869c86696c304fcc7f71d33ea40139d Mon Sep 17 00:00:00 2001 From: dechert Date: Tue, 15 Jun 2021 17:32:40 +0200 Subject: [PATCH] add pdf command line option --- command_line.py | 4 +++- converter.py | 6 ++++++ requirements.txt | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/command_line.py b/command_line.py index 5a2cd21..df57f6c 100644 --- a/command_line.py +++ b/command_line.py @@ -10,13 +10,15 @@ def get_parser(): # required arg parser.add_argument("inputFile", help="name of the csv file to used as input, e.g. quiz.csv", type=str) + parser.add_argument('-pdf', '--pdf', action='store_true', + help="converts markdown file to pdf") return parser def command_line_runner(): parser = get_parser() args = parser.parse_args() - converter.write_markdown_file(args.inputFile) + converter.convert(args.inputFile, args.pdf) if __name__ == "__main__": diff --git a/converter.py b/converter.py index 0fbc432..729a3a2 100644 --- a/converter.py +++ b/converter.py @@ -21,6 +21,12 @@ class QuestionAndAnswers: return "QuestionAndAnswers: Question: {}, Answers: {}, Category: {}".format(self.question, self.answerArray, self.category) +def convert(csv_path, output_pdf=False): + write_markdown_file(csv_path) + if(output_pdf): + to_pdf("slide-deck.md") + + def write_markdown_file(csv_path): # csv_path = "quiz-example.csv" markdown_path = "slide-deck.md" diff --git a/requirements.txt b/requirements.txt index 5becbba..270c1da 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ pywin32==227 requests==2.25.1 urllib3==1.26.5 websocket-client==1.1.0 +six==1.16.0 # needed for docker to run properly