added more list compr, general py3 changes

py3_forced
idziubenko 3 years ago
parent aa3120cec2
commit 545a3a583c

@ -453,8 +453,7 @@ class Distributive(object):
raise DistributiveError(
_("Failed to mount to the directory: %s\n")
% directory + _("Directory already mounted"))
mountopts_list = filter(lambda x: x,
mountopts.split(" "))
mountopts_list = [x for x in mountopts.split(" ") if x]
mountProcess = process('/bin/mount', file, directory, *mountopts_list,
stderr=STDOUT)
if mountProcess.success():
@ -665,7 +664,7 @@ class DirectoryDistributive(Distributive):
:return:
"""
if not self.system_mounted:
for obj in filter(lambda x: x['name'] not in skip, self.data):
for obj in (x for x in self.data if x['name'] not in skip):
target_path = path.join(self.directory, obj['target'])
if obj['type'] == 'bind':
if not path.exists(target_path):
@ -787,10 +786,8 @@ class MultiPartitions:
"""Add partition in data partition list"""
dictDataPart = reduce(lambda x, y: \
x.update({y: getattr(DataPartition, y)}) or x,
filter(lambda x: not x.startswith('_'),
DataPartition.__dict__), {})
updateAttrData = filter(lambda x: x[1] is not None,
dictDataPart.items())
[x for x in DataPartition.__dict__ if not x.startswith('_')], {})
updateAttrData = (x for x in dictDataPart.items() if x[1] is not None)
defaultAttr = []
for attrName, attrValue in updateAttrData:
if not attrName in argv.keys():
@ -801,14 +798,13 @@ class MultiPartitions:
if notFoundAttr:
raise DistributiveError(_("The following attributes "
"are not specified: (%s)") \
% ", ".join(
map(lambda x: "DataPartition.%s" % x, notFoundAttr)))
% ", ".join(("DataPartition.%s" % x for x in notFoundAttr)))
unnecessaryAttr = (set(dictDataPart.keys()) ^ set(argv.keys())) - \
set(dictDataPart.keys())
if unnecessaryAttr:
raise DistributiveError(_("Failed to use attributes (%s) ") \
% ", ".join(
map(lambda x: "DataPartition.%s" % x, unnecessaryAttr)))
("DataPartition.%s" % x for x in unnecessaryAttr)))
else:
partObj = DataPartition()
for attr, value in argv.items():
@ -1125,8 +1121,7 @@ class PartitionDistributive(Distributive):
mapOpts.get(self.fileSystem,""))
dirObj = DirectoryDistributive(mdirectory, parent=self)
if self.multipartition:
mulipartDataNotBind = filter(lambda x: x[2] != "bind",
self.getMultipartData())
mulipartDataNotBind = (x for x in self.getMultipartData() if x[2] != "bind")
for dev, mountPoint, fileSystem, isFormat, partTable \
in sorted(mulipartDataNotBind, key=lambda x: x[1]):
realMountPoint = None
@ -1206,8 +1201,7 @@ class PartitionDistributive(Distributive):
raise DistributiveError(
_("The specified format of '%s' is not supported") % format)
with open("/proc/swaps") as f:
if dev in map(lambda y: y.split(" ")[0],
filter(lambda x: x.startswith("/"),f)):
if dev in (x.split(" ")[0] for x in f if x.startswith("/")):
raise DistributiveError(
_("Failed to format %s: this partition is used as swap") % dev)
self._checkMount(dev)
@ -1284,8 +1278,7 @@ class PartitionDistributive(Distributive):
def formatSwapPartition(self, dev):
"""Format swap partition"""
with open("/proc/swaps") as f:
if dev in map(lambda y: y.split(" ")[0],
filter(lambda x: x.startswith("/"),f)):
if dev in (x.split(" ")[0] for x in f if x.startswith("/")):
raise DistributiveError(
_("Failed to execute 'mkswap %s': "
"the swap partition is used "

@ -80,10 +80,8 @@ class Install(MethodsInterface):
def canInstallGrub2(self, target):
"""Check that system has grub2 in current and installed system"""
if self.clVars.Get('os_grub2_path'):
return bool(
filter(lambda x: (x.startswith('grub-1.99') or
x.startswith('grub-2')),
listDirectory('/var/db/pkg/sys-boot')))
return bool([x for x in listDirectory('/var/db/pkg/sys-boot')
if (x.startswith('grub-1.99') or x.startswith('grub-2'))])
return False
def prepareBoot(self, target_distr):
@ -289,9 +287,9 @@ class Install(MethodsInterface):
# если GRUB2 версии 2.00 и выше, обычная установка требует
# параметра --target=i386-pc, иначе GRUB2 может попытаться
# прописать себя как UEFI
if filter(lambda x: "2." in x,
process(*traverse([chrooting,
cmd_grub_install, '--version']))):
if [x for x
in process(*traverse([chrooting, cmd_grub_install, '--version']))
if "2." in x]:
platform = ["--target=i386-pc"]
else:
platform = []
@ -659,10 +657,10 @@ class Install(MethodsInterface):
"""
target_dir = target.getDirectory()
source_dir = source.getDirectory()
for f in filter(lambda x: x.endswith('.clt'),
chain(*map(lambda x: find(pathJoin(source_dir, x),
filetype="f"),
cltpath))):
for f in (x for x
in chain(*[find(pathJoin(source_dir, y), filetype="f") for y
in cltpath])
if x.endswith('.clt')):
copyWithPath(f, target_dir, prefix=source_dir)
return True
@ -674,10 +672,10 @@ class Install(MethodsInterface):
"/root/.ssh/(id_.*|known_hosts))")
target_dir = target.getDirectory()
source_dir = source.getDirectory()
for f in filter(file_mask.search,
chain(*map(lambda x: find(pathJoin(source_dir, x),
filetype="f"),
["/etc", "/root/.ssh"]))):
for f in (x for x
in chain(*(find(pathJoin(source_dir, y), filetype="f") for y
in ["/etc", "/root/.ssh"]))
if file_mask.search(x)):
copyWithPath(f, target_dir, prefix=source_dir)
return True

