diff --git a/config.yml b/config.yml index 51d75e5..6288234 100644 --- a/config.yml +++ b/config.yml @@ -2,5 +2,6 @@ auth: username: admin hashedPassword: pbkdf2:sha256:150000$gWnHgdeJ$778d54af56408b434fdd7151f4d8ea88e1ad7525d47326aa70671962e1f654a1 prod: False +basePath: './' outputPath: './output' uploadPath: './upload' diff --git a/config_parser.py b/config_parser.py index 5114ddb..9325987 100644 --- a/config_parser.py +++ b/config_parser.py @@ -18,5 +18,6 @@ with open(path_to_config, "r") as ymlfile: credentials = cfg["auth"] prod_mode = cfg["prod"] +base_path = cfg["basePath"] output_path = cfg["outputPath"] upload_path = cfg["uploadPath"] diff --git a/config_prod.yml b/config_prod.yml index 31b59b7..b010300 100644 --- a/config_prod.yml +++ b/config_prod.yml @@ -2,5 +2,6 @@ auth: username: admin hashedPassword: pbkdf2:sha256:150000$gWnHgdeJ$778d54af56408b434fdd7151f4d8ea88e1ad7525d47326aa70671962e1f654a1 prod: True +basePath: './csv-to-marp-converter' outputPath: './csv-to-marp-converter/output' uploadPath: './csv-to-marp-converter/upload' \ No newline at end of file diff --git a/converter.py b/converter.py index d8e580f..5fcb509 100644 --- a/converter.py +++ b/converter.py @@ -11,6 +11,7 @@ NUMBER_OF_ANSWERS = 5 import config_parser OUTPUT_FODLER = config_parser.output_path +BASE_FODLER = config_parser.base_path class QuestionAndAnswers: @@ -48,8 +49,8 @@ def write_markdown_file(csv_path): for line in data: if line.startswith("Kategorie"): name_of_category = line.split(",")[0] - print("name_of_category") - print(name_of_category) + # print("name_of_category") + # print(name_of_category) current_category = name_of_category # do nothing if row is empty elif line.split(",")[0] is "": @@ -61,7 +62,9 @@ def write_markdown_file(csv_path): # static_part = "" # copy template template_name = "quiz-slides-template.md" - shutil.copyfile(template_name, markdown_path) + template_path = os.path.join(BASE_FODLER, template_name) + + shutil.copyfile(template_path, markdown_path) # with open(markdown_path, 'w', encoding='UTF-8') as markdown_file: # append questions and answers to copy of template @@ -69,7 +72,7 @@ def write_markdown_file(csv_path): # write month headline # markdown_file.writelines(static_part) for q_and_a in list_of_q_and_as: - print(q_and_a) + # print(q_and_a) write_q_and_a_to_markdown_file(markdown_file, q_and_a) markdown_file.close() @@ -98,7 +101,7 @@ def write_q_and_a_to_markdown_file(markdown_file, q_and_a): def handle_q_and_a_row(line, list_of_q_and_as, category): column_data = line.split(',') - print(column_data) + # print(column_data) # causes UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 49: ordinal not in range(128) in linux # check size of array print(len(column_data)) if len(column_data) is NUMBER_OF_ANSWERS: @@ -107,7 +110,7 @@ def handle_q_and_a_row(line, list_of_q_and_as, category): # answers = column_data[-3:] q_and_a = QuestionAndAnswers(question, answers, category) list_of_q_and_as.append(q_and_a) - print(q_and_a) + # print(q_and_a) return list_of_q_and_as diff --git a/requirements.txt b/requirements.txt index 27918bc..0a1ef9d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,4 +19,4 @@ Werkzeug==2.0.1 zipp==3.4.1 PyYAML==5.4.1 # pywin32==301 # needed for docker error messages -pywin32==227 +# pywin32==227 # produces error during pip install while building docker image