From 275a53e545619753b547bba882b3bffd82f668f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 21 Apr 2017 02:47:23 +0200 Subject: [PATCH] Make pylint happy --- qubesmgmt/base.py | 2 +- qubesmgmt/storage.py | 13 +++++-------- qubesmgmt/tools/__init__.py | 9 ++++----- qubesmgmt/tools/qvm_ls.py | 3 +-- qubesmgmt/tools/qvm_run.py | 2 +- qubesmgmt/tools/qvm_volume.py | 2 +- qubesmgmt/utils.py | 12 ++++-------- 7 files changed, 17 insertions(+), 26 deletions(-) diff --git a/qubesmgmt/base.py b/qubesmgmt/base.py index daf13f5..2c4a32a 100644 --- a/qubesmgmt/base.py +++ b/qubesmgmt/base.py @@ -70,7 +70,7 @@ class PropertyHolder(object): raise appropriate exception. ''' - if len(response_data) == 0: + if response_data == b'': raise qubesmgmt.exc.QubesDaemonNoResponseError( 'Got empty response from qubesd') diff --git a/qubesmgmt/storage.py b/qubesmgmt/storage.py index dbc7e31..2cf20d2 100644 --- a/qubesmgmt/storage.py +++ b/qubesmgmt/storage.py @@ -90,18 +90,16 @@ class Volume(object): '''Storage volume pool name.''' if self._pool is not None: return self._pool - else: - self._fetch_info() - return str(self._info['pool']) + self._fetch_info() + return str(self._info['pool']) @property def vid(self): '''Storage volume id, unique within given pool.''' if self._vid is not None: return self._vid - else: - self._fetch_info() - return str(self._info['vid']) + self._fetch_info() + return str(self._info['vid']) @property def size(self): @@ -142,8 +140,7 @@ class Volume(object): self._fetch_info() if self._info['source']: return self._info['source'] - else: - return None + return None @property def internal(self): diff --git a/qubesmgmt/tools/__init__.py b/qubesmgmt/tools/__init__.py index cb927fe..b0b997f 100644 --- a/qubesmgmt/tools/__init__.py +++ b/qubesmgmt/tools/__init__.py @@ -219,7 +219,7 @@ class VolumeAction(QubesAction): pool = app.pools[pool_name] volume = [v for v in pool.volumes if v.vid == vid] assert volume > 1, 'Duplicate vids in pool %s' % pool_name - if len(volume) == 0: + if not volume: parser.error_runtime( 'no volume with id {!r} pool: {!r}'.format(vid, pool_name)) @@ -348,7 +348,7 @@ class QubesArgumentParser(argparse.ArgumentParser): self.set_defaults(verbose=1, quiet=0) - def parse_args(self, *args, **kwargs): + def parse_args(self, *args, **kwargs): # pylint: disable=arguments-differ # hack for tests app = kwargs.pop('app', None) namespace = super(QubesArgumentParser, self).parse_args(*args, **kwargs) @@ -424,9 +424,8 @@ class AliasedSubParsersAction(argparse._SubParsersAction): super(AliasedSubParsersAction._AliasedPseudoAction, self).\ __init__(option_strings=[], dest=dest, help=help) - def __call__(self, **kwargs): - super(AliasedSubParsersAction._AliasedPseudoAction, self).__call__( - **kwargs) + def __call__(self, parser, namespace, values, option_string=None): + pass def add_parser(self, name, **kwargs): if 'aliases' in kwargs: diff --git a/qubesmgmt/tools/qvm_ls.py b/qubesmgmt/tools/qvm_ls.py index 61bfb08..09ba3c9 100644 --- a/qubesmgmt/tools/qvm_ls.py +++ b/qubesmgmt/tools/qvm_ls.py @@ -228,8 +228,7 @@ class StatusColumn(Column): if ret is not None: if getattr(vm, 'hvm', False): return ret.upper() - else: - return ret + return ret @flag(2) diff --git a/qubesmgmt/tools/qvm_run.py b/qubesmgmt/tools/qvm_run.py index 429f888..103a78b 100644 --- a/qubesmgmt/tools/qvm_run.py +++ b/qubesmgmt/tools/qvm_run.py @@ -149,7 +149,7 @@ def main(args=None, app=None): if not args.autostart and not vm.is_running(): continue try: - log.info('Running {!r} on {!s}'.format(args.cmd, vm.name)) + log.info('Running \'%s\' on %s', args.cmd, vm.name) if args.passio and not args.localcmd: loop = asyncio.new_event_loop() loop.add_signal_handler(signal.SIGCHLD, loop.stop) diff --git a/qubesmgmt/tools/qvm_volume.py b/qubesmgmt/tools/qvm_volume.py index 98c14a5..2920d3b 100644 --- a/qubesmgmt/tools/qvm_volume.py +++ b/qubesmgmt/tools/qvm_volume.py @@ -72,7 +72,7 @@ class VolumeData(object): def __init__(self, volume): self.pool = volume.pool self.vid = volume.vid - if len(volume.revisions) > 0: + if volume.revisions: self.revisions = 'Yes' else: self.revisions = 'No' diff --git a/qubesmgmt/utils.py b/qubesmgmt/utils.py index 06d065e..984aa31 100644 --- a/qubesmgmt/utils.py +++ b/qubesmgmt/utils.py @@ -81,24 +81,21 @@ def mbytes_to_kmg(size): '''Convert mbytes to human readable format.''' if size > 1024: return "%d GiB" % (size / 1024) - else: - return "%d MiB" % size + return "%d MiB" % size def kbytes_to_kmg(size): '''Convert kbytes to human readable format.''' if size > 1024: return mbytes_to_kmg(size / 1024) - else: - return "%d KiB" % size + return "%d KiB" % size def bytes_to_kmg(size): '''Convert bytes to human readable format.''' if size > 1024: return kbytes_to_kmg(size / 1024) - else: - return "%d B" % size + return "%d B" % size def size_to_human(size): @@ -109,8 +106,7 @@ def size_to_human(size): return str(round(size / 1024.0, 1)) + ' KiB' elif size < 1024 * 1024 * 1024: return str(round(size / (1024.0 * 1024), 1)) + ' MiB' - else: - return str(round(size / (1024.0 * 1024 * 1024), 1)) + ' GiB' + return str(round(size / (1024.0 * 1024 * 1024), 1)) + ' GiB' def get_entry_point_one(group, name):