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): ...@@ -69,7 +69,8 @@ def fix_bibtex(lines, bibtex, rst_mode=False):
s = f"{COMMENT}\n{COMMENT}\n" + s s = f"{COMMENT}\n{COMMENT}\n" + s
i = s.find(COMMENT, s.find(COMMENT)+1) i = s.find(COMMENT, s.find(COMMENT)+1)
all_refs = [" " + r.strip() for r in all_refs] 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']) # s = s.replace(cpr, info['code_copyright'])
return s.splitlines() return s.splitlines()
......
...@@ -23,7 +23,7 @@ def o_block_funlines(lines, art, output, all_lines=None): ...@@ -23,7 +23,7 @@ def o_block_funlines(lines, art, output, all_lines=None):
return l2 return l2
pass 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): # def block_fun(lines, start_extra, end_extra, art, output, **kwargs):
# id = indent(lines[0]) # id = indent(lines[0])
# outf = output + ("_" + art if art is not None else "") + ".txt" # 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): ...@@ -75,21 +75,26 @@ def run_o(lines, file, output,package_base_dir=None, verbose=True):
if verbose: if verbose:
print(cmd) print(cmd)
print("File that will be run contains:", file_run) if show_output:
with open(file_run, 'r') as f: print("File that will be run contains:", file_run)
print(f.read()) with open(file_run, 'r') as f:
print(f.read())
s = subprocess.check_output(cmd, shell=True) s = subprocess.check_output(cmd, shell=True)
if verbose: if verbose:
print("> After I ran it I got the output") # print("[snipper] Obtained output")
print(s) # print(s)
if os.path.isfile(output_file): if os.path.isfile(output_file):
print("> Then Lets read the output file", output_file) print("[snipper] Snipper generated output to file", output_file)
with open(output_file, 'r') as f: if show_output:
print(f.read())
print(">> WAS THAT WHAT YOU EXPECTED???") with open(output_file, 'r') as f:
print(f.read())
print(">> WAS THAT WHAT YOU EXPECTED???")
else: 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) os.remove(file_run)
......
...@@ -73,19 +73,17 @@ def snip_dir(source_dir, # Sources ...@@ -73,19 +73,17 @@ def snip_dir(source_dir, # Sources
continue continue
if accept and (str(f).endswith(".py") or str(f).endswith(".rst") or str(f).endswith(".md")): if accept and (str(f).endswith(".py") or str(f).endswith(".rst") or str(f).endswith(".md")):
# if f.endswith("rst"):
# pass
solution_list = [] solution_list = []
kwargs = {} kwargs = {}
if verbose: if verbose:
print("Snipper processing", f) print("Snipper processing", f)
nrem, cut = censor_file(f, run_files=run_files, run_out_dirs=output_dir, cut_files=cut_files, 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, base_path=dest_dir,
references=references, references=references,
license_head=license_head, license_head=license_head,
censor_files=censor_files, censor_files=censor_files,
package_base_dir=package_base_dir, package_base_dir=package_base_dir,
verbose=verbose,
**kwargs) **kwargs)
if nrem > 0 and verbose: if nrem > 0 and verbose:
print(f"{nrem}> {f}") print(f"{nrem}> {f}")
......
...@@ -46,7 +46,8 @@ def censor_file(file, run_files=True, run_out_dirs=None, cut_files=True, ...@@ -46,7 +46,8 @@ def censor_file(file, run_files=True, run_out_dirs=None, cut_files=True,
strict=True, strict=True,
references=None, references=None,
license_head=None, license_head=None,
package_base_dir=None): package_base_dir=None, verbose=False):
if str(file).endswith("rst"): if str(file).endswith("rst"):
assert not run_files and not cut_files and not censor_files 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, ...@@ -87,7 +88,7 @@ def censor_file(file, run_files=True, run_out_dirs=None, cut_files=True,
ofiles[0] = ofiles[0].replace("\\", "/") ofiles[0] = ofiles[0].replace("\\", "/")
if run_files: 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]) run_i(lines, file=file, output=ofiles[0])
if cut_files: if cut_files:
save_s(lines, file_path=os.path.relpath(file, base_path), output_dir=run_out_dirs) 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.
Finish editing this message first!
Please register or to comment