@ -36,9 +36,10 @@ class _shareData(object):
def getDataInFile(self, fileName='', lenData=7):
"""Get data list from file"""
with open(fileName) as f:
return map(lambda x: x[:lenData],
filter(lambda x: len(x) >= lenData,
map(lambda x: x.rstrip().split(":"), f)))
return [x[:lenData] for x
in (y.rstrip().split(":") for y
in f)
if len(x) >= lenData]
class migrateGroups(_shareData):
@ -58,46 +59,39 @@ class migrateGroups(_shareData):
def getThisData(self):
"""Get data migrate groups in this system"""
return filter(lambda x: \
self._reNumb.match(x[2]) and self.minGid <= int(
x[2]) <= self.maxGid,
self.getData())
return [x for x in self.getData()
if self._reNumb.match(x[2]) and self.minGid <= int(x[2]) <= self.maxGid]
def getNewData(self):
"""Get data migrate groups in new system"""
fileName = pathJoin(self.prefixNewSystem, self.fileGroups)
return filter(lambda x: \
self._reNumb.match(x[2]) and self.minGid <= int(
x[2]) <= self.maxGid,
self.getData(fileName=fileName))
return [x for x in self.getData(fileName=fileName)
if self._reNumb.match(x[2]) and self.minGid <= int(x[2]) <= self.maxGid]
def getNewDataSystemGroups(self):
"""Get data system groups in new system"""
fileName = pathJoin(self.prefixNewSystem, self.fileGroups)
return filter(lambda x: \
self._reNumb.match(x[2]) and \
(int(x[2]) > self.maxGid or int(x[2]) < self.minGid),
self.getData(fileName=fileName))
return [x for x in self.getData(fileName=fileName)
if self._reNumb.match(x[2]) and (int(x[2]) > self.maxGid or int(x[2]) < self.minGid)]
def getNewProcessedData(self):
"""Get processed data migrate groups in new system"""
# data this Group no users
dataThisGroupsNoUsers = map(lambda x: x[:3] + [""], self.getThisData())
dataThisGroupsNoUsers = [x[:3] + [""] for x in self.getThisData()]
dataNewGroups = self.getNewData()
namesNewGroups = map(lambda x: x[0], dataNewGroups)
gidsNewGroups = map(lambda x: x[2], dataNewGroups)
namesNewGroups = [x[0] for x in dataNewGroups]
gidsNewGroups = [x[2] for x in dataNewGroups]
for data in dataThisGroupsNoUsers:
nameGroup = data[0]
gid = data[2]
if nameGroup in namesNewGroups:
dataNewGroups = filter(lambda x: x[0] != nameGroup,
dataNewGroups)
namesNewGroups = map(lambda x: x[0], dataNewGroups)
gidsNewGroups = map(lambda x: x[2], dataNewGroups)
dataNewGroups = [x for x in dataNewGroups if x[0] != nameGroup]
namesNewGroups = [x[0] for x in dataNewGroups]
gidsNewGroups = [x[2] for x in dataNewGroups]
if gid in gidsNewGroups:
dataNewGroups = filter(lambda x: x[2] != gid, dataNewGroups)
namesNewGroups = map(lambda x: x[0], dataNewGroups)
gidsNewGroups = map(lambda x: x[2], dataNewGroups)
dataNewGroups = [x for x in dataNewGroups if x[2] != gid]
namesNewGroups = [x[0] for x in dataNewGroups]
gidsNewGroups = [x[2] for x in dataNewGroups]
systemGroupsNewData = self.getNewDataSystemGroups()
return systemGroupsNewData, dataNewGroups, dataThisGroupsNoUsers
@ -119,81 +113,67 @@ class migrateUsers(_shareData):
def getThisData(self):
"""Get data migrate users in this system"""
return filter(lambda x: \
self._reNumb.match(x[2]) and self.minId <= int(
x[2]) <= self.maxId,
self.getData())
return [x for x in self.getData()
if self._reNumb.match(x[2]) and self.minId <= int(x[2]) <= self.maxId]
def getNewData(self):
"""Get data migrate users in new system"""
fileName = pathJoin(self.prefixNewSystem, self.filePasswd)
return filter(lambda x: \
self._reNumb.match(x[2]) and self.minId <= int(
x[2]) <= self.maxId,
self.getData(fileName=fileName))
return [x for x in self.getData(fileName=fileName)
if self._reNumb.match(x[2]) and self.minId <= int(x[2]) <= self.maxId]
def getNewDataSystemUsers(self):
"""Get data system users in new system"""
fileName = pathJoin(self.prefixNewSystem, self.filePasswd)
return filter(lambda x: \
self._reNumb.match(x[2]) and \
(int(x[2] > self.maxId) or int(x[2]) < self.minId),
self.getData(fileName=fileName))
return [x for x in self.getData(fileName=fileName)
if self._reNumb.match(x[2]) and (int(x[2] > self.maxId) or int(x[2]) < self.minId)]
def getThisDataSystemUsers(self):
"""Get data system users in this system"""
fileName = self.filePasswd
return filter(lambda x: \
self._reNumb.match(x[2]) and \
(int(x[2] > self.maxId) or int(x[2]) < self.minId),
self.getData(fileName=fileName))
return [x for x in self.getData(fileName=fileName)
if self._reNumb.match(x[2]) and (int(x[2] > self.maxId) or int(x[2]) < self.minId)]
def getNewProcessedData(self, migrateUsers=()):
"""Get processed data migrate users in new system"""
dataThisUsers = self.getThisData()
if migrateUsers:
dataThisUsers = filter(lambda x: x[0] in migrateUsers,
dataThisUsers)
dataThisUsers = [x for x in dataThisUsers if x[0] in migrateUsers]
dataNewUsers = self.getNewData()
namesNewUsers = map(lambda x: x[0], dataNewUsers)
uidsNewUsers = map(lambda x: x[2], dataNewUsers)
namesNewUsers = [x[0] for x in dataNewUsers]
uidsNewUsers = [x[2] for x in dataNewUsers]
for data in dataThisUsers:
nameUser = data[0]
uid = data[2]
if nameUser in namesNewUsers:
dataNewUsers = filter(lambda x: x[0] != nameUser, dataNewUsers)
namesNewUsers = map(lambda x: x[0], dataNewUsers)
uidsNewUsers = map(lambda x: x[2], dataNewUsers)
dataNewUsers = [x for x in dataNewUsers if x[0] != nameUser]
namesNewUsers = [x[0] for x in dataNewUsers]
uidsNewUsers = [x[2] for x in dataNewUsers]
if uid in uidsNewUsers:
dataNewUsers = filter(lambda x: x[2] != uid, dataNewUsers)
namesNewUsers = map(lambda x: x[0], dataNewUsers)
uidsNewUsers = map(lambda x: x[2], dataNewUsers)
dataNewUsers = [x for x in dataNewUsers if x[2] != uid]
namesNewUsers = [x[0] for x in dataNewUsers]
uidsNewUsers = [x[2] for x in dataNewUsers]
systemUsersNewData = self.getNewDataSystemUsers()
systemUsersNewNames = map(lambda x: x[0], systemUsersNewData)
systemUsersNewUids = map(lambda x: x[2], systemUsersNewData)
systemUsersNewNames = [x[0] for x in systemUsersNewData]
systemUsersNewUids = [x[2] for x in systemUsersNewData]
systemUsersThisData = []
if migrateUsers:
# this users < minId
systemUsersThisData = filter(lambda x: int(x[2]) < self.minId and \
x[0] in migrateUsers,
self.getThisDataSystemUsers())
systemUsersThisData = [x for x in self.getThisDataSystemUsers()
if int(x[2]) < self.minId and x[0] in migrateUsers]
for data in systemUsersThisData:
nameUser = data[0]
uid = data[2]
if nameUser in systemUsersNewNames:
systemUsersNewData = filter(lambda x: x[0] != nameUser,
systemUsersNewData)
systemUsersNewNames = map(lambda x: x[0],
systemUsersNewData)
systemUsersNewUids = map(lambda x: x[2],
systemUsersNewData)
systemUsersNewData = [x for x in systemUsersNewData
if x[0] != nameUser]
systemUsersNewNames = [x[0] for x in systemUsersNewData]
systemUsersNewUids = [x[2] for x in systemUsersNewData]
if uid in systemUsersNewUids:
systemUsersNewData = filter(lambda x: x[2] != uid,
systemUsersNewData)
systemUsersNewNames = map(lambda x: x[0],
systemUsersNewData)
systemUsersNewUids = map(lambda x: x[2],
systemUsersNewData)
systemUsersNewData = [x for x in systemUsersNewData
if x[2] != uid]
systemUsersNewNames = [x[0] for x in systemUsersNewData]
systemUsersNewUids = [x[2] for x in systemUsersNewData]
return (systemUsersThisData, systemUsersNewData,
dataNewUsers, dataThisUsers)
@ -219,43 +199,43 @@ class migrateShadow(_shareData):
def getThisData(self):
"""Get data migrate users in this system"""
return filter(lambda x: x[0] in self.thisMigrateUsers, self.getData())
return [x for x in self.getData()
if x[0] in self.thisMigrateUsers]
def getNewData(self):
"""Get data migrate users in new system"""
return filter(lambda x: x[0] in self.newMigrateUsers,
self.getData(fileName=self.newFileName))
return [x for x in self.getData(fileName=self.newFileName)
if x[0] in self.newMigrateUsers]
def getNewDataSystemShadow(self):
"""Get data system users in new system"""
return filter(lambda x: x[0] in self.sysNewMigrateUsers,
self.getData(fileName=self.newFileName))
return [x for x in self.getData(fileName=self.newFileName)
if x[0] in self.sysNewMigrateUsers]
def getThisDataSystemShadow(self):
"""Get data system users in this system"""
return filter(lambda x: x[0] in self.sysThisMigrateUsers,
self.getData())
return [x for x in self.getData() if x[0] in self.sysThisMigrateUsers]
def getNewProcessedData(self):
"""Get processed data migrate shadow in new system"""
dataThisShadow = self.getThisData()
dataNewShadow = self.getNewData()
namesNewShadow = map(lambda x: x[0], dataNewShadow)
namesNewShadow = [x[0] for x in dataNewShadow]
for data in dataThisShadow:
nameUser = data[0]
if nameUser in namesNewShadow:
dataNewShadow = filter(lambda x: x[0] != nameUser,
dataNewShadow)
namesNewShadow = map(lambda x: x[0], dataNewShadow)
dataNewShadow = [x for x in dataNewShadow if x[0] != nameUser]
namesNewShadow = [x[0] for x in dataNewShadow]
systemShadowNewData = self.getNewDataSystemShadow()
systemShadowThisData = self.getThisDataSystemShadow()
systemShadowNewNames = map(lambda x: x[0], systemShadowNewData)
systemShadowNewNames = [x[0] for x in systemShadowNewData]
for data in systemShadowThisData:
nameUser = data[0]
if nameUser in systemShadowNewNames:
systemShadowNewData = filter(lambda x: x[0] != nameUser,
systemShadowNewData)
systemShadowNewNames = map(lambda x: x[0], systemShadowNewData)
systemShadowNewData = [x for x
in systemShadowNewData if x[0] != nameUser]
systemShadowNewNames = [x[0] for x in systemShadowNewData]
return (systemShadowThisData, systemShadowNewData, dataNewShadow,
dataThisShadow)
@ -285,14 +265,12 @@ class migrate(object):
def addThisUsersToGroups(self, users):
"""Add users to groups"""
thisGroupsData = self.objGroups.getData()
thisGroupsData = map(lambda x: (x[0], x[3].split(',')),
thisGroupsData)
thisGroupsData = [(x[0], x[3].split(',')) for x in thisGroupsData]
dataGroups = []
for data in self.dataGroups:
groupName = data[0]
thisUsersInGroup = map(lambda x: x[1],
filter(lambda x: x[0] == groupName,
thisGroupsData))
thisUsersInGroup = [x[1] for x in thisGroupsData if x[0] == groupName]
#??? whats the point of this?
thisUsersInGroup = reduce(lambda x, y: x + y, thisUsersInGroup, [])
addUsers = list(set(thisUsersInGroup) & set(users))
if addUsers:
@ -300,36 +278,30 @@ class migrate(object):
for user in addUsers:
if not user in newUsersInGroup:
newUsersInGroup.append(user)
data[3] = ','.join(filter(lambda x: x, newUsersInGroup))
data[3] = ','.join((x for x in newUsersInGroup if x))
dataGroups.append(data)
self.dataGroups = dataGroups
return self.dataGroups
def getNextUid(self):
"""get next uid"""
listUid = map(lambda x: int(x[2]),
filter(lambda x: \
self.objUsers._reNumb.match(x[2]) and \
self.minId <= int(x[2]) <= self.maxId,
self.dataUsers))
listUid = [int(x[2]) for x in self.dataUsers
if self.objUsers._reNumb.match(x[2]) and self.minId <= int(x[2]) <= self.maxId]
if listUid:
return max(listUid) + 1
return self.minId
def getNextGid(self):
"""get next gid"""
listGid = map(lambda x: int(x[2]),
filter(lambda x: \
self.objGroups._reNumb.match(x[2]) and \
self.minGid <= int(x[2]) <= self.maxGid,
self.dataGroups))
listGid = [int(x[2]) for x in self.dataGroups
if self.objUsers._reNumb.match(x[2]) and self.minGid <= int(x[2]) <= self.maxGid]
if listGid:
return max(listGid) + 1
return self.minGid
def isSystemUser(self, userName):
if filter(lambda x: x[0] == userName and int(x[2]) <= self.minSysId,
self.dataUsers):
if [x for x in self.dataUsers
if (x[0] == userName and int(x[2]) <= self.minSysId)]:
return True
return False
@ -343,7 +315,7 @@ class migrate(object):
usersInGroup = data[3].split(',')
if not userName in usersInGroup:
usersInGroup.append(userName)
data[3] = ','.join(filter(lambda x: x, usersInGroup))
data[3] = ','.join((x for x in usersInGroup if x))
dataGroups.append(data)
self.dataGroups = dataGroups
return self.dataGroups
@ -353,7 +325,7 @@ class migrate(object):
return self.addUserToGroups(userName, self.newUserGroups)
def changePassword(self, userName, pwdHash, maxDays="99999", warnDays="7"):
if not filter(lambda x: x[0] == userName, self.dataUsers):
if not [x for x in self.dataUsers if x[0] == userName]:
raise MigrationError(_("User %s not found") % userName)
indexFoundUser = False
for i, data in enumerate(self.dataShadow):
@ -380,14 +352,14 @@ class migrate(object):
def addUser(self, userName, userGroups, pwdHash):
"""Add user"""
# find user
if filter(lambda x: x[0] == userName, self.dataUsers):
if [x for x in self.dataUsers if x[0] == userName]:
return "EXISTS"
else:
strUid = str(self.getNextUid())
strGid = str(self.getNextGid())
groupName = userName
dataExistGroup = filter(lambda x: x[0] == groupName,
self.dataGroups)
dataExistGroup = [x for x in self.dataGroups
if x[0] == groupName]
if dataExistGroup:
strGid = dataExistGroup[0][2]
else:
@ -412,27 +384,25 @@ class migrate(object):
"""Check permission files"""
checkThisFiles = [migrateGroups.fileGroups, migrateUsers.filePasswd,
migrateShadow.fileShadow]
checkNewFiles = map(lambda x: pathJoin(self.prefixNewSystem, x),
checkThisFiles)
checkNewFiles = [pathJoin(self.prefixNewSystem, x) for x in checkThisFiles]
parentDir = lambda x: "".join(os.path.split(x)[:-1])
notRead = lambda x: not os.access(x, os.R_OK)
notWrite = lambda x: not os.access(x, os.W_OK)
filesNotRead = filter(notRead, checkThisFiles)
filesNotRead = [x for x in checkThisFiles if notRead(x)]
if filesNotRead:
raise MigrationError(_("Failed to read files") + _(": ") +
", ".join(filesNotRead))
filesNotWrite = filter(notWrite, checkNewFiles)
filesNotWrite = [x for x in checkNewFiles if notWrite(x)]
if filesNotWrite:
raise MigrationError(_("Failed to write to files") + _(": ") +
", ".join(filesNotWrite))
# Check permissions backup files
checkNewBackupFiles = map(
lambda x: pathJoin(self.prefixNewSystem, x + "-"),
checkThisFiles)
checkNewBackupFiles = (pathJoin(self.prefixNewSystem, x + "-") for x
in checkThisFiles)
notWriteBackup = lambda x: not os.access(x, os.W_OK) and \
(os.path.exists(x) or
not os.access(os.path.dirname(x), os.W_OK))
filesNotWrite = filter(notWriteBackup, checkNewBackupFiles)
filesNotWrite = [x for x in checkNewBackupFiles if notWriteBackup(x)]
if filesNotWrite:
raise MigrationError(_("Failed to write to files") + _(": ") +
", ".join(filesNotWrite))
@ -443,20 +413,20 @@ class migrate(object):
listFilesThisSystem = [migrateGroups.fileGroups,
migrateUsers.filePasswd,
migrateShadow.fileShadow]
listFiles = map(lambda x: (pathJoin(self.prefixNewSystem, x),
pathJoin(self.prefixNewSystem, x + "-")),
listFilesThisSystem)
listFiles = [(pathJoin(self.prefixNewSystem, x),
pathJoin(self.prefixNewSystem, x + "-")) for x
in listFilesThisSystem]
listData = [self.dataGroups, self.dataUsers, self.dataShadow]
allData = zip(listFiles, listData)
for fileNames, data in allData:
buff = "\n".join(map(lambda x: ":".join(x), data)) + "\n"
buff = "\n".join((":".join(x) for x in data)) + "\n"
for fileName in fileNames:
FD = open(fileName, "w+")
FD.write(buff)
FD.close()
def createUserGuest(self):
if filter(lambda x: int(x[2]) >= self.minSysId, self.dataUsers):
if [x for x in self.dataUsers if int(x[2]) >= self.minSysId]:
return True
else:
# add user guest
@ -482,7 +452,7 @@ class migrate(object):
os.chmod(homedir, perms)
users = list(set([x[0] for x in addUsersList] + existsMigrateUsers) - {"root"})
try:
map(createHome, filter(lambda x: x[0] in users, self.dataUsers))
map(createHome, (x for x in self.dataUsers if x[0] in users))
except Exception as e:
raise MigrationError(
_("Failed to create the user's home directory"))
@ -500,8 +470,9 @@ class migrate(object):
existsMigrateUsers = []
if not self.checkPermFiles():
return False
migrateUsers = (["root"] +
map(lambda x: x[0], addUsersList + pwdUsersList))
migrateUsers = (["root"] + [x[0] for x in addUsersList + pwdUsersList])
for existMigrUser in existsMigrateUsers:
if existMigrUser not in migrateUsers:
migrateUsers.append(existMigrUser)
@ -509,7 +480,7 @@ class migrate(object):
dataUsers = self.objUsers.getNewProcessedData(migrateUsers)
dataGroups = self.objGroups.getNewProcessedData()
thisSystemUsers, newSystemUsers, newUsers, thisUsers = \
map(lambda x: map(lambda y: y[0], x), dataUsers)
[[y[0] for y in x] for x in dataUsers]
objShadow = migrateShadow(thisSystemUsers, newSystemUsers, newUsers,
thisUsers, self.prefixNewSystem)
dataShadow = objShadow.getNewProcessedData()
@ -572,7 +543,5 @@ class currentUsers(migrate):
if not self.checkPermFiles():
return False
getDataInFile = _shareData().getDataInFile
self.dataUsers = map(lambda x: x[0],
getDataInFile(fileName=migrateUsers.filePasswd,
lenData=7))
self.dataUsers = [x[0] for x in getDataInFile(fileName=migrateUsers.filePasswd,lenData=7)]
return set(self.dataUsers) >= set(users)

