From 83f47098e990ab4218134521582e12abe5044277 Mon Sep 17 00:00:00 2001 From: Tue Herlau <tuhe@dtu.dk> Date: Mon, 13 Feb 2023 13:20:33 +0100 Subject: [PATCH] updates --- src/snipper/fix_bf.py | 13 +++++++++++-- src/snipper/snip_dir.py | 2 +- src/snipper/snipper_main.py | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/snipper/fix_bf.py b/src/snipper/fix_bf.py index 0f8cb0c..dc2eb63 100644 --- a/src/snipper/fix_bf.py +++ b/src/snipper/fix_bf.py @@ -80,7 +80,10 @@ def _block_fun(lines, start_extra, end_extra, keep=False, permute=False, questio if len(ee) >= 2 and ee[0] == '"': ee = ee[1:-1] if len(ee) == 0: - ee = "Insert your solution and remove this error." + if not permute: + ee = "Insert your solution and remove this error." + else: + ee = "Remove this exception after the above lines have been uncommented and rearranged." start_extra = start_extra.strip() if keep: l2 = ['GARBAGE'] * cc @@ -93,15 +96,21 @@ def _block_fun(lines, start_extra, end_extra, keep=False, permute=False, questio insert_lines = False msg = [] if permute: - msg = [id + "# TODO: The following lines have been permuted. Can you put them back in order?"] + sperm = f"# TODO: Oy veh, the following {cc} lines below have been permuted. Uncomment, rearrange to the correct order and remove the error." + msg = [id + f"#"+sperm, id + "#"+"-"*len(sperm)] # Permute all lines. lines = f1(lines) insert_lines = True pass if questionmarks: + sperm = f"# TODO: The following {cc} lines have been obfuscated by having characters replaced by questionmarks. Make it work and remove the error." + msg = [id + f"#" + sperm, id + "#" + "-" * len(sperm)] lines = f2(lines) insert_lines = True elif halfquestionmarks: + sperm = f"# TODO: Half of each line of code in the following {cc} lines have been replaced by garbage. Make it work and remove the error." + msg = [id + f"#" + sperm, id + "#" + "-" * len(sperm)] + lines = f3(lines) insert_lines = True if not insert_lines: diff --git a/src/snipper/snip_dir.py b/src/snipper/snip_dir.py index 62ece1e..d55ee78 100644 --- a/src/snipper/snip_dir.py +++ b/src/snipper/snip_dir.py @@ -71,7 +71,7 @@ def snip_dir(source_dir, # Sources if os.path.isdir(f) or str(f).endswith("_grade.py"): continue - if accept and (str(f).endswith(".py") or str(f).endswith(".rst")): + if accept and (str(f).endswith(".py") or str(f).endswith(".rst") or str(f).endswith(".md")): # if f.endswith("rst"): # pass solution_list = [] diff --git a/src/snipper/snipper_main.py b/src/snipper/snipper_main.py index 3ed8374..094068e 100644 --- a/src/snipper/snipper_main.py +++ b/src/snipper/snipper_main.py @@ -36,8 +36,10 @@ def censor_file(file, run_files=True, run_out_dirs=None, cut_files=True, license_head=None): if str(file).endswith("rst"): assert not run_files and not cut_files and not censor_files - print(file) + # if str(file).endswith("md"): + # assert not run_files and not cut_files + if references == None: references = {} -- GitLab