Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
mrhlpr
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
postmarketOS
mrhlpr
Commits
bc35aee2
Unverified
Commit
bc35aee2
authored
1 year ago
by
Petr Hodina
Committed by
Oliver Smith
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
mrtest: allow to toggle multiple packages and use ranges (MR 23)
parent
976b3319
No related branches found
Branches containing commit
Tags
1.3.0
Tags containing commit
1 merge request
!23
mrtest: allow to select multiple packages and use ranges
Pipeline
#184960
passed
1 year ago
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mrtest/select_package.py
+44
-6
44 additions, 6 deletions
mrtest/select_package.py
with
44 additions
and
6 deletions
mrtest/select_package.py
+
44
−
6
View file @
bc35aee2
...
...
@@ -88,6 +88,46 @@ def show_commands():
print
(
"
l: list selection
"
)
print
(
"
y: confirm selection
"
)
print
(
"
q: quit
"
)
print
(
""
)
print
(
"
Toggling multiple packages in one command is possible (e.g. 2 3 4 10-15 20)
"
)
def
toggle_package
(
selection
,
apks
,
ret
):
"""
Toggle the package based on the user action.
:param selection: user input, single integer
:param apks: list of packages available for install
:param ret: list containing packages that are marked for install
"""
pkg
=
int
(
selection
)
if
pkg
>=
1
and
pkg
<=
len
(
apks
):
apk
=
apks
[
pkg
-
1
]
if
apk
in
ret
:
ret
=
[
x
for
x
in
ret
if
x
!=
apk
]
else
:
ret
+=
[
apk
]
else
:
print
(
f
"
Number
{
pkg
}
is out of range (1-
{
len
(
apks
)
}
)! Ignoring...
"
)
return
ret
def
toggle_packages
(
action
,
apks
,
ret
):
"""
Toggle multiple packages based on the user action.
:param action: user input, multiple integers or range
:param apks: list of packages available for install
:param ret: list containing packages that are marked for install
"""
selection
=
action
.
split
()
for
i
in
selection
:
multiple
=
i
.
split
(
"
-
"
)
size
=
len
(
multiple
)
if
size
==
1
and
i
.
isnumeric
():
ret
=
toggle_package
(
i
,
apks
,
ret
)
elif
size
==
2
and
multiple
[
0
].
isnumeric
()
and
multiple
[
1
].
isnumeric
():
start
=
int
(
multiple
[
0
])
stop
=
int
(
multiple
[
1
])
+
1
for
j
in
range
(
start
,
stop
):
ret
=
toggle_package
(
j
,
apks
,
ret
)
else
:
print
(
f
"
Don
'
t know (
{
i
}
)! Ignoring...
"
)
return
ret
def
ask
(
zip_path
):
...
...
@@ -128,12 +168,10 @@ def ask(zip_path):
exit
(
1
)
elif
action
==
"
u
"
:
ret
=
toggle_installed
(
apks
,
ret
)
elif
action
.
isnumeric
()
and
int
(
action
)
>=
1
and
int
(
action
)
<=
len
(
apks
):
apk
=
apks
[
int
(
action
)
-
1
]
if
apk
in
ret
:
ret
=
[
x
for
x
in
ret
if
x
!=
apk
]
else
:
ret
+=
[
apk
]
elif
"
"
in
action
or
"
-
"
in
action
:
ret
=
toggle_packages
(
action
,
apks
,
ret
)
elif
action
.
isnumeric
():
ret
=
toggle_package
(
action
,
apks
,
ret
)
elif
len
(
action
)
>
0
:
print
(
f
"
Don
'
t know (
{
action
}
), try
'
h
'
for help
"
)
show_selection_short
(
apks
,
ret
)
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