@ -248,7 +248,7 @@ class VariableOsInstallX11VideoDrv(VideoVariable):
return drv
return self.default_video
else:
for drv in map(lambda x: x[0], self.choice()):
for drv in (x[0] for x in self.choice()):
refcnt = device.sysfs.read(
device.sysfs.Path.Module, drv, "refcnt").strip()
if refcnt.isdigit() and int(refcnt) > 0:

@ -88,11 +88,12 @@ class VariableOsAudioAvailable(Variable):
with image as distr:
try:
distrPath = image.getDirectory()
return [x[0::2] for x in mapAudioConf if not x[1] or isPkgInstalled(x[1], prefix=distrPath)]
return [x[0::2] for x
in mapAudioConf
if not x[1] or isPkgInstalled(x[1], prefix=distrPath)]
except DistributiveError as e:
pass
return sorted(map(lambda x: x[0::2], mapAudioConf[-1:]),
key=lambda x: x[1])
return sorted((x[0::2] for x in mapAudioConf[-1:]), key=lambda x: x[1])
class VariableOsAudioCardMap(ReadonlyVariable):

@ -50,7 +50,7 @@ class DeviceHelper(VariableInterface):
def getBlockDevices(self):
"""Get interest devices from sys block path"""
return list(filter(self.rePassDevice.search, device.udev.get_block_devices()))
return [x for x in device.udev.get_block_devices() if self.rePassDevice.search(x)]
def separateDevice(self, dev):
"""
@ -218,14 +218,13 @@ class VariableOsDeviceType(ReadonlyVariable):
# get usb device by '/dev/disk/by-id'(usb devices contain 'usb' in name)
diskIdPath = '/dev/disk/by-id'
if device.devfs.exists(diskIdPath):
self.usbdevices = \
map(lambda x: \
device.devfs.realpath(diskIdPath, x).rpartition('/')[2],
filter(lambda x: x.startswith('usb-'),
device.devfs.listdir(diskIdPath, fullpath=False)))
self.usbdevices = [device.devfs.realpath(diskIdPath, x).rpartition('/')[2] for x
in device.devfs.listdir(diskIdPath, fullpath=False)
if x.startswith('usb-')]
else:
self.usbdevices = []
return list(map(self.getType, self.Get('os_device_dev')))
return [self.getType(x) for x in self.Get('os_device_dev')]
class VariableOsDeviceParent(ReadonlyVariable):
@ -434,7 +433,7 @@ class VariableOsDeviceTable(ReadonlyVariable):
else:
return getTable(dev)
return list(map(getByAutopartition, self.Get('os_device_dev')))
return [getByAutopartition(x) for x in self.Get('os_device_dev')]
@ -465,7 +464,7 @@ class VariableOsDeviceName(ReadonlyVariable):
return ""
def get(self):
return list(map(self.getName, self.Get('os_device_dev')))
return [self.getName(x) for x in self.Get('os_device_dev')]
class VariableOsDeviceSize(ReadonlyVariable):
@ -479,7 +478,7 @@ class VariableOsDeviceSize(ReadonlyVariable):
return [getPartitionSize(name=x, inBytes=True) for x in self.Get('os_device_dev')]
def humanReadable(self):
return list(map(humanreadableSize, self.Get()))
return [humanreadableSize(x) for x in self.Get()]
#############################################
@ -523,7 +522,7 @@ class VariableOsDiskDev(DeviceHelper, ReadonlyVariable):
return list(sorted((x for x in dev_names), key=self.separateDevice))
def humanReadable(self):
return list(map(self.getPerfectName, self.Get()))
return [self.getPerfectName(x) for x in self.Get()]
class VariableOsDiskMount(DeviceHelper, ReadonlyVariable):
@ -577,7 +576,7 @@ class VariableOsDiskFormat(ReadonlyVariable):
pass
return fs
return list(map(getFormat, self.Get('os_disk_dev')))
return [getFormat(x) for x in self.Get('os_disk_dev')]
class VariableOsDiskType(ReadonlyVariable):
@ -653,7 +652,7 @@ class VariableOsDiskLvm(DeviceHelper, ReadonlyVariable):
def get(self):
"""Get each element from var through udev [prop]"""
return list(map(self.getLvmName, self.Get('os_disk_dev')))
return [self.getLvmName(x) for x in self.Get('os_disk_dev')]
class VariableOsDiskUuid(DeviceHelper, ReadonlyVariable):
@ -732,10 +731,10 @@ class VariableOsDiskGrub(ReadonlyVariable):
else:
return ""
return list(map(getGrubMap,
zip(self.Get('os_disk_dev'),
self.Get('os_disk_type'),
self.Get('os_disk_parent'))))
return [getGrubMap(x) for x
in zip(self.Get('os_disk_dev'),
self.Get('os_disk_type'),
self.Get('os_disk_parent'))]
class VariableOsDiskPart(ReadonlyVariable):
@ -768,7 +767,7 @@ class VariableOsDiskSize(ReadonlyVariable):
return [getPartitionSize(name=x, inBytes=True) for x in self.Get('os_disk_dev')]
def humanReadable(self):
return list(map(humanreadableSize, self.Get()))
return [humanreadableSize(x) for x in self.Get()]
class VariableOsDiskName(DeviceHelper, ReadonlyVariable):
@ -794,8 +793,7 @@ class VariableOsDiskOptions(ReadonlyVariable):
def getFormat(dev):
return fstab.getBy(what=fstab.OPTS, eq=dev)
return list(map(getFormat, self.Get('os_disk_dev')))
return [getFormat(x) for x in self.Get('os_disk_dev')]
################################################
# Bind mount points
@ -1018,7 +1016,7 @@ class VariableOsLocationSource(LocationHelper, DeviceHelper, Variable):
return path.normpath(val)
return val
return list(map(normpath, value))
return [normpath(x) for x in value]
def choice(self):
return [(x, self.getPerfectName(x) or x) for x
@ -1057,14 +1055,14 @@ class VariableOsLocationSource(LocationHelper, DeviceHelper, Variable):
###########################
# check wrong dev
###########################
disks = filter(lambda x: x.startswith('/dev/'), value)
disks = [x for x in value if x.startswith('/dev/')]
# get original /dev names
cnDisks = (device.udev.get_device_info(name=x).get('DEVNAME', x)
for x in disks)
wrongDevices = list(set(cnDisks) - set(self.fixOsDiskDev()))
if wrongDevices:
raise VariableError(_("Wrong device '%s'") % wrongDevices[0])
wrongSource = filter(lambda x: x and not x.startswith('/'), value)
wrongSource = [x for x in value if x and not x.startswith('/')]
if wrongSource:
raise VariableError(
_("Wrong bind mount point '%s'") % wrongSource[0])
@ -1149,10 +1147,8 @@ class VariableOsLocationDest(LocationHelper, Variable):
osInstallRootType = self.Get('os_install_root_type')
if osInstallRootType != "flash" and \
not "/usr" in value:
for mp, size in filter(lambda x: x[0] == '/' and x[1].isdigit() and \
int(x[1]) < minroot,
zip(value,
self.Get("os_location_size"))):
for mp, size in (x for x in zip(value, self.Get("os_location_size"))
if x[0] == '/' and x[1].isdigit() and int(x[1]) < minroot):
raise VariableError(
_("The root partition should be at least %s") % "7 Gb")
source = self.Get("os_location_source")
@ -1190,9 +1186,9 @@ class VariableOsLocationDest(LocationHelper, Variable):
#########################
# detect wrong bind
#########################
wrongBind = filter(lambda x: not x[0].startswith("/") or
not x[1].startswith("/"),
binds)
wrongBind = [x for x in binds
if not x[0].startswith("/") or
not x[1].startswith("/")]
if wrongBind:
raise VariableError(
_("Incorrect mount point (bind '%(bindSrc)s' to "
@ -1202,8 +1198,8 @@ class VariableOsLocationDest(LocationHelper, Variable):
#########################################
# Check '/' in start path of dest pointst
#########################################
wrongMP = filter(lambda x: x and not x.startswith("/") and x != "swap",
value)
wrongMP = [x for x in value
if x and not x.startswith("/") and x != "swap"]
if wrongMP:
raise VariableError(_("Wrong mount point '%s'") % wrongMP[0])
#########################################
@ -1237,8 +1233,8 @@ class VariableOsLocationDest(LocationHelper, Variable):
# check cross bind mount points
###############################
DEVICE, MP = 0, 1
srcMountPoints = map(lambda x: x[DEVICE], binds)
destMountPoints = map(lambda x: x[MP], binds)
srcMountPoints = (x[DEVICE] for x in binds)
destMountPoints = (x[MP] for x in binds)
wrongBind = [x for x in srcMountPoints if x in destMountPoints]
if wrongBind:
incompBind = [x for x in zip(srcMountPoints, destMountPoints) if x[1] == wrongBind[0]]
@ -1253,10 +1249,10 @@ class VariableOsLocationDest(LocationHelper, Variable):
#######################################
osInstallRootType = self.Get('os_install_root_type')
if osInstallRootType == "flash":
if filter(lambda x: x and x != '/', value):
if [x for x in value if x and x != '/']:
raise VariableError(
_("Flash install does not support multipartition mode"))
if filter(lambda x: x == "swap", value):
if [x for x in value if x == "swap"]:
raise VariableError(
_("Flash install does not support swap disks"))
########################################
@ -1288,7 +1284,7 @@ class VariableOsLocationFormat(LocationHelper, Variable):
mount = self.Get("os_location_dest")
source = self.Get("os_location_source")
value = [""] * len(source)
return list(map(self.defaultFormat(), zip(source, mount, value)))
return [self.defaultFormat()(x) for x in zip(source, mount, value)]
def choice(self):
if self.Get('cl_install_type') == "flash":
@ -1346,10 +1342,10 @@ class VariableOsLocationFormat(LocationHelper, Variable):
return wrap
def set(self, value):
value = map(lambda x: "vfat" if x == "uefi" else x, value)
value = ["vfat" if x == "uefi" else x for x in value]
mount = self.Get("os_location_dest")
source = self.Get("os_location_source")
return list(map(self.defaultFormat(), zip(source, mount, value)))
return [self.defaultFormat()(x) for x in zip(source, mount, value)]
def check(self, value):
osInstallRootType = self.Get('os_install_root_type')
@ -1394,7 +1390,7 @@ class VariableOsLocationPerformFormat(LocationHelper, Variable):
source = self.Get("os_location_source")
fs = self.Get("os_location_format")
value = [""] * len(source)
return list(map(self.defaultPerformFormat(), zip(source, mount, fs, value)))
return [self.defaultPerformFormat()(x) for x in zip(source, mount, fs, value)]
fixNtfs = lambda self, x: {'ntfs-3g': 'ntfs'}.get(x, x)
@ -1837,7 +1833,7 @@ class VariableOsInstallDiskName(Variable):
else:
return diskLabel.get(dev, '')
return list(map(changeLabel, self.ZipVars('os_install_disk_dev','os_install_disk_mount')))
return [changeLabel(x) for x in self.ZipVars('os_install_disk_dev','os_install_disk_mount')]
class VariableOsInstallDiskSize(SourceReadonlyVariable):
@ -2164,8 +2160,7 @@ class VariableOsInstallMbr(LocationHelper, Variable):
return self.Get('cl_autopartition_mbr')
if self.Get('os_install_root_type') in ("flash", "usb-hdd"):
rootdev = self.Get('os_install_root_dev')
device = filter(lambda x: x in rootdev,
self.Get('os_device_dev'))
device = [x for x in self.Get('os_device_dev') if x in rootdev]
if device:
return [device[0]]
else:
@ -2390,9 +2385,8 @@ class VariableOsInstallFstabMountConf(DeviceHelper, ReadonlyVariable):
bindData = self.ZipVars('os_install_bind_path',
'os_install_bind_mountpoint')
bindLines = "\n".join(map(lambda x: "%s\t%s\tnone\tbind\t0 0" \
% (x[0], x[1]), bindData))
return "\n".join(filter(lambda x: x, [rootLine, otherLines, bindLines]))
bindLines = "\n".join(("%s\t%s\tnone\tbind\t0 0" % (x[0], x[1]) for x in bindData))
return "\n".join((x for x in [rootLine, otherLines, bindLines] if x))
class VariableOsInstallFstabEfiConf(VariableOsInstallFstabMountConf):
@ -2419,7 +2413,7 @@ class VariableOsInstallFstabEfiConf(VariableOsInstallFstabMountConf):
for used, mp, fs, opts, dev in devicesForFstab
)
return "\n".join(filter(lambda x: x, [efiLines]))
return "\n".join((x for x in [efiLines] if x))
class VariableOsInstallFstabSwapConf(VariableOsInstallFstabMountConf):
@ -2428,13 +2422,12 @@ class VariableOsInstallFstabSwapConf(VariableOsInstallFstabMountConf):
"""
def get(self):
return "\n".join(map(lambda x: "%s\tnone\tswap\tsw\t0 0" % \
self._commentFstab(x[0], "swap", x[2]),
self.Select(['os_install_disk_use',
'os_install_disk_mount',
'os_install_disk_dev'],
where='os_install_disk_mount',
eq='swap')))
return "\n".join(("%s\tnone\tswap\tsw\t0 0" % self._commentFstab(x[0], "swap", x[2]) for x
in self.Select(['os_install_disk_use',
'os_install_disk_mount',
'os_install_disk_dev'],
where='os_install_disk_mount',
eq='swap')))
class VariableClInstallType(Variable):

