Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
pmbootstrap
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
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
pmbootstrap
Commits
ddd920b1
Unverified
Commit
ddd920b1
authored
5 months ago
by
Newbyte
Committed by
Caleb Connolly
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
pmb.config.init: Add more type hints (MR 2434)
parent
82a9059d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!2434
Add more type hints, fix some type errors, and clean up some strings
Pipeline
#208977
failed
5 months ago
Stage: lint
Stage: deploy
Stage: test
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
pmb/config/init.py
+14
-13
14 additions, 13 deletions
pmb/config/init.py
with
14 additions
and
13 deletions
pmb/config/init.py
+
14
−
13
View file @
ddd920b1
...
...
@@ -10,6 +10,7 @@ import glob
import
json
import
os
import
shutil
from
pathlib
import
Path
from
typing
import
Any
import
pmb.aportgen
...
...
@@ -43,7 +44,7 @@ def require_programs() -> None:
)
def
ask_for_username
(
default_user
:
str
):
def
ask_for_username
(
default_user
:
str
)
->
str
:
"""
Ask for a reasonable username for the non-root user.
:returns: the username
...
...
@@ -60,7 +61,7 @@ def ask_for_username(default_user: str):
return
ret
def
ask_for_work_path
(
args
:
PmbArgs
):
def
ask_for_work_path
(
args
:
PmbArgs
)
->
tuple
[
Path
,
bool
]
:
"""
Ask for the work path, until we can create it (when it does not exist) and write into it.
:returns: (path, exists)
...
...
@@ -112,7 +113,7 @@ def ask_for_work_path(args: PmbArgs):
)
def
ask_for_channel
(
config
:
Config
):
def
ask_for_channel
(
config
:
Config
)
->
str
:
"""
Ask for the postmarketOS release channel.
The channel dictates, which pmaports branch pmbootstrap will check out,
and which repository URLs will be used when initializing chroots.
...
...
@@ -148,7 +149,7 @@ def ask_for_channel(config: Config):
logging
.
fatal
(
"
ERROR: Invalid channel specified, please type in one from the list above.
"
)
def
ask_for_ui
(
deviceinfo
)
:
def
ask_for_ui
(
deviceinfo
:
Deviceinfo
)
->
str
:
ui_list
=
pmb
.
helpers
.
ui
.
list_ui
(
deviceinfo
.
arch
)
hidden_ui_count
=
0
device_is_accelerated
=
deviceinfo
.
gpu_accelerated
==
"
true
"
...
...
@@ -231,7 +232,7 @@ def ask_for_systemd(config: Config, ui):
return
answer
def
ask_for_keymaps
(
config
:
Config
,
deviceinfo
:
Deviceinfo
):
def
ask_for_keymaps
(
config
:
Config
,
deviceinfo
:
Deviceinfo
)
->
str
:
if
not
deviceinfo
.
keymaps
or
deviceinfo
.
keymaps
.
strip
()
==
""
:
return
""
options
=
deviceinfo
.
keymaps
.
split
(
"
"
)
...
...
@@ -246,7 +247,7 @@ def ask_for_keymaps(config: Config, deviceinfo: Deviceinfo):
logging
.
fatal
(
"
ERROR: Invalid keymap specified, please type in one from the list above.
"
)
def
ask_for_timezone
():
def
ask_for_timezone
()
->
str
:
localtimes
=
[
"
/etc/zoneinfo/localtime
"
,
"
/etc/localtime
"
]
zoneinfo_path
=
"
/usr/share/zoneinfo/
"
for
localtime
in
localtimes
:
...
...
@@ -327,7 +328,7 @@ def ask_for_provider_select(apkbuild, providers_cfg) -> None:
)
def
ask_for_provider_select_pkg
(
pkgname
,
providers_cfg
)
->
None
:
def
ask_for_provider_select_pkg
(
pkgname
:
str
,
providers_cfg
:
dict
[
str
,
str
]
)
->
None
:
"""
Look up the APKBUILD for the specified pkgname and ask for selectable
providers that are specified using
"
_pmb_select
"
.
...
...
@@ -342,7 +343,7 @@ def ask_for_provider_select_pkg(pkgname, providers_cfg) -> None:
ask_for_provider_select
(
apkbuild
,
providers_cfg
)
def
ask_for_device_kernel
(
config
:
Config
,
device
:
str
):
def
ask_for_device_kernel
(
config
:
Config
,
device
:
str
)
->
str
:
"""
Ask for the kernel that should be used with the device.
:param device: code name, e.g.
"
lg-mako
"
...
...
@@ -385,7 +386,7 @@ def ask_for_device_kernel(config: Config, device: str):
return
ret
def
ask_for_device
(
context
:
Context
):
def
ask_for_device
(
context
:
Context
)
->
tuple
[
str
,
bool
,
str
]
:
"""
Prompt for the device vendor, model, and kernel.
...
...
@@ -462,7 +463,7 @@ def ask_for_device(context: Context):
return
(
device
,
device_path
is
not
None
,
kernel
)
def
ask_for_additional_options
(
config
)
->
None
:
def
ask_for_additional_options
(
config
:
Config
)
->
None
:
context
=
pmb
.
core
.
context
.
get_context
()
# Allow to skip additional options
logging
.
info
(
...
...
@@ -546,7 +547,7 @@ def ask_for_additional_options(config) -> None:
config
.
mirrors
[
"
systemd
"
]
=
os
.
path
.
join
(
mirror
,
"
staging/systemd/
"
)
def
ask_for_mirror
():
def
ask_for_mirror
()
->
str
:
regex
=
"
^[1-9][0-9]*$
"
# single non-zero number only
json_path
=
pmb
.
helpers
.
http
.
download
(
...
...
@@ -601,7 +602,7 @@ def ask_for_mirror():
return
mirror
def
ask_for_hostname
(
default
:
str
|
None
,
device
)
:
def
ask_for_hostname
(
default
:
str
|
None
,
device
:
str
)
->
str
:
if
device
:
device
=
pmb
.
helpers
.
other
.
normalize_hostname
(
device
)
while
True
:
...
...
@@ -635,7 +636,7 @@ def ask_build_pkgs_on_install(default: bool) -> bool:
)
def
get_locales
():
def
get_locales
()
->
list
[
str
]
:
ret
=
[]
list_path
=
f
"
{
pmb
.
config
.
pmb_src
}
/pmb/data/locales
"
with
open
(
list_path
)
as
handle
:
...
...
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