Fix pylint warning no-else-return

This commit is contained in:
Bahtiar `kalkin-` Gadimov 2017-04-15 20:04:38 +02:00
parent eb217e0d27
commit 5bc7a8f9e3
No known key found for this signature in database
GPG Key ID: 07799AE179ED4FD4
11 changed files with 40 additions and 44 deletions

View File

@ -269,8 +269,8 @@ class DeviceCollection(object):
if dev:
assert len(dev) == 1
return dev[0]
else:
return UnknownDevice(self._vm, ident)
return UnknownDevice(self._vm, ident)
class DeviceManager(dict):

View File

@ -406,8 +406,7 @@ class Firewall(object):
def _translate_action(key):
if xml_root.get(key, policy_v1) == 'allow':
return Action.accept
else:
return Action.drop
return Action.drop
self.rules.append(Rule(None,
action=_translate_action('dns'),

View File

@ -55,8 +55,8 @@ class Element(object):
if wrap:
return ''.join(self.schema.wrapper.fill(p) + '\n\n'
for p in textwrap.dedent(xml.text.strip('\n')).split('\n\n'))
else:
return ' '.join(xml.text.strip().split())
return ' '.join(xml.text.strip().split())
def get_data_type(self, xml=None):

View File

@ -460,8 +460,8 @@ class Storage(object):
"You need to pass a Volume or pool name as str"
if isinstance(volume, Volume):
return self.pools[volume.name]
else:
return self.vm.app.pools[volume]
return self.vm.app.pools[volume]
def commit(self):
''' Makes changes to an 'origin' volume persistent '''
@ -490,8 +490,8 @@ class Storage(object):
"You need to pass a Volume or pool name as str"
if isinstance(volume, Volume):
return self.pools[volume.name].export(volume)
else:
return self.pools[volume].export(self.vm.volumes[volume])
return self.pools[volume].export(self.vm.volumes[volume])
class Pool(object):

View File

@ -377,10 +377,10 @@ class FileVolume(qubes.storage.Volume):
if not os.path.exists(old_revision):
return {}
else:
seconds = os.path.getctime(old_revision)
iso_date = qubes.storage.isodate(seconds).split('.', 1)[0]
return {iso_date: old_revision}
seconds = os.path.getctime(old_revision)
iso_date = qubes.storage.isodate(seconds).split('.', 1)[0]
return {iso_date: old_revision}
@property
def usage(self):

View File

@ -401,8 +401,8 @@ class ThinVolume(qubes.storage.Volume):
return qubes.storage.BlockDevice(
'/dev/' + self._vid_snap, self.name, self.script,
self.rw, self.domain, self.devtype)
else:
return super(ThinVolume, self).block_device()
return super(ThinVolume, self).block_device()
@property
def usage(self): # lvm thin usage always returns at least the same usage as

View File

@ -40,8 +40,7 @@ class TarSparseInfo(tarfile.TarInfo):
def realsize(self):
if self.sparsemap:
return self.sparsemap[-1][0] + self.sparsemap[-1][1]
else:
return self.size
return self.size
def sparse_header_chunk(self, index):
if index < len(self.sparsemap):
@ -49,8 +48,7 @@ class TarSparseInfo(tarfile.TarInfo):
tarfile.itn(self.sparsemap[index][0], 12, tarfile.GNU_FORMAT),
tarfile.itn(self.sparsemap[index][1], 12, tarfile.GNU_FORMAT),
])
else:
return b'\0' * 12 * 2
return b'\0' * 12 * 2
def get_gnu_header(self):
'''Part placed in 'prefix' field of posix header'''
@ -81,8 +79,7 @@ class TarSparseInfo(tarfile.TarInfo):
header_buf = super(TarSparseInfo, self).tobuf(format, encoding, errors)
if len(self.sparsemap) > 4:
return header_buf + b''.join(self.create_ext_sparse_headers())
else:
return header_buf
return header_buf
def create_ext_sparse_headers(self):
for ext_hdr in range(4, len(self.sparsemap), 21):

View File

@ -309,8 +309,8 @@ class StatusColumn(Column):
if ret is not None:
if getattr(vm, 'hvm', False):
return ret.upper()
else:
return ret
return ret
@flag(2)
@ -478,8 +478,8 @@ class Table(object):
'''Format single table row (all columns for one domain).'''
if self.raw_data:
return '|'.join(col.format(vm) for col in self.columns)
else:
return ''.join(col.cell(vm) for col in self.columns)
return ''.join(col.cell(vm) for col in self.columns)
def write_table(self, stream=sys.stdout):

View File

@ -111,22 +111,22 @@ def parse_size(size):
def mbytes_to_kmg(size):
if size > 1024:
return "%d GiB" % (size / 1024)
else:
return "%d MiB" % size
return "%d MiB" % size
def kbytes_to_kmg(size):
if size > 1024:
return mbytes_to_kmg(size / 1024)
else:
return "%d KiB" % size
return "%d KiB" % size
def bytes_to_kmg(size):
if size > 1024:
return kbytes_to_kmg(size / 1024)
else:
return "%d B" % size
return "%d B" % size
def size_to_human(size):
@ -137,8 +137,8 @@ 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 urandom(size):

View File

@ -49,8 +49,8 @@ def _default_ip(self):
return None
if self.netvm is not None:
return self.netvm.get_ip_for_vm(self) # pylint: disable=no-member
else:
return self.get_ip_for_vm(self)
return self.get_ip_for_vm(self)
def _setter_ip(self, prop, value):
@ -173,8 +173,8 @@ class NetVMMixin(qubes.events.Emitter):
'10.139.1.1',
'10.139.1.2',
)
else:
return None
return None
def __init__(self, *args, **kwargs):
self._firewall = None

View File

@ -1432,10 +1432,10 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
else:
if not self.is_fully_usable():
return "Transient"
else:
return "Running"
else:
return 'Halted'
return "Running"
return 'Halted'
except libvirt.libvirtError as e:
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
return 'Halted'
@ -1614,8 +1614,8 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
'/vm/{}/start_time'.format(self.uuid))
if start_time != '':
return datetime.datetime.fromtimestamp(float(start_time))
else:
return None
return None
def is_outdated(self):
'''Check whether domain needs restart to update root image from \