Skip to content
Snippets Groups Projects
Commit de2da3a7 authored by Thomas Kluyver's avatar Thomas Kluyver
Browse files

Use list.sort() instead of a bunch of insert() calls

parent a5540cb9
No related branches found
No related tags found
1 merge request!331Some cleanup in calibrate.py
...@@ -263,24 +263,17 @@ def make_report(run_path, tmp_path, out_path, project, author, version, ...@@ -263,24 +263,17 @@ def make_report(run_path, tmp_path, out_path, project, author, version,
lead_rstfiles = ['InputParameters.rst', 'timing_summary.rst'] lead_rstfiles = ['InputParameters.rst', 'timing_summary.rst']
# Order rst files based on the known order(lead_rstfiles). # Order rst files based on the known order(lead_rstfiles).
for f in direntries: # TODO: fix order somewhere else instead of munging filenames
def sort_key(f):
if f in lead_rstfiles: if f in lead_rstfiles:
direntries.insert(lead_rstfiles.index(f), return lead_rstfiles.index(f), f
direntries.pop(direntries.index(f))) elif "summary" in f.lower():
# Move summary to the top, if it is exists, return len(lead_rstfiles), f
# after the known leading rst files.
if "summary" in f.lower() and f not in lead_rstfiles:
direntries.insert(len(lead_rstfiles),
direntries.pop(direntries.index(f)))
# Move 'precorrection' notebook to the top if it exists
# TODO: find a better way to order the report content
elif "precorrection" in f.lower(): elif "precorrection" in f.lower():
# There's currently only 1 case with 'precorrection', and that return len(lead_rstfiles) + 1, f
# also has a summary notebook, so we can hardcode N+1 until we else:
# rework this. return len(lead_rstfiles) + 2, f
direntries.insert(len(lead_rstfiles) + 1, lead_rstfiles.sort(key=sort_key)
direntries.pop(direntries.index(f)))
files_to_handle = [] files_to_handle = []
for entry in direntries: for entry in direntries:
......
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