@ -93,9 +93,9 @@ class DistroRepository(Linux):
def _getAvailableShortnames(self, dirs):
"""Get available distributives shortnames"""
distros = filter(lambda x: x,
map(self.reDistName.search,
self._getAvailableDistributives(dirs)))
distros = [x for x
in map(self.reDistName.search, self._getAvailableDistributives(dirs))
if x]
return sorted(list(set([x.groupdict()['name'] for x in distros])))
def opcompareByString(self, buf):
if buf:
@ -163,9 +163,7 @@ class DistroRepository(Linux):
return [x for x in listDirectory(pathname) if not path.isdir(path.join(pathname, x))]
# get lists files in directories
allFiles = map(lambda x: map(lambda y: path.join(x, y),
listdistr(x)),
dirs)
allFiles = [[path.join(x, y) for y in listdistr(x)] for x in dirs]
# filter distributives
# join files lists to one list
return [x for x in reduce(lambda x, y: x + y, allFiles, []) if distfilter(x)]
@ -377,9 +375,7 @@ class VariableClImageFilename(DistroRepository, Variable):
discardType=discardType)
if self.wasSet and not self.value in distros:
distros.append(self.value)
return sorted(map(lambda x: (
x, self.humanImageName(self._getDistrInfo(x), x)), distros),
key=itemgetter(1))
return sorted(((x, self.humanImageName(self._getDistrInfo(x), x)) for x in distros), key=itemgetter(1))
class VariableClImageArchMachine(DistroRepository, Variable):
@ -494,7 +490,7 @@ class VariableClImagePath(ReadonlyVariable):
livedistr = ['/run/initramfs/squashfs',
'/run/initramfs/live',
'/mnt/cdrom']
livedistr = list(filter(listDirectory, livedistr))[:1]
livedistr = [x for x in livedistr if listDirectory(x)][:1]
else:
livedistr = []
# search all partition for source installation distributive
@ -503,8 +499,8 @@ class VariableClImagePath(ReadonlyVariable):
in zip(self.Get('os_disk_dev'), self.Get('os_disk_content'))
if " live" in x[1] and x[0] != rootDev]
# add to standard path
return list(filter(path.exists, ['/var/calculate/remote/linux',
'/var/calculate/linux'] + livedistr))
return [x for x in ['/var/calculate/remote/linux',
'/var/calculate/linux'] + livedistr if path.exists(x)]
class VariableClSource(ReadonlyVariable):

