Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
pycalibration
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Model registry
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
calibration
pycalibration
Commits
de2da3a7
Commit
de2da3a7
authored
4 years ago
by
Thomas Kluyver
Browse files
Options
Downloads
Patches
Plain Diff
Use list.sort() instead of a bunch of insert() calls
parent
a5540cb9
No related branches found
No related tags found
1 merge request
!331
Some cleanup in calibrate.py
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xfel_calibrate/finalize.py
+9
-16
9 additions, 16 deletions
xfel_calibrate/finalize.py
with
9 additions
and
16 deletions
xfel_calibrate/finalize.py
+
9
−
16
View file @
de2da3a7
...
@@ -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
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment