From f3b3fe906bf16a3a077daf33f5dd98078c20ea1e Mon Sep 17 00:00:00 2001 From: Caio Fontes Date: Wed, 19 May 2021 16:24:52 -0300 Subject: [PATCH] enforce E501 in pmb/config (MR 2058) --- pmb/config/__init__.py | 21 +++++++++++++-------- pmb/config/init.py | 35 +++++++++++++++++++++++------------ pmb/config/load.py | 9 +++++---- pmb/config/merge_with_args.py | 3 ++- 4 files changed, 43 insertions(+), 25 deletions(-) diff --git a/pmb/config/__init__.py b/pmb/config/__init__.py index f4313e77..41c148d2 100644 --- a/pmb/config/__init__.py +++ b/pmb/config/__init__.py @@ -79,7 +79,8 @@ defaults = { "ccache_size": "5G", "is_default_channel": True, "cipher": "aes-xts-plain64", - "config": (os.environ.get('XDG_CONFIG_HOME') or os.path.expanduser("~/.config")) + "/pmbootstrap.cfg", + "config": os.environ.get('XDG_CONFIG_HOME') or + ((os.path.expanduser("~/.config")) + "/pmbootstrap.cfg"), "device": "qemu-amd64", "extra_packages": "none", "fork_alpine": False, @@ -521,10 +522,11 @@ flashers = { "boot", "$BOOT/boot.img-$FLAVOR"]], }, }, - # Some devices provide Fastboot but using Android boot images is not practical - # for them (e.g. because they support booting from FAT32 partitions directly - # and/or the Android boot partition is too small). This can be implemented - # using --split (separate image files for boot and rootfs). + # Some devices provide Fastboot but using Android boot images is not + # practical for them (e.g. because they support booting from FAT32 + # partitions directly and/or the Android boot partition is too small). + # This can be implemented using --split (separate image files for boot and + # rootfs). # This flasher allows flashing the split image files using Fastboot. "fastboot-bootpart": { "split": True, @@ -567,7 +569,8 @@ flashers = { ["heimdall", "flash", "--$PARTITION_SYSTEM", "$IMAGE"]], "flash_kernel": [ ["heimdall_wait_for_device.sh"], - ["heimdall", "flash", "--$PARTITION_KERNEL", "$BOOT/boot.img-$FLAVOR"]], + ["heimdall", "flash", "--$PARTITION_KERNEL", + "$BOOT/boot.img-$FLAVOR"]], "flash_vbmeta": [ ["avbtool", "make_vbmeta_image", "--flags", "2", "--padding_size", "$FLASH_PAGESIZE", @@ -660,8 +663,10 @@ newapkbuild_arguments_switches_other = [ # # UPGRADE # -# Patterns of package names to ignore for automatic pmaport upgrading ("pmbootstrap aportupgrade --all") -upgrade_ignore = ["device-*", "firmware-*", "linux-*", "postmarketos-*", "*-aarch64", "*-armhf", "*-armv7"] +# Patterns of package names to ignore for automatic pmaport upgrading +# ("pmbootstrap aportupgrade --all") +upgrade_ignore = ["device-*", "firmware-*", "linux-*", "postmarketos-*", + "*-aarch64", "*-armhf", "*-armv7"] # # SIDELOAD diff --git a/pmb/config/init.py b/pmb/config/init.py index 2efc9c0f..ec83e807 100644 --- a/pmb/config/init.py +++ b/pmb/config/init.py @@ -137,7 +137,8 @@ def ask_for_ui_extras(args, ui): if extra is None: return False - logging.info("This user interface has an extra package: " + extra["pkgdesc"]) + logging.info("This user interface has an extra package: " + + extra["pkgdesc"]) return pmb.helpers.cli.confirm(args, "Enable this package?", default=args.ui_extras) @@ -179,7 +180,8 @@ def ask_for_timezone(args): pass if tz: logging.info("Your host timezone: " + tz) - if pmb.helpers.cli.confirm(args, "Use this timezone instead of GMT?", + if pmb.helpers.cli.confirm(args, + "Use this timezone instead of GMT?", default="y"): return tz logging.info("WARNING: Unable to determine timezone configuration on host," @@ -267,7 +269,8 @@ def ask_for_device_nonfree(args, device): subpkgname = "device-" + device + "-nonfree-" + type subpkg = apkbuild["subpackages"].get(subpkgname, {}) if subpkg is None: - raise RuntimeError("Cannot find subpackage function for " + subpkgname) + raise RuntimeError("Cannot find subpackage function for " + f"{subpkgname}") if subpkg: logging.info(subpkgname + ": " + subpkg["pkgdesc"]) ret[type] = pmb.helpers.cli.confirm(args, "Enable this package?", @@ -302,10 +305,11 @@ def ask_for_device(args): continue else: # Unmaintained devices can be selected, but are not displayed - devices = sorted(pmb.helpers.devices.list_codenames(args, vendor, unmaintained=False)) + devices = sorted(pmb.helpers.devices.list_codenames( + args, vendor, unmaintained=False)) # Remove "vendor-" prefixes from device list codenames = [x.split('-', 1)[1] for x in devices] - logging.info("Available codenames (" + str(len(codenames)) + "): " + + logging.info(f"Available codenames ({len(codenames)}): " + ", ".join(codenames)) if current_vendor != vendor: @@ -387,11 +391,13 @@ def ask_for_additional_options(args, cfg): # Ccache size logging.info("We use ccache to speed up building the same code multiple" " times. How much space should the ccache folder take up per" - " architecture? After init is through, you can check the current" - " usage with 'pmbootstrap stats'. Answer with 0 for infinite.") + " architecture? After init is through, you can check the" + " current usage with 'pmbootstrap stats'. Answer with 0 for" + " infinite.") regex = "0|[0-9]+(k|M|G|T|Ki|Mi|Gi|Ti)" answer = pmb.helpers.cli.ask(args, "Ccache size", None, args.ccache_size, - lowercase_answer=False, validation_regex=regex) + lowercase_answer=False, + validation_regex=regex) cfg["pmbootstrap"]["ccache_size"] = answer # Sudo timer @@ -408,7 +414,8 @@ def ask_for_additional_options(args, cfg): def ask_for_hostname(args, device): while True: - ret = pmb.helpers.cli.ask(args, "Device hostname (short form, e.g. 'foo')", + ret = pmb.helpers.cli.ask(args, + "Device hostname (short form, e.g. 'foo')", None, (args.hostname or device), True) if not pmb.helpers.other.validate_hostname(ret): continue @@ -422,7 +429,8 @@ def ask_for_ssh_keys(args): if not len(glob.glob(os.path.expanduser("~/.ssh/id_*.pub"))): return False return pmb.helpers.cli.confirm(args, - "Would you like to copy your SSH public keys to the device?", + "Would you like to copy your SSH public" + " keys to the device?", default=args.ssh_keys) @@ -514,7 +522,8 @@ def frontend(args): cfg["pmbootstrap"]["aports"] = args.aports # Build outdated packages in pmbootstrap install - cfg["pmbootstrap"]["build_pkgs_on_install"] = str(ask_build_pkgs_on_install(args)) + cfg["pmbootstrap"]["build_pkgs_on_install"] = str( + ask_build_pkgs_on_install(args)) # Save config pmb.config.save(args, cfg) @@ -522,7 +531,9 @@ def frontend(args): # Zap existing chroots if (work_exists and device_exists and len(glob.glob(args.work + "/chroot_*")) and - pmb.helpers.cli.confirm(args, "Zap existing chroots to apply configuration?", default=True)): + pmb.helpers.cli.confirm( + args, "Zap existing chroots to apply configuration?", + default=True)): setattr(args, "deviceinfo", pmb.parse.deviceinfo(args, device=device)) # Do not zap any existing packages or cache_http directories diff --git a/pmb/config/load.py b/pmb/config/load.py index 9f3a09c8..c64a1c2b 100644 --- a/pmb/config/load.py +++ b/pmb/config/load.py @@ -20,12 +20,13 @@ def load(args): # We used to save default values in the config, which can *not* be # configured in "pmbootstrap init". That doesn't make sense, we always - # want to use the defaults from pmb/config/__init__.py in that case, not - # some outdated version we saved some time back (eg. aports folder, + # want to use the defaults from pmb/config/__init__.py in that case, + # not some outdated version we saved some time back (eg. aports folder, # postmarketOS binary packages mirror). if key not in pmb.config.config_keys and key in cfg["pmbootstrap"]: - logging.debug("Ignored unconfigurable and possibly outdated default" - " value from config: " + str(cfg["pmbootstrap"][key])) + logging.debug("Ignored unconfigurable and possibly outdated" + " default value from config:" + f" {cfg['pmbootstrap'][key]}") del cfg["pmbootstrap"][key] return cfg diff --git a/pmb/config/merge_with_args.py b/pmb/config/merge_with_args.py index 86d5daef..5b8cbcff 100644 --- a/pmb/config/merge_with_args.py +++ b/pmb/config/merge_with_args.py @@ -6,7 +6,8 @@ import pmb.config def merge_with_args(args): """ We have the internal config (pmb/config/__init__.py) and the user config - (usually ~/.config/pmbootstrap.cfg, can be changed with the '-c' parameter). + (usually ~/.config/pmbootstrap.cfg, can be changed with the '-c' + parameter). Args holds the variables parsed from the commandline (e.g. -j fills out args.jobs), and values specified on the commandline count the most.