In many cases generators can be used instead of constructing temporary lists.
Some functions even support the generator expresions passed directly as
arguments.
Signed-off-by: Vratislav Podzimek <vpodzime(a)redhat.com>
---
pyanaconda/anaconda_optparse.py | 2 +-
pyanaconda/bootloader.py | 2 +-
pyanaconda/network.py | 2 +-
pyanaconda/packaging/__init__.py | 2 +-
pyanaconda/packaging/yumpayload.py | 2 +-
pyanaconda/ui/gui/spokes/custom.py | 8 ++++----
pyanaconda/ui/gui/spokes/network.py | 4 ++--
pyanaconda/ui/gui/spokes/user.py | 4 ++--
pyanaconda/ui/tui/simpleline/base.py | 2 +-
9 files changed, 14 insertions(+), 14 deletions(-)
diff --git a/pyanaconda/anaconda_optparse.py b/pyanaconda/anaconda_optparse.py
index ccb0361..37f4b86 100644
--- a/pyanaconda/anaconda_optparse.py
+++ b/pyanaconda/anaconda_optparse.py
@@ -57,7 +57,7 @@ class AnacondaOptionParser(OptionParser):
bootargs = [a for a in args if not a.startswith('-')]
do_bootarg = kwargs.pop("bootarg", True)
option = OptionParser.add_option(self, *flags, **kwargs)
- bootargs += [flag[2:] for flag in option._long_opts]
+ bootargs += (flag[2:] for flag in option._long_opts)
if do_bootarg:
for b in bootargs:
if b in self._boot_arg:
diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py
index a802ca8..b7694dc 100644
--- a/pyanaconda/bootloader.py
+++ b/pyanaconda/bootloader.py
@@ -1084,7 +1084,7 @@ class GRUB(BootLoader):
salt_chars = string.letters + string.digits + './'
rand_gen = random.SystemRandom()
- salt += "".join([rand_gen.choice(salt_chars) for i in
range(salt_len)])
+ salt += "".join(rand_gen.choice(salt_chars) for i in range(salt_len))
self.encrypted_password = crypt.crypt(self.password, salt)
def write_config_password(self, config):
diff --git a/pyanaconda/network.py b/pyanaconda/network.py
index 626e2c0..27da1bf 100644
--- a/pyanaconda/network.py
+++ b/pyanaconda/network.py
@@ -268,7 +268,7 @@ class NetworkDevice(IfcfgFile):
def set(self, *args):
# If we are changing value of a key set _dirty flag
# informing that ifcfg file needs to be synced.
- s = " ".join(["%s=%s" % key_val for key_val in args])
+ s = " ".join("%s=%s" % key_val for key_val in args)
ifcfglog.debug("NetworkDevice %s set: %s" %
(self.iface, s))
for (key, data) in args:
diff --git a/pyanaconda/packaging/__init__.py b/pyanaconda/packaging/__init__.py
index cba0f79..1904a3e 100644
--- a/pyanaconda/packaging/__init__.py
+++ b/pyanaconda/packaging/__init__.py
@@ -163,7 +163,7 @@ class Payload(object):
urls.extend(repo.mirrorlist)
network_protocols = ["http:", "ftp:", "nfs:",
"nfsiso:"]
for url in urls:
- if any([url.startswith(p) for p in network_protocols]):
+ if any(url.startswith(p) for p in network_protocols):
return True
return False
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index fe132f7..bce5051 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -354,7 +354,7 @@ reposdir=%s
# trigger setup of self._yum.config
log.debug("installation yum config repos: %s"
- % ",".join([r.id for r in self._yum.repos.listEnabled()]))
+ % ",".join(r.id for r in self._yum.repos.listEnabled()))
# YUMFIXME: there should be a way to reset package sacks without all this
# knowledge of the yum internals or, better yet, some convenience
diff --git a/pyanaconda/ui/gui/spokes/custom.py b/pyanaconda/ui/gui/spokes/custom.py
index 3e19707..7deecb1 100644
--- a/pyanaconda/ui/gui/spokes/custom.py
+++ b/pyanaconda/ui/gui/spokes/custom.py
@@ -1456,7 +1456,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
encryptCheckbox.set_sensitive(self._reformatCheckbox.get_active())
ancestors = use_dev.ancestors
ancestors.remove(use_dev)
- if any([a.format.type == "luks" and a.format.exists for a in
ancestors]):
+ if any(a.format.type == "luks" and a.format.exists for a in
ancestors):
# The encryption checkbutton should not be sensitive if there is
# existing encryption below the leaf layer.
encryptCheckbox.set_sensitive(False)
@@ -1606,9 +1606,9 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
def on_finish_clicked(self, button):
self._save_right_side(self._current_selector)
- new_luks = any([d for d in self.__storage.devices
+ new_luks = any(d for d in self.__storage.devices
if d.format.type == "luks" and
- not d.format.exists])
+ not d.format.exists)
if new_luks:
dialog = PassphraseDialog(self.data)
with enlightbox(self.window, dialog.window):
@@ -2181,7 +2181,7 @@ class CustomPartitioningSpoke(NormalSpoke, StorageChecker):
ancestors = device.ancestors
ancestors.remove(device)
- if any([a.format.type == "luks" and a.format.exists for a in
ancestors]):
+ if any(a.format.type == "luks" and a.format.exists for a in
ancestors):
# The encryption checkbutton should not be sensitive if there is
# existing encryption below the leaf layer.
encryption_checkbutton.set_sensitive(False)
diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index 8fee6c3..2046987 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -694,8 +694,8 @@ class NetworkControlBox(object):
addr = socket.inet_ntoa(struct.pack('=L',
ipv4cfg.get_addresses()[0].get_address()))
self._set_device_info_value(dt, "ipv4", addr)
- dnss = " ".join([socket.inet_ntoa(struct.pack('=L', addr))
- for addr in ipv4cfg.get_nameservers()])
+ dnss = " ".join(socket.inet_ntoa(struct.pack('=L', addr))
+ for addr in ipv4cfg.get_nameservers())
self._set_device_info_value(dt, "dns", dnss)
gateway = socket.inet_ntoa(struct.pack('=L',
ipv4cfg.get_addresses()[0].get_gateway()))
diff --git a/pyanaconda/ui/gui/spokes/user.py b/pyanaconda/ui/gui/spokes/user.py
index af39856..66d1232 100644
--- a/pyanaconda/ui/gui/spokes/user.py
+++ b/pyanaconda/ui/gui/spokes/user.py
@@ -264,8 +264,8 @@ class UserSpoke(FirstbootSpokeMixIn, NormalSpoke):
self._wheel.name in self._user.groups:
self._user.groups.remove(self._wheel.name)
- self.data.group.groupList += [self._groupDict[g] for g in self._user.groups
- if g != self._wheel.name]
+ self.data.group.groupList += (self._groupDict[g] for g in self._user.groups
+ if g != self._wheel.name)
if self._user not in self.data.user.userList:
self.data.user.userList.append(self._user)
diff --git a/pyanaconda/ui/tui/simpleline/base.py b/pyanaconda/ui/tui/simpleline/base.py
index 131a54a..df1f6f0 100644
--- a/pyanaconda/ui/tui/simpleline/base.py
+++ b/pyanaconda/ui/tui/simpleline/base.py
@@ -602,7 +602,7 @@ class Widget(object):
def __unicode__(self):
"""Method to render the screen when printing as unicode
string."""
- return u"\n".join([u"".join(l) for l in self._buffer])
+ return u"\n".join(u"".join(l) for l in self._buffer)
def setxy(self, row, col):
"""Sets cursor position.
--
1.7.11.7