Skip to content
Snippets Groups Projects
Commit bf5f5daa authored by tuhe's avatar tuhe
Browse files

Version committed to pypi

parent b1f6912f
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,8 @@ def snip_dir(source_dir, dest_dir, exclude=None, clean_destination_dir=True):
exclude = []
if not os.path.exists(dest_dir):
os.makedirs(dest_dir)
source_dir = os.path.abspath(source_dir)
dest_dir = os.path.abspath(dest_dir)
if os.path.samefile( source_dir, dest_dir):
raise Exception("Source and destination is the same")
if clean_destination_dir:
......@@ -25,7 +27,7 @@ def snip_dir(source_dir, dest_dir, exclude=None, clean_destination_dir=True):
# def fix_hw(info, hw, out, run_files=False, cut_files=False, students_irlc_tools=None, **kwargs):
# CE = info['CE']
# paths = get_paths()
print(f"Fixing {hw['base']} -> {out}")
print(f"[snipper] Synchronizing directories: {hw['base']} -> {out}")
if os.path.exists(out):
shutil.rmtree(out)
......
......@@ -286,17 +286,22 @@ def fix_f(lines, debug):
comments = [id + c for c in comments]
if len(comments) > 0:
lines2 += comments[0].split("\n")
lines2 += [id+"#!b"]
lines2 += (id+funrem.strip()).split("\n")
# lines2 += [id+"#!b"]
f = [id + l.strip() for l in funrem.splitlines()]
f[0] = f[0] + "#!b"
# lines2 += (id+funrem.strip()).split("\n")
errm = l_head if len(l_head) > 0 else "Implement function body"
lines2 += [f'{id}#!b {errm}']
f[-1] = f[-1] + f' #!b {errm}'
lines2 += f
# lines2 += [f'{id}#!b {errm}']
else:
lines2.append(l)
i += 1
return lines2
def fix_b2(lines):
def fix_b2(lines, keep=False):
stats = {'n': 0}
def block_fun(lines, start_extra, end_extra, art, stats=None, **kwargs):
id = indent(lines[0])
......@@ -307,8 +312,12 @@ def fix_b2(lines):
if len(ee) >= 2 and ee[0] == '"':
ee = ee[1:-1]
start_extra = start_extra.strip()
l2 = ([id+start_extra] if len(start_extra) > 0 else []) + [id + f"# TODO: {cc} lines missing.",
id+f'raise NotImplementedError("{ee}")']
if keep:
l2 = ['GARBAGE'] * cc
else:
l2 = ([id+start_extra] if len(start_extra) > 0 else []) + [id + f"# TODO: {cc} lines missing.", id+f'raise NotImplementedError("{ee}")']
# if "\n".join(l2).find("l=l")>0:
# a = 2342342
stats['n'] += cc
......@@ -386,6 +395,17 @@ def full_strip(lines, tags=None):
lines = strip_tag(lines, t)
return lines
def censor_code(lines, keep=True):
# lines = code.split("\n")
dbug = True
lines = fix_f(lines, dbug)
lines, nB, cut = fix_b2(lines, keep=True)
return lines
# print("safs")
def censor_file(file, info, paths, run_files=True, run_out_dirs=None, cut_files=True, solution_list=None,
censor_files=True,
include_path_base=None,
......
__version__ = "0.0.1"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment