Fix pylint warning no-else-return
This commit is contained in:
parent
eb217e0d27
commit
5bc7a8f9e3
@ -269,7 +269,7 @@ class DeviceCollection(object):
|
|||||||
if dev:
|
if dev:
|
||||||
assert len(dev) == 1
|
assert len(dev) == 1
|
||||||
return dev[0]
|
return dev[0]
|
||||||
else:
|
|
||||||
return UnknownDevice(self._vm, ident)
|
return UnknownDevice(self._vm, ident)
|
||||||
|
|
||||||
|
|
||||||
|
@ -406,7 +406,6 @@ class Firewall(object):
|
|||||||
def _translate_action(key):
|
def _translate_action(key):
|
||||||
if xml_root.get(key, policy_v1) == 'allow':
|
if xml_root.get(key, policy_v1) == 'allow':
|
||||||
return Action.accept
|
return Action.accept
|
||||||
else:
|
|
||||||
return Action.drop
|
return Action.drop
|
||||||
|
|
||||||
self.rules.append(Rule(None,
|
self.rules.append(Rule(None,
|
||||||
|
@ -55,7 +55,7 @@ class Element(object):
|
|||||||
if wrap:
|
if wrap:
|
||||||
return ''.join(self.schema.wrapper.fill(p) + '\n\n'
|
return ''.join(self.schema.wrapper.fill(p) + '\n\n'
|
||||||
for p in textwrap.dedent(xml.text.strip('\n')).split('\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())
|
||||||
|
|
||||||
|
|
||||||
|
@ -460,7 +460,7 @@ class Storage(object):
|
|||||||
"You need to pass a Volume or pool name as str"
|
"You need to pass a Volume or pool name as str"
|
||||||
if isinstance(volume, Volume):
|
if isinstance(volume, Volume):
|
||||||
return self.pools[volume.name]
|
return self.pools[volume.name]
|
||||||
else:
|
|
||||||
return self.vm.app.pools[volume]
|
return self.vm.app.pools[volume]
|
||||||
|
|
||||||
def commit(self):
|
def commit(self):
|
||||||
@ -490,7 +490,7 @@ class Storage(object):
|
|||||||
"You need to pass a Volume or pool name as str"
|
"You need to pass a Volume or pool name as str"
|
||||||
if isinstance(volume, Volume):
|
if isinstance(volume, Volume):
|
||||||
return self.pools[volume.name].export(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])
|
||||||
|
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ class FileVolume(qubes.storage.Volume):
|
|||||||
|
|
||||||
if not os.path.exists(old_revision):
|
if not os.path.exists(old_revision):
|
||||||
return {}
|
return {}
|
||||||
else:
|
|
||||||
seconds = os.path.getctime(old_revision)
|
seconds = os.path.getctime(old_revision)
|
||||||
iso_date = qubes.storage.isodate(seconds).split('.', 1)[0]
|
iso_date = qubes.storage.isodate(seconds).split('.', 1)[0]
|
||||||
return {iso_date: old_revision}
|
return {iso_date: old_revision}
|
||||||
|
@ -401,7 +401,7 @@ class ThinVolume(qubes.storage.Volume):
|
|||||||
return qubes.storage.BlockDevice(
|
return qubes.storage.BlockDevice(
|
||||||
'/dev/' + self._vid_snap, self.name, self.script,
|
'/dev/' + self._vid_snap, self.name, self.script,
|
||||||
self.rw, self.domain, self.devtype)
|
self.rw, self.domain, self.devtype)
|
||||||
else:
|
|
||||||
return super(ThinVolume, self).block_device()
|
return super(ThinVolume, self).block_device()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -40,7 +40,6 @@ class TarSparseInfo(tarfile.TarInfo):
|
|||||||
def realsize(self):
|
def realsize(self):
|
||||||
if self.sparsemap:
|
if self.sparsemap:
|
||||||
return self.sparsemap[-1][0] + self.sparsemap[-1][1]
|
return self.sparsemap[-1][0] + self.sparsemap[-1][1]
|
||||||
else:
|
|
||||||
return self.size
|
return self.size
|
||||||
|
|
||||||
def sparse_header_chunk(self, index):
|
def sparse_header_chunk(self, index):
|
||||||
@ -49,7 +48,6 @@ class TarSparseInfo(tarfile.TarInfo):
|
|||||||
tarfile.itn(self.sparsemap[index][0], 12, tarfile.GNU_FORMAT),
|
tarfile.itn(self.sparsemap[index][0], 12, tarfile.GNU_FORMAT),
|
||||||
tarfile.itn(self.sparsemap[index][1], 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):
|
def get_gnu_header(self):
|
||||||
@ -81,7 +79,6 @@ class TarSparseInfo(tarfile.TarInfo):
|
|||||||
header_buf = super(TarSparseInfo, self).tobuf(format, encoding, errors)
|
header_buf = super(TarSparseInfo, self).tobuf(format, encoding, errors)
|
||||||
if len(self.sparsemap) > 4:
|
if len(self.sparsemap) > 4:
|
||||||
return header_buf + b''.join(self.create_ext_sparse_headers())
|
return header_buf + b''.join(self.create_ext_sparse_headers())
|
||||||
else:
|
|
||||||
return header_buf
|
return header_buf
|
||||||
|
|
||||||
def create_ext_sparse_headers(self):
|
def create_ext_sparse_headers(self):
|
||||||
|
@ -309,7 +309,7 @@ class StatusColumn(Column):
|
|||||||
if ret is not None:
|
if ret is not None:
|
||||||
if getattr(vm, 'hvm', False):
|
if getattr(vm, 'hvm', False):
|
||||||
return ret.upper()
|
return ret.upper()
|
||||||
else:
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
@ -478,7 +478,7 @@ class Table(object):
|
|||||||
'''Format single table row (all columns for one domain).'''
|
'''Format single table row (all columns for one domain).'''
|
||||||
if self.raw_data:
|
if self.raw_data:
|
||||||
return '|'.join(col.format(vm) for col in self.columns)
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,21 +111,21 @@ def parse_size(size):
|
|||||||
def mbytes_to_kmg(size):
|
def mbytes_to_kmg(size):
|
||||||
if size > 1024:
|
if size > 1024:
|
||||||
return "%d GiB" % (size / 1024)
|
return "%d GiB" % (size / 1024)
|
||||||
else:
|
|
||||||
return "%d MiB" % size
|
return "%d MiB" % size
|
||||||
|
|
||||||
|
|
||||||
def kbytes_to_kmg(size):
|
def kbytes_to_kmg(size):
|
||||||
if size > 1024:
|
if size > 1024:
|
||||||
return mbytes_to_kmg(size / 1024)
|
return mbytes_to_kmg(size / 1024)
|
||||||
else:
|
|
||||||
return "%d KiB" % size
|
return "%d KiB" % size
|
||||||
|
|
||||||
|
|
||||||
def bytes_to_kmg(size):
|
def bytes_to_kmg(size):
|
||||||
if size > 1024:
|
if size > 1024:
|
||||||
return kbytes_to_kmg(size / 1024)
|
return kbytes_to_kmg(size / 1024)
|
||||||
else:
|
|
||||||
return "%d B" % size
|
return "%d B" % size
|
||||||
|
|
||||||
|
|
||||||
@ -137,7 +137,7 @@ def size_to_human(size):
|
|||||||
return str(round(size / 1024.0, 1)) + ' KiB'
|
return str(round(size / 1024.0, 1)) + ' KiB'
|
||||||
elif size < 1024 * 1024 * 1024:
|
elif size < 1024 * 1024 * 1024:
|
||||||
return str(round(size / (1024.0 * 1024), 1)) + ' MiB'
|
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'
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ def _default_ip(self):
|
|||||||
return None
|
return None
|
||||||
if self.netvm is not None:
|
if self.netvm is not None:
|
||||||
return self.netvm.get_ip_for_vm(self) # pylint: disable=no-member
|
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)
|
||||||
|
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ class NetVMMixin(qubes.events.Emitter):
|
|||||||
'10.139.1.1',
|
'10.139.1.1',
|
||||||
'10.139.1.2',
|
'10.139.1.2',
|
||||||
)
|
)
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
|
@ -1432,9 +1432,9 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
else:
|
else:
|
||||||
if not self.is_fully_usable():
|
if not self.is_fully_usable():
|
||||||
return "Transient"
|
return "Transient"
|
||||||
else:
|
|
||||||
return "Running"
|
return "Running"
|
||||||
else:
|
|
||||||
return 'Halted'
|
return 'Halted'
|
||||||
except libvirt.libvirtError as e:
|
except libvirt.libvirtError as e:
|
||||||
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
if e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||||
@ -1614,7 +1614,7 @@ class QubesVM(qubes.vm.mix.net.NetVMMixin, qubes.vm.BaseVM):
|
|||||||
'/vm/{}/start_time'.format(self.uuid))
|
'/vm/{}/start_time'.format(self.uuid))
|
||||||
if start_time != '':
|
if start_time != '':
|
||||||
return datetime.datetime.fromtimestamp(float(start_time))
|
return datetime.datetime.fromtimestamp(float(start_time))
|
||||||
else:
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def is_outdated(self):
|
def is_outdated(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user