@ -77,7 +77,7 @@ class VariableOsInstallKernelScheduler(Variable):
else:
currentScheduler = getValueFromCmdLine(
CmdlineParams.IOScheduler)
if currentScheduler in map(lambda x: x[0], self.choice()):
if currentScheduler in (x[0] for x in self.choice()):
return currentScheduler
return self.Get('os_install_kernel_schedule_default')
@ -336,11 +336,9 @@ class KernelHelper(VariableInterface):
def getFilesByType(self, pathname, descr):
"""Get files from "pathname" has "descr" in descriptions"""
filelist = map(lambda x: path.join(pathname, x), os.listdir(pathname))
filelist = [path.join(pathname, x) for x in os.listdir(pathname)]
ftype = typeFile(magic=MAGIC_COMPRESS | MAGIC_SYMLINK).getMType
filesWithType = map(lambda x: (x, ftype(x)),
filter(path.exists,
filelist))
filesWithType = [(x, ftype(x)) for x in filelist if path.exists(x)]
return [x for x in filesWithType if x[1] and descr in x[1]]
def getInitrdFiles(self, pathname):

@ -68,11 +68,8 @@ class VariableOsInstallLinguas(LocaleVariable):
# get linguas from make.conf, emerge --info or default
curlanguage = self.Get('os_install_locale_language')
return get_linguas(readLinesFile(makeconf)) or \
" ".join(filter(lambda x: x == "en" or x == curlanguage,
get_linguas(
process(
*infocommand).readlines() or "").split())) or \
defaultLinguas
" ".join((x for x in get_linguas(process(*infocommand).readlines() or "").split() if x == "en" or x == curlanguage)) or defaultLinguas
class VariableOsInstallLocaleConsolefont(LocaleVariable):

