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

Minor output fix

parent 747fc1d7
No related branches found
No related tags found
No related merge requests found
Pipeline #34197 passed
......@@ -69,7 +69,8 @@ def fix_bibtex(lines, bibtex, rst_mode=False):
s = f"{COMMENT}\n{COMMENT}\n" + s
i = s.find(COMMENT, s.find(COMMENT)+1)
all_refs = [" " + r.strip() for r in all_refs]
s = s[:i] + "References:\n" + "\n".join(all_refs) +"\n"+ s[i:]
# Two newlines because of python styleguide.
s = s[:i].rstrip() + "\n\nReferences:\n" + "\n".join(all_refs) +"\n"+ s[i:]
# s = s.replace(cpr, info['code_copyright'])
return s.splitlines()
......
......@@ -23,7 +23,7 @@ def o_block_funlines(lines, art, output, all_lines=None):
return l2
pass
def run_o(lines, file, output,package_base_dir=None, verbose=True):
def run_o(lines, file, output,package_base_dir=None, verbose=True, show_output=False):
# def block_fun(lines, start_extra, end_extra, art, output, **kwargs):
# id = indent(lines[0])
# outf = output + ("_" + art if art is not None else "") + ".txt"
......@@ -75,21 +75,26 @@ def run_o(lines, file, output,package_base_dir=None, verbose=True):
if verbose:
print(cmd)
if show_output:
print("File that will be run contains:", file_run)
with open(file_run, 'r') as f:
print(f.read())
s = subprocess.check_output(cmd, shell=True)
if verbose:
print("> After I ran it I got the output")
print(s)
# print("[snipper] Obtained output")
# print(s)
if os.path.isfile(output_file):
print("> Then Lets read the output file", output_file)
print("[snipper] Snipper generated output to file", output_file)
if show_output:
with open(output_file, 'r') as f:
print(f.read())
print(">> WAS THAT WHAT YOU EXPECTED???")
else:
print("No output file produced", output_file)
print("[snipper] No output file produced which is quite odd. The terminal output is")
print(s)
print(f"[snipper] No output file produced: {output_file=}")
os.remove(file_run)
......
......@@ -73,19 +73,17 @@ def snip_dir(source_dir, # Sources
continue
if accept and (str(f).endswith(".py") or str(f).endswith(".rst") or str(f).endswith(".md")):
# if f.endswith("rst"):
# pass
solution_list = []
kwargs = {}
if verbose:
print("Snipper processing", f)
nrem, cut = censor_file(f, run_files=run_files, run_out_dirs=output_dir, cut_files=cut_files,
# solution_list=solution_list,
base_path=dest_dir,
references=references,
license_head=license_head,
censor_files=censor_files,
package_base_dir=package_base_dir,
verbose=verbose,
**kwargs)
if nrem > 0 and verbose:
print(f"{nrem}> {f}")
......
......@@ -46,7 +46,8 @@ def censor_file(file, run_files=True, run_out_dirs=None, cut_files=True,
strict=True,
references=None,
license_head=None,
package_base_dir=None):
package_base_dir=None, verbose=False):
if str(file).endswith("rst"):
assert not run_files and not cut_files and not censor_files
......@@ -87,7 +88,7 @@ def censor_file(file, run_files=True, run_out_dirs=None, cut_files=True,
ofiles[0] = ofiles[0].replace("\\", "/")
if run_files:
run_o(lines, file=file, output=ofiles[0], package_base_dir=package_base_dir)
run_o(lines, file=file, output=ofiles[0], package_base_dir=package_base_dir, verbose=verbose, show_output=False)
run_i(lines, file=file, output=ofiles[0])
if cut_files:
save_s(lines, file_path=os.path.relpath(file, base_path), output_dir=run_out_dirs)
......
__version__ = "0.1.18.15"
__version__ = "0.1.18.16"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment