diff --git a/bootstrapvz/base/fs/partitionmaps/gpt.py b/bootstrapvz/base/fs/partitionmaps/gpt.py index 1dbd943..89f5f9f 100644 --- a/bootstrapvz/base/fs/partitionmaps/gpt.py +++ b/bootstrapvz/base/fs/partitionmaps/gpt.py @@ -21,7 +21,7 @@ class GPTPartitionMap(AbstractPartitionMap): # Returns the last partition unless there is none def last_partition(): - return self.partitions[-1] if len(self.partitions) > 0 else None + return self.partitions[-1] if self.partitions else None if bootloader == 'grub': # If we are using the grub bootloader we need to create an unformatted partition diff --git a/bootstrapvz/base/fs/partitionmaps/msdos.py b/bootstrapvz/base/fs/partitionmaps/msdos.py index ebc04cc..2e80d92 100644 --- a/bootstrapvz/base/fs/partitionmaps/msdos.py +++ b/bootstrapvz/base/fs/partitionmaps/msdos.py @@ -23,7 +23,7 @@ class MSDOSPartitionMap(AbstractPartitionMap): # Returns the last partition unless there is none def last_partition(): - return self.partitions[-1] if len(self.partitions) > 0 else None + return self.partitions[-1] if self.partitions else None # The boot and swap partitions are optional if 'boot' in data: diff --git a/bootstrapvz/base/pkg/sourceslist.py b/bootstrapvz/base/pkg/sourceslist.py index 2539611..2a68f19 100644 --- a/bootstrapvz/base/pkg/sourceslist.py +++ b/bootstrapvz/base/pkg/sourceslist.py @@ -82,11 +82,11 @@ class Source(object): :rtype: str """ options = '' - if len(self.options) > 0: + if self.options: options = ' [{options}]'.format(options=' '.join(self.options)) components = '' - if len(self.components) > 0: + if self.components: components = ' {components}'.format(components=' '.join(self.components)) return ('{type}{options} {uri} {distribution}{components}' diff --git a/bootstrapvz/common/fsm_proxy.py b/bootstrapvz/common/fsm_proxy.py index 5db4036..6a44d4b 100644 --- a/bootstrapvz/common/fsm_proxy.py +++ b/bootstrapvz/common/fsm_proxy.py @@ -34,7 +34,7 @@ class FSMProxy(object): fn = getattr(fsm, event) def proxy(*args, **kwargs): - if len(args) > 0: + if args: raise FSMProxyError('FSMProxy event listeners only accept named arguments.') fn(**kwargs) return proxy diff --git a/bootstrapvz/common/tasks/bootstrap.py b/bootstrapvz/common/tasks/bootstrap.py index 6a79a04..436450e 100644 --- a/bootstrapvz/common/tasks/bootstrap.py +++ b/bootstrapvz/common/tasks/bootstrap.py @@ -34,9 +34,9 @@ def get_bootstrap_args(info): else: from bootstrapvz.common.exceptions import ManifestError raise ManifestError('force-check-gpg is only support in Stretch and newer releases') - if len(info.include_packages) > 0: + if info.include_packages: options.append('--include=' + ','.join(info.include_packages)) - if len(info.exclude_packages) > 0: + if info.exclude_packages: options.append('--exclude=' + ','.join(info.exclude_packages)) mirror = info.manifest.bootstrapper.get('mirror', info.apt_mirror) arguments = [info.manifest.system['release'], info.root, mirror] diff --git a/bootstrapvz/common/tasks/grub.py b/bootstrapvz/common/tasks/grub.py index edf03f5..a0281ea 100644 --- a/bootstrapvz/common/tasks/grub.py +++ b/bootstrapvz/common/tasks/grub.py @@ -211,7 +211,7 @@ class WriteGrubConfig(Task): elif isinstance(value, bool): grub_config_contents += '{}="{}"\n'.format(key, str(value).lower()) elif isinstance(value, list): - if len(value) > 0: + if value: args_list = ' '.join(map(str, value)) grub_config_contents += '{}="{}"\n'.format(key, args_list) elif value is not None: diff --git a/bootstrapvz/common/tasks/host.py b/bootstrapvz/common/tasks/host.py index 7238ad1..8285b81 100644 --- a/bootstrapvz/common/tasks/host.py +++ b/bootstrapvz/common/tasks/host.py @@ -30,6 +30,6 @@ class CheckExternalCommands(Task): 'it is located in the package `{package}\'.' .format(command=command, package=package)) missing_packages.append(msg) - if len(missing_packages) > 0: + if missing_packages: msg = '\n'.join(missing_packages) raise TaskError(msg) diff --git a/bootstrapvz/plugins/cloud_init/__init__.py b/bootstrapvz/plugins/cloud_init/__init__.py index 5567251..7e7f714 100644 --- a/bootstrapvz/plugins/cloud_init/__init__.py +++ b/bootstrapvz/plugins/cloud_init/__init__.py @@ -30,7 +30,7 @@ def resolve_tasks(taskset, manifest): options = manifest.plugins['cloud_init'] if 'username' in options: taskset.add(tasks.SetUsername) - if 'groups' in options and len(options['groups']): + if 'groups' in options and options['groups']: taskset.add(tasks.SetGroups) if 'enable_modules' in options: taskset.add(tasks.EnableModules) diff --git a/bootstrapvz/plugins/docker_daemon/__init__.py b/bootstrapvz/plugins/docker_daemon/__init__.py index 05e5aea..4e47cde 100644 --- a/bootstrapvz/plugins/docker_daemon/__init__.py +++ b/bootstrapvz/plugins/docker_daemon/__init__.py @@ -23,5 +23,5 @@ def resolve_tasks(taskset, manifest): taskset.add(tasks.AddDockerBinary) taskset.add(tasks.AddDockerInit) taskset.add(tasks.EnableMemoryCgroup) - if len(manifest.plugins['docker_daemon'].get('pull_images', [])) > 0: + if manifest.plugins['docker_daemon'].get('pull_images', []): taskset.add(tasks.PullDockerImages)