Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mpsd-software-manager
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository 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
MPSD Computational Science
mpsd-software-manager
Commits
29afcd9c
Commit
29afcd9c
authored
1 year ago
by
Martin Lang
Browse files
Options
Downloads
Patches
Plain Diff
Move pretty_print_spec to separate module in util
parent
206a4f9d
No related branches found
No related tags found
1 merge request
!123
Resolve "split the main file into one per cmd"
Pipeline
#403853
passed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/mpsd_software_manager/cmds/status.py
+1
-43
1 addition, 43 deletions
src/mpsd_software_manager/cmds/status.py
src/mpsd_software_manager/utils/pretty_print_spec.py
+42
-0
42 additions, 0 deletions
src/mpsd_software_manager/utils/pretty_print_spec.py
with
43 additions
and
43 deletions
src/mpsd_software_manager/cmds/status.py
+
1
−
43
View file @
29afcd9c
...
...
@@ -4,10 +4,9 @@ import os
from
pathlib
import
Path
from
typing
import
List
,
Union
from
rich
import
print
as
rprint
from
mpsd_software_manager
import
config_vars
from
mpsd_software_manager.utils.microarch
import
get_native_microarchitecture
from
mpsd_software_manager.utils.pretty_print_spec
import
pretty_print_spec
from
mpsd_software_manager.utils.run
import
run
...
...
@@ -247,44 +246,3 @@ def list_installed_packages(
for
package
in
package_list
:
pretty_print_spec
(
package
)
return
package_list
# TODO Martin: this could maybe be moved to utils
def
pretty_print_spec
(
spec
:
str
)
->
None
:
"""
Print the specs with colours using rich.
- packages in white (everything until first %)
- compiler in green (everything between % and first+)
- variants in cyan (everything that starts with +)
- build_system in yellow (everything that starts with build_system=)
- architecture in purple (everything that starts with arch=)
"""
# Note that this implementation necessitates the definition of
# flags in the order in which we ask spack to format the output
# also for flags that need the same colour because they are
# interchangeable (like `+` and `~`) we need to define them together
colour_map
=
{
"
%
"
:
"
green
"
,
"
+
"
:
"
cyan
"
,
"
~
"
:
"
cyan
"
,
"
build_system=
"
:
"
yellow
"
,
"
libs=
"
:
"
blue
"
,
"
arch=
"
:
"
purple
"
,
}
prev_colour
=
""
for
flag
in
colour_map
.
keys
():
# If the flag is in the spec string,
# replace it with: previous closing colour, new colour, flag
if
flag
in
spec
:
if
(
colour_map
[
flag
]
not
in
prev_colour
):
# avoid duplicates for eg when having both ~ and +
spec
=
spec
.
replace
(
flag
,
f
"
{
prev_colour
}
[
{
colour_map
[
flag
]
}
]
{
flag
}
"
,
1
)
prev_colour
=
f
"
[/
{
colour_map
[
flag
]
}
]
"
# for next iter
# Add the final closing tag to the spec string
spec
+=
prev_colour
rprint
(
spec
)
This diff is collapsed.
Click to expand it.
src/mpsd_software_manager/utils/pretty_print_spec.py
0 → 100644
+
42
−
0
View file @
29afcd9c
"""
Coloured output of spack spec.
"""
from
rich
import
print
as
rprint
def
pretty_print_spec
(
spec
:
str
)
->
None
:
"""
Print the specs with colours using rich.
- packages in white (everything until first %)
- compiler in green (everything between % and first+)
- variants in cyan (everything that starts with +)
- build_system in yellow (everything that starts with build_system=)
- architecture in purple (everything that starts with arch=)
"""
# Note that this implementation necessitates the definition of
# flags in the order in which we ask spack to format the output
# also for flags that need the same colour because they are
# interchangeable (like `+` and `~`) we need to define them together
colour_map
=
{
"
%
"
:
"
green
"
,
"
+
"
:
"
cyan
"
,
"
~
"
:
"
cyan
"
,
"
build_system=
"
:
"
yellow
"
,
"
libs=
"
:
"
blue
"
,
"
arch=
"
:
"
purple
"
,
}
prev_colour
=
""
for
flag
in
colour_map
.
keys
():
# If the flag is in the spec string,
# replace it with: previous closing colour, new colour, flag
if
flag
in
spec
:
if
(
colour_map
[
flag
]
not
in
prev_colour
):
# avoid duplicates for eg when having both ~ and +
spec
=
spec
.
replace
(
flag
,
f
"
{
prev_colour
}
[
{
colour_map
[
flag
]
}
]
{
flag
}
"
,
1
)
prev_colour
=
f
"
[/
{
colour_map
[
flag
]
}
]
"
# for next iter
# Add the final closing tag to the spec string
spec
+=
prev_colour
rprint
(
spec
)
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