@ -188,8 +188,7 @@ class VariableOsNetInterfacesInfo(NetHelper, ReadonlyVariable):
else:
listInterfacesInfo.append((interface,
ipaddr if ipaddr else _("Off")))
return ", ".join(map(lambda x: "%s (%s)" % (x[0], x[1]),
listInterfacesInfo))
return ", ".join(("%s (%s)" % (x[0], x[1]) for x in listInterfacesInfo))
class VariableOsInstallNetData(NetHelper, TableVariable):
@ -334,7 +333,7 @@ class VariableOsInstallNetMacType(NetHelper, ReadonlyVariable):
return "local"
def get(self):
return list(map(self._mactype, self.Get('os_install_net_mac')))
return [self._mactype(x) for x in self.Get('os_install_net_mac')]
class VariableOsInstallNetMac(NetHelper, ReadonlyVariable):
@ -360,7 +359,7 @@ class VariableOsInstallNetStatus(NetHelper, Variable):
self.label = _("IP address")
def get(self):
return list(map(self.getDefaultValue, self.Get('os_install_net_interfaces')))
return [self.getDefaultValue(x) for x in self.Get('os_install_net_interfaces')]
def getDefaultValue(self, iface):
def statusValue(ipaddr, dhcp):
@ -383,15 +382,14 @@ class VariableOsInstallNetStatus(NetHelper, Variable):
if rootDevNfs or isDhcpIp(iface) else "off")
def set(self, value):
value = map(lambda x: x.lower() if x else x, value)
value = (x.lower() if x else x for x in value)
ifaces = self.Get('os_install_net_interfaces')
return [self.getDefaultValue(x[1]) if x[0] == "auto" else x[0] for x
in zip(value, ifaces)]
def check(self, value):
for status in value:
if status not in map(lambda x: x[0], self.choice()) and \
not checkIp(status):
if status not in (x[0] for x in self.choice()) and not checkIp(status):
raise VariableError(_("Wrong IP address %s") % status)
def choice(self):
@ -479,7 +477,7 @@ class VariableOsInstallNetMask(NetHelper, Variable):
else:
return x
res = map(convertCidrToMask, value)
res = [convertCidrToMask(x) for x in value]
return res
def check(self, value):
@ -617,9 +615,9 @@ class VariableOsInstallNetRouteGw(NetHelper, FieldValue, Variable):
NET, GW = 0, 1
netsGw = zip(self.Get('os_install_net_route_network'),
value)
nets = filter(lambda x: x and x != "default",
chain(self.Get('os_install_net_route_network'),
self.Get('os_install_net_network')))
nets = [x for x in chain(self.Get('os_install_net_route_network'),
self.Get('os_install_net_network'))
if x and x != "default"]
for wrongip in filterfalse(ip.checkIp, value):
raise VariableError(_("Wrong gateway IP %s") % wrongip)
@ -703,10 +701,11 @@ class VariableOsInstallNetRoute(NetHelper, ReadonlyVariable):
NET, GW, DEV, SRC = 0, 1, 2, 3
# filter by interface and discard direct routes
# example: for 192.168.1.5/24 discard 192.168.1.0/24 net
route_list = filter(lambda x: (interface == x[DEV] or defaultDev and
interface == defaultDev) \
and net != x[NET], routeMatrix)
route_list = [x for x in routeMatrix
if (interface == x[DEV] or
defaultDev and
interface == defaultDev) and
net != x[NET]]
nets = []
route_list_uniqnet = []
for net, gw, dev, src in route_list:
@ -714,10 +713,9 @@ class VariableOsInstallNetRoute(NetHelper, ReadonlyVariable):
route_list_uniqnet.append([net, gw, dev, src])
nets.append(net)
route_strs = map(lambda x: "{net}{gateway}{src}".format(
net=x[NET],
gateway=" via %s" % x[GW] if x[GW] else "",
src=" src %s" % x[SRC] if x[SRC] else ""), route_list_uniqnet)
route_strs = ("{net}{gateway}{src}".format(net=x[NET], gateway=" via %s" % x[GW]
if x[GW] else "", src=" src %s" % x[SRC] if x[SRC] else "") for x
in route_list_uniqnet)
# build string for route from net,gateway,dev and src
return "\n".join(route_strs)
@ -743,25 +741,40 @@ class VariableOsInstallNetNmroute(VariableOsInstallNetRoute):
NET, GW, DEV, SRC = 0, 1, 2, 3
defaultGw = ["%s;" % x[GW] for x in routeMatrix
if interface == x[DEV] and x[NET] == "default"]
return "{0}\n".format(defaultGw[0] if defaultGw else "") + \
"\n".join(
# build string for route from net,gateway,dev and src
map(lambda
x: "routes{num}={ip};{cidr};{gateway};0;".format(
# return "{0}\n".format(defaultGw[0] if defaultGw else "") + \
# "\n".join(
# # build string for route from net,gateway,dev and src
# map(lambda
# x: "routes{num}={ip};{cidr};{gateway};0;".format(
# num=x[0] + 1,
# ip=x[1][NET].partition('/')[0],
# cidr=x[1][NET].partition('/')[2],
# gateway=x[1][GW] if x[1][GW] else "0.0.0.0"),
# # filter by interface and discard direct routes
# # example: for 192.168.1.5/24 discard 192.168.1.0/24 net
# enumerate(
# filter(lambda x: (interface == x[
# DEV] or defaultDev and
# interface == defaultDev) and net !=
# x[
# NET] and \
# x[NET] != "default",
# routeMatrix))))
return "{0}\n".format(defaultGw[0] if defaultGw else "") + "\n".join(
# build string for route from net,gateway,dev and src
("routes{num}={ip};{cidr};{gateway};0;".format(
num=x[0] + 1,
ip=x[1][NET].partition('/')[0],
cidr=x[1][NET].partition('/')[2],
gateway=x[1][GW] if x[1][GW] else "0.0.0.0"),
# filter by interface and discard direct routes
# example: for 192.168.1.5/24 discard 192.168.1.0/24 net
enumerate(
filter(lambda x: (interface == x[
DEV] or defaultDev and
interface == defaultDev) and net !=
x[
NET] and \
x[NET] != "default",
routeMatrix))))
gateway=x[1][GW] if x[1][GW] else "0.0.0.0") for x
# filter by interface and discard direct routes
# example: for 192.168.1.5/24 discard 192.168.1.0/24 net
in enumerate((x for x in routeMatrix
if (interface == x[DEV] or
defaultDev and
interface == defaultDev) and
net !=x[NET] and
x[NET] != "default"))))
return self.performRouteData(getRouteForInterfaceNM)
@ -846,10 +859,9 @@ class VariableOsInstallNetDnsSearch(NetHelper, Variable):
def get(self):
"""Get current name servers"""
dnsSearch = " ".join(
map(lambda x: x.strip().partition("search")[2].strip(),
filter(lambda x: x.lstrip().startswith("search"),
readLinesFile('/etc/resolv.conf'))))
dnsSearch = " ".join((x.strip().partition("search")[2].strip() for x
in readLinesFile('/etc/resolv.conf')
if x.lstrip().startswith("search")))
return "" if self.isDNSByDHCP() else dnsSearch
def humanReadable(self):
@ -873,12 +885,11 @@ class VariableOsInstallNetDns(VariableOsInstallNetDnsSearch):
return " ".join(re.split(r'[; ,]', value))
def get(self):
dnsIps = filter(ip.checkIp,
map(lambda x: x.strip().partition("nameserver")[
2].strip(),
filter(
lambda x: x.lstrip().startswith("nameserver"),
readLinesFile('/etc/resolv.conf'))))
dnsIps = (x for x
in (y.strip().partition("nameserver")[2].strip() for y
in readLinesFile('/etc/resolv.conf')
if y.lstrip().startswith("nameserver"))
if ip.checkIp(x))
return "" if self.isDNSByDHCP() else " ".join(dnsIps)
def check(self, value):
@ -924,4 +935,4 @@ class VariableOsInstallPxeIp(Variable):
def choice(self):
ips = self.Get('os_net_ip').split(',')
return list(filter(None, ips))
return [x for x in ips if x]

@ -141,7 +141,7 @@ class VariableOsFormatUse(ReadonlyVariable):
return "no"
def get(self):
return list(map(self.checkFunc, self.Get('os_format_type')))
return [self.checkFunc(x) for x in self.Get('os_format_type')]
class VariableClMigrateRootPwdPlain(GrubHelper, UserHelper, Variable):

Loading…
Cancel
Save