replaced filters/maps with list comprehensions

py3_forced
idziubenko 3 years ago
parent 072415613f
commit aa3120cec2

@ -374,10 +374,10 @@ class Distributive(object):
joinFrom = partial(path.join, fromdir) joinFrom = partial(path.join, fromdir)
params = [cpCmd, "-x"] + \ params = [cpCmd, "-x"] + \
(["--no-preserve=mode,ownership"] if noperm else ["-a"]) + \ (["--no-preserve=mode,ownership"] if noperm else ["-a"]) + \
list(map(joinFrom, [joinFrom(x) for x
filterfalse(byfile or operator.not_, in filterfalse(byfile or operator.not_,
listDirectory(fromdir)))) + \ listDirectory(fromdir))] + \
[todir] [todir]
cpProcess = cpProcessProgress(*params, cpProcess = cpProcessProgress(*params,
maxfiles=filesnum, stderr=STDOUT) maxfiles=filesnum, stderr=STDOUT)
for perc in cpProcess.progress(): for perc in cpProcess.progress():
@ -386,8 +386,7 @@ class Distributive(object):
errmes = cpProcess.read() errmes = cpProcess.read()
# copy by one file # copy by one file
if byfile: if byfile:
percFiles = list(filter(byfile, percFiles = [x for x in listDirectory(fromdir) if byfile(x)]
listDirectory(fromdir)))
if len(percFiles) > 1: if len(percFiles) > 1:
maxPercOnFile = 100 / len(percFiles) maxPercOnFile = 100 / len(percFiles)
recountPerc = \ recountPerc = \
@ -441,9 +440,7 @@ class Distributive(object):
def _getLastLive(self, directory): def _getLastLive(self, directory):
"""Get last live squashfs image from directory""" """Get last live squashfs image from directory"""
squashfiles = list(filter(lambda x: x, squashfiles = [x for x in map(self.reLive.search, listDirectory(directory)) if x]
map(self.reLive.search,
listDirectory(directory))))
if squashfiles: if squashfiles:
return max(squashfiles, key=self._getSquashNum).group() return max(squashfiles, key=self._getSquashNum).group()
return None return None
@ -822,27 +819,27 @@ class MultiPartitions:
def getSystemId(self): def getSystemId(self):
"""Get systemID for change [None,82,...]""" """Get systemID for change [None,82,...]"""
return list(map(lambda x: x.systemId, self.listPartitions)) return [x.systemId for x in self.listPartitions]
def getPartitionTable(self): def getPartitionTable(self):
"""Get systemID for change [dos,gpt,...]""" """Get systemID for change [dos,gpt,...]"""
return list(map(lambda x: x.partitionTable, self.listPartitions)) return [x.partitionTable for x in self.listPartitions]
def getIsFormat(self): def getIsFormat(self):
"""Get list is format [True,...]""" """Get list is format [True,...]"""
return list(map(lambda x: x.isFormat, self.listPartitions)) return [x.isFormat for x in self.listPartitions]
def getFileSystems(self): def getFileSystems(self):
"""Get list filesystems ["reiserfs",...]""" """Get list filesystems ["reiserfs",...]"""
return list(map(lambda x: x.fileSystem, self.listPartitions)) return [x.fileSystem for x in self.listPartitions]
def getPartitions(self): def getPartitions(self):
"""Get list partition ["/dev/sda",...]""" """Get list partition ["/dev/sda",...]"""
return list(map(lambda x: x.dev, self.listPartitions)) return [x.dev for x in self.listPartitions]
def getMountPoints(self): def getMountPoints(self):
"""Get list mount point ["/boot",...]""" """Get list mount point ["/boot",...]"""
return list(map(lambda x: x.mountPoint, self.listPartitions)) return [x.mountPoint for x in self.listPartitions]
class FormatProcess(process): class FormatProcess(process):
@ -1084,8 +1081,7 @@ class PartitionDistributive(Distributive):
def postinstallMountBind(self): def postinstallMountBind(self):
"""Mount bind mount point and create mount dirs""" """Mount bind mount point and create mount dirs"""
if self.multipartition and self.DirectoryObject: if self.multipartition and self.DirectoryObject:
mulipartDataBind = list(filter(lambda x: x[2] == "bind", mulipartDataBind = [x for x in self.getMultipartData() if x[2] == "bind"]
self.getMultipartData()))
dirObj = self.DirectoryObject dirObj = self.DirectoryObject
mdirectory = dirObj.directory mdirectory = dirObj.directory
for srcDir, destDir, fileSystem, isFormat, partTable \ for srcDir, destDir, fileSystem, isFormat, partTable \
@ -1166,10 +1162,8 @@ class PartitionDistributive(Distributive):
self.multipartition.getMountPoints() + \ self.multipartition.getMountPoints() + \
["/"]) ["/"])
# get partition which need format # get partition which need format
formatPartitions = list(map(lambda x: (x[FS], x[DEV], x[NEWID], x[MP]), formatPartitions = [(x[FS], x[DEV], x[NEWID], x[MP]) for x
filter( in dataPartitions if x[NEEDFORMAT] and x[FS] != "bind"]
lambda x: x[NEEDFORMAT] and x[FS] != "bind",
dataPartitions)))
# if has separate /boot partition # if has separate /boot partition
bootmp = ["/boot", "/"] bootmp = ["/boot", "/"]
purpose_map = {"/boot": "boot", purpose_map = {"/boot": "boot",
@ -1194,9 +1188,8 @@ class PartitionDistributive(Distributive):
self.formatPartition(dev, format=fileSystem, self.formatPartition(dev, format=fileSystem,
purpose=purpose_map.get(mp, None)) purpose=purpose_map.get(mp, None))
# change system id for partitions # change system id for partitions
changeidPartitions = list(map(lambda x: (x[NEWID], x[DEV], x[PARTTABLE]), changeidPartitions = [(x[NEWID], x[DEV], x[PARTTABLE]) for x
filter(lambda x: x[NEWID], in dataPartitions if x[NEWID]]
dataPartitions)))
for systemid, dev, partTable in changeidPartitions: for systemid, dev, partTable in changeidPartitions:
self.changeSystemID(dev, systemid, partTable) self.changeSystemID(dev, systemid, partTable)
return True return True
@ -1495,7 +1488,7 @@ class ContainerDistributive(ArchiveDistributive):
if self.exclude: if self.exclude:
exclude_list = list(calculate_exclude( exclude_list = list(calculate_exclude(
directory, exclude=self.exclude, include=self.include)) directory, exclude=self.exclude, include=self.include))
params += list(map(lambda x: "--exclude=./%s" % x, exclude_list)) params += ["--exclude=./%s" % x for x in exclude_list]
params += ["."] params += ["."]
#debug_file = "/var/calculate/tmp/rootfs.tar.xz" #debug_file = "/var/calculate/tmp/rootfs.tar.xz"
@ -1880,7 +1873,7 @@ class FlashDistributive(PartitionDistributive):
clear_match = re.compile( clear_match = re.compile(
r"^(boot|efi|isolinux|syslinux|id.*\.uefi|" r"^(boot|efi|isolinux|syslinux|id.*\.uefi|"
"ldlinux.c32|ldlinux.sys|livecd|livecd.squashfs)$") "ldlinux.c32|ldlinux.sys|livecd|livecd.squashfs)$")
for fn in list(filter(clear_match.match, listDirectory(dn))): for fn in [x for x in listDirectory(dn) if clear_match.match(x)]:
full_path = path.join(dn, fn) full_path = path.join(dn, fn)
try: try:
if path.isdir(full_path): if path.isdir(full_path):

@ -27,34 +27,51 @@ class FileSystemManager(object):
defaultOpt = ['noatime'] defaultOpt = ['noatime']
defaultBindOpts = ['bind'] defaultBindOpts = ['bind']
#Python3 compat problem:
# dict keys() now sorted based on insertion order,
# instead of being sorted arbitrary by hash.
# Just so the order of keys could be the same as
# in older version, I swaped some pairs around.
supportFS = { supportFS = {
'ext2': {'defaultopt': defaultOpt, 'f2fs': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.ext2', 'format': '/usr/sbin/mkfs.f2fs',
'formatparam': '{labelparam} {device}', 'formatparam': '{labelparam} -f {device}',
'gpt': '8300', 'gpt': '8300',
'label': '-L {labelname}', 'label': '-l {labelname}',
'ssd': [], 'msdos': '83',
'msdos': '83', 'ssd': [],
'compress': None, 'compress': None,
'type': ['hdd', 'usb-hdd']}, 'type': ['hdd', 'usb-hdd']},
'ext3': {'defaultopt': defaultOpt, 'btrfs': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.ext3', 'format': '/sbin/mkfs.btrfs',
'formatparam': '{labelparam} {device}', 'formatparam': '{labelparam} -f {device}',
'gpt': '8300',
'label': '-L {labelname}',
'msdos': '83',
'ssd': ['ssd', 'discard', 'space_cache'],
'type': ['hdd', 'usb-hdd'],
'compress': None,
'compatible': ['btrfs-compress']},
'ntfs-3g': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.ntfs',
'formatparam': '{labelparam} -FQ {device}',
'gpt': '8300',
'label': '-L {labelname}',
'ssd': [],
'auto': False,
'msdos': '7',
'compress': None,
'compatible': ['ntfs']},
'ntfs': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.ntfs',
'formatparam': '{labelparam} -FQ {device}',
'gpt': '8300', 'gpt': '8300',
'label': '-L {labelname}', 'label': '-L {labelname}',
'msdos': '7',
'auto': False,
'ssd': [], 'ssd': [],
'msdos': '83',
'compress': None, 'compress': None,
'type': ['hdd', 'usb-hdd']}, 'compatible': ['ntfs-3g']},
'ext4': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.ext4',
'formatparam': '{labelparam} {device}',
'gpt': '8300',
'label': '-L {labelname}',
'ssd': ['discard'],
'msdos': '83',
'compress': None,
'type': ['hdd', 'usb-hdd']},
'reiserfs': {'defaultopt': defaultOpt, 'reiserfs': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.reiserfs', 'format': '/sbin/mkfs.reiserfs',
'formatparam': '{labelparam} -f {device}', 'formatparam': '{labelparam} -f {device}',
@ -64,16 +81,16 @@ class FileSystemManager(object):
'compress': None, 'compress': None,
'ssd': [], 'ssd': [],
'type': ['hdd', 'usb-hdd']}, 'type': ['hdd', 'usb-hdd']},
'btrfs': {'defaultopt': defaultOpt, 'xfs': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.btrfs', 'format': '/sbin/mkfs.xfs',
'formatparam': '{labelparam} -f {device}', 'formatparam': '{labelparam} -f {device}',
'gpt': '8300', 'gpt': '8300',
'label': '-L {labelname}', 'label': '-L {labelname}',
'msdos': '83', 'msdos': '83',
'ssd': ['ssd', 'discard', 'space_cache'], 'boot': '-i sparce=0',
'type': ['hdd', 'usb-hdd'], 'ssd': ['discard'],
'compress': None, 'compress': None,
'compatible': ['btrfs-compress']}, 'type': ['hdd', 'usb-hdd']},
'btrfs-compress': {'defaultopt': defaultOpt, 'btrfs-compress': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.btrfs', 'format': '/sbin/mkfs.btrfs',
'orig': 'btrfs', 'orig': 'btrfs',
@ -85,6 +102,53 @@ class FileSystemManager(object):
'ssd': ['ssd', 'discard', 'space_cache'], 'ssd': ['ssd', 'discard', 'space_cache'],
'type': ['hdd', 'usb-hdd'], 'type': ['hdd', 'usb-hdd'],
'compatible': ['btrfs']}, 'compatible': ['btrfs']},
'ext4': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.ext4',
'formatparam': '{labelparam} {device}',
'gpt': '8300',
'label': '-L {labelname}',
'ssd': ['discard'],
'msdos': '83',
'compress': None,
'type': ['hdd', 'usb-hdd']},
'ext3': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.ext3',
'formatparam': '{labelparam} {device}',
'gpt': '8300',
'label': '-L {labelname}',
'ssd': [],
'msdos': '83',
'compress': None,
'type': ['hdd', 'usb-hdd']},
'ext2': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.ext2',
'formatparam': '{labelparam} {device}',
'gpt': '8300',
'label': '-L {labelname}',
'ssd': [],
'msdos': '83',
'compress': None,
'type': ['hdd', 'usb-hdd']},
'uefi': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.vfat',
'formatparam': '{labelparam} -F 32 {device}',
'gpt': 'EF00',
'label': '-n {labelname}',
'msdos': '0b',
'ssd': [],
'auto': False,
'compress': None,
'type': ['hdd']},
'vfat': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.vfat',
'formatparam': '{labelparam} -F 32 {device}',
'gpt': '0700',
'label': '-n {labelname}',
'msdos': '0b',
'auto': False,
'ssd': ['discard'],
'compress': None,
'type': ['flash']},
'jfs': {'defaultopt': defaultOpt, 'jfs': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.jfs', 'format': '/sbin/mkfs.jfs',
'formatparam': '{labelparam} -f {device}', 'formatparam': '{labelparam} -f {device}',
@ -94,25 +158,6 @@ class FileSystemManager(object):
'ssd': ['discard'], 'ssd': ['discard'],
'compress': None, 'compress': None,
'type': ['hdd', 'usb-hdd']}, 'type': ['hdd', 'usb-hdd']},
'xfs': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.xfs',
'formatparam': '{labelparam} -f {device}',
'gpt': '8300',
'label': '-L {labelname}',
'msdos': '83',
'boot': '-i sparce=0',
'ssd': ['discard'],
'compress': None,
'type': ['hdd', 'usb-hdd']},
'f2fs': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.f2fs',
'formatparam': '{labelparam} -f {device}',
'gpt': '8300',
'label': '-l {labelname}',
'msdos': '83',
'ssd': [],
'compress': None,
'type': ['hdd', 'usb-hdd']},
# 'nilfs2': {'defaultopt': defaultOpt, # 'nilfs2': {'defaultopt': defaultOpt,
# 'format': '/sbin/mkfs.nilfs2', # 'format': '/sbin/mkfs.nilfs2',
# 'formatparam': '{labelparam} {device}', # 'formatparam': '{labelparam} {device}',
@ -130,46 +175,7 @@ class FileSystemManager(object):
'auto': False, 'auto': False,
'compress': None, 'compress': None,
'msdos': '82'}, 'msdos': '82'},
'uefi': {'defaultopt': defaultOpt, }
'format': '/usr/sbin/mkfs.vfat',
'formatparam': '{labelparam} -F 32 {device}',
'gpt': 'EF00',
'label': '-n {labelname}',
'msdos': '0b',
'ssd': [],
'auto': False,
'compress': None,
'type': ['hdd']},
'vfat': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.vfat',
'formatparam': '{labelparam} -F 32 {device}',
'gpt': '0700',
'label': '-n {labelname}',
'msdos': '0b',
'auto': False,
'ssd': ['discard'],
'compress': None,
'type': ['flash']},
'ntfs': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.ntfs',
'formatparam': '{labelparam} -FQ {device}',
'gpt': '8300',
'label': '-L {labelname}',
'msdos': '7',
'auto': False,
'ssd': [],
'compress': None,
'compatible': ['ntfs-3g']},
'ntfs-3g': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.ntfs',
'formatparam': '{labelparam} -FQ {device}',
'gpt': '8300',
'label': '-L {labelname}',
'ssd': [],
'auto': False,
'msdos': '7',
'compress': None,
'compatible': ['ntfs']}}
default_param = {'defaultopt': defaultOpt, default_param = {'defaultopt': defaultOpt,
'gpt': '8300', 'gpt': '8300',

@ -132,36 +132,56 @@ class Install(MethodsInterface):
if partition_table == "dos": if partition_table == "dos":
fdisk = process(fdisk_cmd, "-l", device_name) fdisk = process(fdisk_cmd, "-l", device_name)
DEVICENUM, AFLAG = 0, 1 DEVICENUM, AFLAG = 0, 1
change_active = map( # change_active = map(
lambda x: x[DEVICENUM], # lambda x: x[DEVICENUM],
filter( # filter(
lambda x: (x[DEVICENUM] != partition_number and # lambda x: (x[DEVICENUM] != partition_number and
x[AFLAG] == "*" or # x[AFLAG] == "*" or
x[DEVICENUM] == partition_number and # x[DEVICENUM] == partition_number and
not x[AFLAG] == "*"), # not x[AFLAG] == "*"),
list(map( # list(map(
lambda x: [str(x[0]), x[1][1].strip()], # lambda x: [str(x[0]), x[1][1].strip()],
# enumerate partitions # # enumerate partitions
enumerate(filter(None, map( # enumerate(filter(None, map(
lambda x: x.split()[:2], # lambda x: x.split()[:2],
# drop string before information about partitions # # drop string before information about partitions
dropwhile( # dropwhile(
lambda x: not x.lstrip().startswith( # lambda x: not x.lstrip().startswith(
"Device"), # "Device"),
fdisk.readlines()))))))[1:])) # fdisk.readlines()))))))[1:]))
change_active = [x[DEVICENUM] for x
in [[str(y[0]), y[1][1].strip()] for y
in enumerate([z for z
in [o.split()[:2] for o
in dropwhile(lambda x: not x.lstrip().startswith("Device"),fdisk.readlines())]
if z])][1:]
if x[DEVICENUM] != partition_number and
x[AFLAG] == "*" or
x[DEVICENUM] == partition_number and
not x[AFLAG] == "*"]
else: else:
parted = process(parted_cmd, "-m", device_name, "print") parted = process(parted_cmd, "-m", device_name, "print")
DEVICENUM, FLAGS = 0, 6 DEVICENUM, FLAGS = 0, 6
change_active = map( # change_active = map(
lambda x: x[DEVICENUM], filter( # lambda x: x[DEVICENUM], filter(
lambda x: (x[DEVICENUM] != partition_number and # lambda x: (x[DEVICENUM] != partition_number and
boot_flag in x[FLAGS].strip(';').split(', ') or # boot_flag in x[FLAGS].strip(';').split(', ') or
x[DEVICENUM] == partition_number and # x[DEVICENUM] == partition_number and
boot_flag not in # boot_flag not in
x[FLAGS].strip(';').split(', ')), # x[FLAGS].strip(';').split(', ')),
filter(lambda x: len(x) >= 7, # filter(lambda x: len(x) >= 7,
map(lambda x: x.split(':'), # map(lambda x: x.split(':'),
parted.readlines()[2:])))) # parted.readlines()[2:]))))
change_active = [x[DEVICENUM] for x
in [y for y
in [z.split(':') for z
in parted.readlines()[2:]]
if len(y) >= 7]
if x[DEVICENUM] != partition_number and
boot_flag in x[FLAGS].strip(';').split(', ') or
x[DEVICENUM] == partition_number and
boot_flag not in
x[FLAGS].strip(';').split(', ')]
if not change_active: if not change_active:
return True return True
if partition_table == "dos": if partition_table == "dos":

@ -480,9 +480,7 @@ class migrate(object):
os.mkdir(homedir) os.mkdir(homedir)
os.chown(homedir, int(userdata[2]), int(userdata[3])) os.chown(homedir, int(userdata[2]), int(userdata[3]))
os.chmod(homedir, perms) os.chmod(homedir, perms)
users = list( users = list(set([x[0] for x in addUsersList] + existsMigrateUsers) - {"root"})
set(map(lambda x: x[0],
addUsersList) + existsMigrateUsers) - {"root"})
try: try:
map(createHome, filter(lambda x: x[0] in users, self.dataUsers)) map(createHome, filter(lambda x: x[0] in users, self.dataUsers))
except Exception as e: except Exception as e:

@ -91,8 +91,7 @@ class ResolutionVariable(VideoVariable):
"1600x900", "1600x1200", "2048x1152", "2560x1440", "1600x900", "1600x1200", "2048x1152", "2560x1440",
"2560x1600"] "2560x1600"]
if self.fbres: if self.fbres:
return list(map(lambda x: "%s-32" % x, return ["%s-32" % x for x in resolutions]
resolutions))
else: else:
return resolutions return resolutions
@ -183,7 +182,7 @@ class VariableOsInstallX11VideoAvailable(VideoVariable):
return [] return []
def humanReadable(self): def humanReadable(self):
return list(map(lambda x: self.driver_names.get(x, x), self.Get())) return [self.driver_names.get(x, x) for x in self.Get()]
class VariableOsX11KmsVideoDrv(ReadonlyVariable): class VariableOsX11KmsVideoDrv(ReadonlyVariable):
@ -219,9 +218,9 @@ class VariableOsInstallX11VideoDrv(VideoVariable):
if self.Get('os_install_x11_server_set') == 'on': if self.Get('os_install_x11_server_set') == 'on':
values = self.Get('os_install_x11_video_available') values = self.Get('os_install_x11_video_available')
else: else:
values = self.nox_video_drivers() values = self.nox_video_drivers()
return list(map(lambda x: (x, self.driver_names.get(x, x)), return [(x, self.driver_names.get(x, x)) for x
(x for x in self.driver_names.keys() if x in values))) in [y for y in self.driver_names.keys() if y in values]]
def get(self): def get(self):
if self.Get('os_install_x11_server_set') == 'on': if self.Get('os_install_x11_server_set') == 'on':

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

@ -98,9 +98,7 @@ class VariableHrMemorySize(ReadonlyVariable):
def get(self): def get(self):
reMemTotal = re.compile(r'^MemTotal:\s*(\d+)\s*kB$') reMemTotal = re.compile(r'^MemTotal:\s*(\d+)\s*kB$')
totalMemList = list(filter(lambda x: x, totalMemList = [x for x in map(reMemTotal.search, readLinesFile('/proc/meminfo')) if x]
map(reMemTotal.search,
readLinesFile('/proc/meminfo'))))
if totalMemList: if totalMemList:
size = int(totalMemList[0].group(1)) * Sizes.K size = int(totalMemList[0].group(1)) * Sizes.K
return str(size) return str(size)
@ -212,7 +210,7 @@ class VariableClAutopartitionDevice(AutopartitionHelper, Variable):
self.label = _("Devices for install") self.label = _("Devices for install")
def get(self): def get(self):
choiceVal = list(map(lambda x: x[0], self.choice())) choiceVal = [x[0] for x in self.choice()]
devicesTypes = self.Select(['os_device_dev','os_device_type'], devicesTypes = self.Select(['os_device_dev','os_device_type'],
where='os_device_dev', _in=choiceVal) where='os_device_dev', _in=choiceVal)
notFlashDevices = [x[0] for x in devicesTypes if x[1] != 'flash'] notFlashDevices = [x[0] for x in devicesTypes if x[1] != 'flash']
@ -255,8 +253,9 @@ class VariableClAutopartitionDevice(AutopartitionHelper, Variable):
def checkOnRaid(self, valuelist): def checkOnRaid(self, valuelist):
disks = self.Select('os_disk_dev', disks = self.Select('os_disk_dev',
where='os_disk_parent', _in=valuelist) where='os_disk_parent', _in=valuelist)
raids = list(filter(None, self.Select('os_disk_raid', raids = [x for x
where='os_disk_dev', _in=disks))) in self.Select('os_disk_raid', where='os_disk_dev', _in=disks)
if x]
raidDisks = self.Select('os_disk_dev', where='os_disk_raid', _in=raids) raidDisks = self.Select('os_disk_dev', where='os_disk_raid', _in=raids)
raidDevices = self.Select('os_disk_parent', raidDevices = self.Select('os_disk_parent',
where='os_disk_dev', where='os_disk_dev',
@ -784,10 +783,10 @@ class VariableClAutopartitionDiskSize(DiskFilter, ReadonlyVariable):
field = "disk_size" field = "disk_size"
def get(self): def get(self):
return list(map(str, super(VariableClAutopartitionDiskSize, self).get())) return [str(x) for x in super(VariableClAutopartitionDiskSize, self).get()]
def humanReadable(self): def humanReadable(self):
return list(map(humanreadableSize, self.Get())) return [humanreadableSize(x) for x in self.Get()]
class VariableClAutopartitionDiskDataFull(ReadonlyTableVariable): class VariableClAutopartitionDiskDataFull(ReadonlyTableVariable):
@ -876,10 +875,10 @@ class VariableClAutopartitionDiskSizeFull(ReadonlyVariable):
def get(self): def get(self):
var_factory = self.Get('cl_autopartition_factory') var_factory = self.Get('cl_autopartition_factory')
return list(map(str, var_factory.disk_size)) return [str(x) for x in var_factory.disk_size]
def humanReadable(self): def humanReadable(self):
return list(map(humanreadableSize, self.Get())) return [humanreadableSize(x) for x in self.Get()]
class VariableClAutopartitionRaid(ReadonlyVariable): class VariableClAutopartitionRaid(ReadonlyVariable):

@ -50,8 +50,7 @@ class DeviceHelper(VariableInterface):
def getBlockDevices(self): def getBlockDevices(self):
"""Get interest devices from sys block path""" """Get interest devices from sys block path"""
return list(filter(self.rePassDevice.search, return list(filter(self.rePassDevice.search, device.udev.get_block_devices()))
device.udev.get_block_devices()))
def separateDevice(self, dev): def separateDevice(self, dev):
""" """
@ -59,8 +58,7 @@ class DeviceHelper(VariableInterface):
Using for sort. (Example: sda2 ("sda",2), md5p1 ("md",5,"p",1) Using for sort. (Example: sda2 ("sda",2), md5p1 ("md",5,"p",1)
""" """
return list(map(lambda x: int(x) if x.isdigit() else x, return [int(x) if x.isdigit() else x for x in re.findall(r'\d+|\D+', dev)]
re.findall(r'\d+|\D+', dev)))
def mapUdevProperty(self, var, prop, default): def mapUdevProperty(self, var, prop, default):
"""Get each element from var through udev [prop]""" """Get each element from var through udev [prop]"""
@ -180,8 +178,7 @@ class VariableOsDeviceDev(DeviceHelper, ReadonlyVariable):
if device.udev.is_device(device.udev.get_device_info(x)) or if device.udev.is_device(device.udev.get_device_info(x)) or
self.re_disk_raid.match(device.udev.get_device_type(path=x))) self.re_disk_raid.match(device.udev.get_device_type(path=x)))
return list(sorted((x for x in devnames), return list(sorted((x for x in devnames), key=self.separateDevice))
key=self.separateDevice))
class VariableOsDeviceFulltype(ReadonlyVariable): class VariableOsDeviceFulltype(ReadonlyVariable):
""" """
@ -228,8 +225,7 @@ class VariableOsDeviceType(ReadonlyVariable):
device.devfs.listdir(diskIdPath, fullpath=False))) device.devfs.listdir(diskIdPath, fullpath=False)))
else: else:
self.usbdevices = [] self.usbdevices = []
return list(map(self.getType, return list(map(self.getType, self.Get('os_device_dev')))
self.Get('os_device_dev')))
class VariableOsDeviceParent(ReadonlyVariable): class VariableOsDeviceParent(ReadonlyVariable):
@ -313,8 +309,7 @@ class VariableOsDeviceMap(ReadonlyVariable):
type = "list" type = "list"
def get(self): def get(self):
return list(map(lambda x: str(x[0]), return [str(x[0]) for x in enumerate(self.Get('os_device_dev'))]
enumerate(self.Get('os_device_dev'))))
class VariableOsDeviceArraySet(ReadonlyVariable): class VariableOsDeviceArraySet(ReadonlyVariable):
@ -334,9 +329,7 @@ class VariableOsDeviceArraySet(ReadonlyVariable):
else: else:
return "off" return "off"
return list(map(lambda x: isArray(*x), return [isArray(*x) for x in zip(self.Get('os_device_dev'), self.Get('os_device_name'))]
zip(self.Get('os_device_dev'),
self.Get('os_device_name'))))
class VariableOsDeviceSsdSet(ReadonlyVariable): class VariableOsDeviceSsdSet(ReadonlyVariable):
@ -361,9 +354,7 @@ class VariableOsDeviceSsdSet(ReadonlyVariable):
else: else:
return "off" return "off"
return list(map(lambda x: isSsd(*x), return [isSsd(*x) for x in zip(self.Get('os_device_dev'), self.Get('os_device_name'))]
zip(self.Get('os_device_dev'),
self.Get('os_device_name'))))
class VariableOsDeviceSyspath(ReadonlyVariable): class VariableOsDeviceSyspath(ReadonlyVariable):
@ -403,10 +394,9 @@ class VariableOsDeviceVirtualSet(ReadonlyVariable):
else: else:
return "off" return "off"
return list(map(lambda x: isVirtual(*x), return [isVirtual(*x) for x in zip(self.Get('os_device_dev'),
zip(self.Get('os_device_dev'), self.Get('os_device_name'),
self.Get('os_device_name'), self.Get('os_device_syspath'))]
self.Get('os_device_syspath'))))
class VariableOsDeviceTable(ReadonlyVariable): class VariableOsDeviceTable(ReadonlyVariable):
@ -444,8 +434,8 @@ class VariableOsDeviceTable(ReadonlyVariable):
else: else:
return getTable(dev) return getTable(dev)
return list(map(getByAutopartition, return list(map(getByAutopartition, self.Get('os_device_dev')))
self.Get('os_device_dev')))
class VariableOsDeviceName(ReadonlyVariable): class VariableOsDeviceName(ReadonlyVariable):
@ -475,8 +465,7 @@ class VariableOsDeviceName(ReadonlyVariable):
return "" return ""
def get(self): def get(self):
return list(map(self.getName, return list(map(self.getName, self.Get('os_device_dev')))
self.Get('os_device_dev')))
class VariableOsDeviceSize(ReadonlyVariable): class VariableOsDeviceSize(ReadonlyVariable):
@ -487,12 +476,10 @@ class VariableOsDeviceSize(ReadonlyVariable):
def get(self): def get(self):
"""Get device size""" """Get device size"""
return list(map(lambda x: getPartitionSize(name=x, inBytes=True), return [getPartitionSize(name=x, inBytes=True) for x in self.Get('os_device_dev')]
self.Get('os_device_dev')))
def humanReadable(self): def humanReadable(self):
return list(map(humanreadableSize, return list(map(humanreadableSize, self.Get()))
self.Get()))
############################################# #############################################
@ -536,8 +523,7 @@ class VariableOsDiskDev(DeviceHelper, ReadonlyVariable):
return list(sorted((x for x in dev_names), key=self.separateDevice)) return list(sorted((x for x in dev_names), key=self.separateDevice))
def humanReadable(self): def humanReadable(self):
return list(map(self.getPerfectName, return list(map(self.getPerfectName, self.Get()))
self.Get()))
class VariableOsDiskMount(DeviceHelper, ReadonlyVariable): class VariableOsDiskMount(DeviceHelper, ReadonlyVariable):
@ -550,8 +536,7 @@ class VariableOsDiskMount(DeviceHelper, ReadonlyVariable):
disk_hash = self.Get('os_disk_dev') disk_hash = self.Get('os_disk_dev')
fstab = FStab('/etc/fstab', devs=disk_hash) fstab = FStab('/etc/fstab', devs=disk_hash)
rootdev = self.Get('os_root_dev') rootdev = self.Get('os_root_dev')
return list(map(lambda x: '/' if x == rootdev else fstab.getBy(eq=x) or "", return ['/' if x == rootdev else fstab.getBy(eq=x) or "" for x in self.Get('os_disk_dev')]
self.Get('os_disk_dev')))
class VariableOsDiskContent(ReadonlyVariable): class VariableOsDiskContent(ReadonlyVariable):
@ -564,8 +549,7 @@ class VariableOsDiskContent(ReadonlyVariable):
""" """
TODO: need to write TODO: need to write
""" """
return list(map(lambda x: "", return ["" for x in self.Get('os_disk_dev')]
self.Get('os_disk_dev')))
class VariableOsDiskFormat(ReadonlyVariable): class VariableOsDiskFormat(ReadonlyVariable):
""" """
@ -593,8 +577,7 @@ class VariableOsDiskFormat(ReadonlyVariable):
pass pass
return fs return fs
return list(map(getFormat, return list(map(getFormat, self.Get('os_disk_dev')))
self.Get('os_disk_dev')))
class VariableOsDiskType(ReadonlyVariable): class VariableOsDiskType(ReadonlyVariable):
@ -608,8 +591,7 @@ class VariableOsDiskType(ReadonlyVariable):
def get(self): def get(self):
"""Get partition scheme""" """Get partition scheme"""
types = list(map(lambda x: (x, device.udev.get_device_type(name=x)), types = [(x, device.udev.get_device_type(name=x)) for x in self.Get('os_disk_dev')]
self.Get('os_disk_dev')))
lvmUsedDisks = {} lvmUsedDisks = {}
raidUsedDisks = {} raidUsedDisks = {}
@ -642,9 +624,8 @@ class VariableOsDiskType(ReadonlyVariable):
lvmUsedDisks[x].append(dev) lvmUsedDisks[x].append(dev)
else: else:
lvmUsedDisks[x] = [dev] lvmUsedDisks[x] = [dev]
return list(map(lambda x: x[1],
map(forMember, return [x[1] for x in map(forMember, types)]
types)))
class VariableOsDiskRaid(ReadonlyVariable): class VariableOsDiskRaid(ReadonlyVariable):
@ -672,8 +653,7 @@ class VariableOsDiskLvm(DeviceHelper, ReadonlyVariable):
def get(self): def get(self):
"""Get each element from var through udev [prop]""" """Get each element from var through udev [prop]"""
return list(map(self.getLvmName, return list(map(self.getLvmName, self.Get('os_disk_dev')))
self.Get('os_disk_dev')))
class VariableOsDiskUuid(DeviceHelper, ReadonlyVariable): class VariableOsDiskUuid(DeviceHelper, ReadonlyVariable):
@ -723,10 +703,9 @@ class VariableOsDiskId(DeviceHelper, ReadonlyVariable):
'21686148-6449-6e6f-744e-656564454649': 'EF02', '21686148-6449-6e6f-744e-656564454649': 'EF02',
'c12a7328-f81f-11d2-ba4b-00a0c93ec93b': 'EF00', 'c12a7328-f81f-11d2-ba4b-00a0c93ec93b': 'EF00',
'0fc63daf-8483-4772-8e79-3d69d8477de4': '8300'} '0fc63daf-8483-4772-8e79-3d69d8477de4': '8300'}
return list(map(lambda x: mapTypeUUID.get(x, x), return [mapTypeUUID.get(x, x) for x
map(lambda x: x.rpartition("x")[2], in [y.rpartition("x")[2] for y
self.mapUdevProperty('os_disk_dev', 'ID_PART_ENTRY_TYPE', in self.mapUdevProperty('os_disk_dev', 'ID_PART_ENTRY_TYPE','')]]
''))))
class VariableOsDiskGrub(ReadonlyVariable): class VariableOsDiskGrub(ReadonlyVariable):
@ -786,12 +765,10 @@ class VariableOsDiskSize(ReadonlyVariable):
def get(self): def get(self):
"""Get disk size""" """Get disk size"""
return list(map(lambda x: getPartitionSize(name=x, inBytes=True), return [getPartitionSize(name=x, inBytes=True) for x in self.Get('os_disk_dev')]
self.Get('os_disk_dev')))
def humanReadable(self): def humanReadable(self):
return list(map(humanreadableSize, return list(map(humanreadableSize, self.Get()))
self.Get()))
class VariableOsDiskName(DeviceHelper, ReadonlyVariable): class VariableOsDiskName(DeviceHelper, ReadonlyVariable):
@ -817,8 +794,7 @@ class VariableOsDiskOptions(ReadonlyVariable):
def getFormat(dev): def getFormat(dev):
return fstab.getBy(what=fstab.OPTS, eq=dev) return fstab.getBy(what=fstab.OPTS, eq=dev)
return list(map(getFormat, return list(map(getFormat, self.Get('os_disk_dev')))
self.Get('os_disk_dev')))
################################################ ################################################
@ -1045,8 +1021,8 @@ class VariableOsLocationSource(LocationHelper, DeviceHelper, Variable):
return list(map(normpath, value)) return list(map(normpath, value))
def choice(self): def choice(self):
return list(map(lambda x: (x, self.getPerfectName(x) or x), return [(x, self.getPerfectName(x) or x) for x
self.fixOsDiskDev(self.availDevs(choice=True)))) + [("", "")] in self.fixOsDiskDev(self.availDevs(choice=True))] + [("", "")]
def fixOsDiskDev(self, sourcelist=None): def fixOsDiskDev(self, sourcelist=None):
""" """
@ -1085,8 +1061,7 @@ class VariableOsLocationSource(LocationHelper, DeviceHelper, Variable):
# get original /dev names # get original /dev names
cnDisks = (device.udev.get_device_info(name=x).get('DEVNAME', x) cnDisks = (device.udev.get_device_info(name=x).get('DEVNAME', x)
for x in disks) for x in disks)
wrongDevices = list(set(cnDisks) - wrongDevices = list(set(cnDisks) - set(self.fixOsDiskDev()))
set(self.fixOsDiskDev()))
if wrongDevices: if wrongDevices:
raise VariableError(_("Wrong device '%s'") % wrongDevices[0]) raise VariableError(_("Wrong device '%s'") % wrongDevices[0])
wrongSource = filter(lambda x: x and not x.startswith('/'), value) wrongSource = filter(lambda x: x and not x.startswith('/'), value)
@ -1096,8 +1071,7 @@ class VariableOsLocationSource(LocationHelper, DeviceHelper, Variable):
########################## ##########################
# detect duplicate devices # detect duplicate devices
########################## ##########################
dupDevices = list(set(filter(lambda x: disks.count(x) > 1, dupDevices = [x for x in disks if disks.count(x) > 1]
disks)))
if dupDevices: if dupDevices:
raise VariableError( raise VariableError(
_("Device '%s' is used more than once") % dupDevices[0]) _("Device '%s' is used more than once") % dupDevices[0])
@ -1141,12 +1115,10 @@ class VariableOsLocationDest(LocationHelper, Variable):
return "" return ""
return mount return mount
return list(map(installMountPoint, return [installMountPoint(x) for x
filter(lambda x: x[0] in source, in list(zip(self.Get('os_disk_dev'),self.Get('os_disk_mount'))) + \
list(zip(self.Get('os_disk_dev'), list(zip(self.Get('os_bind_path'),self.Get('os_bind_mountpoint')))
self.Get('os_disk_mount'))) + \ if x[0] in source]
list(zip(self.Get('os_bind_path'),
self.Get('os_bind_mountpoint'))))))
def set(self, value): def set(self, value):
"""Add abilitiy not specify root""" """Add abilitiy not specify root"""
@ -1157,7 +1129,7 @@ class VariableOsLocationDest(LocationHelper, Variable):
return val return val
value = map(normpath, value) value = map(normpath, value)
return list(map(lambda x: x or "/", value)) return [x or "/" for x in value]
def choice(self): def choice(self):
if self.Get('cl_install_type') == 'flash': if self.Get('cl_install_type') == 'flash':
@ -1189,15 +1161,13 @@ class VariableOsLocationDest(LocationHelper, Variable):
################################ ################################
if not source: if not source:
return return
if not list(filter(lambda x: x == "/", value)): if not [x for x in value if x == "/"]:
raise VariableError(_("To install the system, you need to " raise VariableError(_("To install the system, you need to "
"specify the root device")) "specify the root device"))
################################ ################################
disks = list(filter(lambda x: x[0].startswith('/dev/') and x[1], disks = [x for x in zip(source, value) if x[0].startswith('/dev/') and x[1]]
zip(source, value))) disksDevs = [x[0] for x in disks]
disksDevs = list(map(lambda x: x[0], disks)) binds = [x for x in zip(source, value) if not x[0].startswith('/dev/') and x[1]]
binds = list(filter(lambda x: not x[0].startswith('/dev/') and x[1],
zip(source, value)))
########################## ##########################
# detect efi specifing # detect efi specifing
########################## ##########################
@ -1213,9 +1183,7 @@ class VariableOsLocationDest(LocationHelper, Variable):
########################## ##########################
# detect duplicate mps # detect duplicate mps
########################## ##########################
dupMP = list(set(filter(lambda x: value.count(x) > 1, dupMP = list(set([x for x in [y for y in value if y and y != "swap"] if value.count(x) > 1]))
filter(lambda x: x and x != "swap",
value))))
if dupMP: if dupMP:
raise VariableError( raise VariableError(
_("Mount point '%s' is used more than once") % dupMP[0]) _("Mount point '%s' is used more than once") % dupMP[0])
@ -1271,10 +1239,9 @@ class VariableOsLocationDest(LocationHelper, Variable):
DEVICE, MP = 0, 1 DEVICE, MP = 0, 1
srcMountPoints = map(lambda x: x[DEVICE], binds) srcMountPoints = map(lambda x: x[DEVICE], binds)
destMountPoints = map(lambda x: x[MP], binds) destMountPoints = map(lambda x: x[MP], binds)
wrongBind = list(filter(lambda x: x in destMountPoints, srcMountPoints)) wrongBind = [x for x in srcMountPoints if x in destMountPoints]
if wrongBind: if wrongBind:
incompBind = list(filter(lambda x: x[1] == wrongBind[0], incompBind = [x for x in zip(srcMountPoints, destMountPoints) if x[1] == wrongBind[0]]
zip(srcMountPoints, destMountPoints)))
raise VariableError( raise VariableError(
_("Source directory %(src)s is already used " _("Source directory %(src)s is already used "
"for binding '%(bindSrc)s' to '%(bindDst)s'") \ "for binding '%(bindSrc)s' to '%(bindDst)s'") \
@ -1298,8 +1265,7 @@ class VariableOsLocationDest(LocationHelper, Variable):
installTypes = zip(self.Get('os_install_disk_dev'), installTypes = zip(self.Get('os_install_disk_dev'),
self.Get('os_install_disk_type')) self.Get('os_install_disk_type'))
for checkType in ("raid", "lvm"): for checkType in ("raid", "lvm"):
memberData = list(filter(lambda x: checkType + "member" in x[1], memberData = [x for x in installTypes if checkType + "member" in x[1]]
installTypes))
if memberData: if memberData:
raise VariableError( raise VariableError(
_("Unable to use {part} partition used by active " _("Unable to use {part} partition used by active "
@ -1317,13 +1283,12 @@ class VariableOsLocationFormat(LocationHelper, Variable):
def get(self): def get(self):
if self.Get('cl_autopartition_set') == "on": if self.Get('cl_autopartition_set') == "on":
return self.Get('cl_autopartition_disk_format') + \ return self.Get('cl_autopartition_disk_format') + \
list(map(lambda x: "", self.Get('cl_autopartition_bind_path'))) ["" for x in self.Get('cl_autopartition_bind_path')]
else: else:
mount = self.Get("os_location_dest") mount = self.Get("os_location_dest")
source = self.Get("os_location_source") source = self.Get("os_location_source")
value = [""] * len(source) value = [""] * len(source)
return list(map(self.defaultFormat(), return list(map(self.defaultFormat(), zip(source, mount, value)))
zip(source, mount, value)))
def choice(self): def choice(self):
if self.Get('cl_install_type') == "flash": if self.Get('cl_install_type') == "flash":
@ -1384,8 +1349,7 @@ class VariableOsLocationFormat(LocationHelper, Variable):
value = map(lambda x: "vfat" if x == "uefi" else x, value) value = map(lambda x: "vfat" if x == "uefi" else x, value)
mount = self.Get("os_location_dest") mount = self.Get("os_location_dest")
source = self.Get("os_location_source") source = self.Get("os_location_source")
return list(map(self.defaultFormat(), return list(map(self.defaultFormat(), zip(source, mount, value)))
zip(source, mount, value)))
def check(self, value): def check(self, value):
osInstallRootType = self.Get('os_install_root_type') osInstallRootType = self.Get('os_install_root_type')
@ -1423,17 +1387,14 @@ class VariableOsLocationPerformFormat(LocationHelper, Variable):
def get(self): def get(self):
if self.Get('cl_autopartition_set') == "on": if self.Get('cl_autopartition_set') == "on":
return list(map(lambda x: "on", return ["on" for x in self.Get('cl_autopartition_disk_format')] + \
self.Get('cl_autopartition_disk_format'))) + \ ["" for x in self.Get('cl_autopartition_bind_path')]
list(map(lambda x: "",
self.Get('cl_autopartition_bind_path')))
else: else:
mount = self.Get("os_location_dest") mount = self.Get("os_location_dest")
source = self.Get("os_location_source") source = self.Get("os_location_source")
fs = self.Get("os_location_format") fs = self.Get("os_location_format")
value = [""] * len(source) value = [""] * len(source)
return list(map(self.defaultPerformFormat(), return list(map(self.defaultPerformFormat(), zip(source, mount, fs, value)))
zip(source, mount, fs, value)))
fixNtfs = lambda self, x: {'ntfs-3g': 'ntfs'}.get(x, x) fixNtfs = lambda self, x: {'ntfs-3g': 'ntfs'}.get(x, x)
@ -1531,11 +1492,9 @@ class VariableOsLocationPerformFormat(LocationHelper, Variable):
self.Get('os_location_dest'), self.Get('os_location_dest'),
self.Get('os_location_format'), self.Get('os_location_format'),
value) value)
return list(map(self.defaultPerformFormat(), return [self.defaultPerformFormat()(x) for x
map(lambda x: [x[DEV], x[MP], x[FS], ""] \ in [[y[DEV], y[MP], y[FS], ""]
if x[FORMAT] == "off" and not x[DEV].startswith("/dev/") if y[FORMAT] == "off" and not y[DEV].startswith("/dev/") else y for y in info]]
else x,
info)))
class VariableOsLocationSize(LocationHelper, SourceReadonlyVariable): class VariableOsLocationSize(LocationHelper, SourceReadonlyVariable):
@ -1678,8 +1637,7 @@ class VariableOsInstallDiskDev(ReadonlyVariable, DeviceHelper):
self.Get('os_install_disk_dev_base')) self.Get('os_install_disk_dev_base'))
def humanReadable(self): def humanReadable(self):
return list(map(lambda x: self.getPerfectName(x, defaultValue=x), return [self.getPerfectName(x, defaultValue=x) for x in self.Get()]
self.Get()))
class VariableOsInstallDiskUuid(ReadonlyVariable): class VariableOsInstallDiskUuid(ReadonlyVariable):
@ -1691,7 +1649,7 @@ class VariableOsInstallDiskUuid(ReadonlyVariable):
def get(self): def get(self):
diskDev = self.Get('os_install_disk_dev') diskDev = self.Get('os_install_disk_dev')
hashUUID = getUUIDDict(revers=True) hashUUID = getUUIDDict(revers=True)
return list(map(lambda x: hashUUID.get(x, "")[5:], diskDev)) return [hashUUID.get(x, "")[5:] for x in diskDev]
class VariableOsInstallDiskPartuuid(ReadonlyVariable): class VariableOsInstallDiskPartuuid(ReadonlyVariable):
""" """
@ -1756,9 +1714,8 @@ class VariableOsInstallDiskUse(ReadonlyVariable):
def get(self): def get(self):
"""Get real id (by cl_uuid_set) device""" """Get real id (by cl_uuid_set) device"""
if self.Get('cl_uuid_set') == "on": if self.Get('cl_uuid_set') == "on":
return list(map(lambda x: "UUID=%s" % x[0] if x[0] else x[1], return ["UUID=%s" % x[0] if x[0] else x[1] for x
zip(self.Get('os_install_disk_uuid'), in zip(self.Get('os_install_disk_uuid'), self.Get('os_install_disk_dev'))]
self.Get('os_install_disk_dev'))))
else: else:
return self.Get('os_install_disk_dev') return self.Get('os_install_disk_dev')
@ -1820,11 +1777,11 @@ class VariableOsInstallDiskPerformFormat(ReadonlyVariable):
type = "bool-list" type = "bool-list"
def get(self): def get(self):
_format = list(map(lambda x: x[2], _format = [x[2] for x
filter(lambda x: x[0].startswith('/dev/') and x[1], in zip(self.Get('os_location_source'),
zip(self.Get('os_location_source'), self.Get('os_location_dest'),
self.Get('os_location_dest'), self.Get('os_location_perform_format'))
self.Get('os_location_perform_format'))))) if x[0].startswith('/dev/') and x[1]]
if self.GetBool('cl_autopartition_set'): if self.GetBool('cl_autopartition_set'):
efiformat = ['on' for x in self.Get('os_install_uefi')] efiformat = ['on' for x in self.Get('os_install_uefi')]
res = efiformat + _format res = efiformat + _format
@ -1880,9 +1837,7 @@ class VariableOsInstallDiskName(Variable):
else: else:
return diskLabel.get(dev, '') return diskLabel.get(dev, '')
return list(map(changeLabel, return list(map(changeLabel, self.ZipVars('os_install_disk_dev','os_install_disk_mount')))
self.ZipVars('os_install_disk_dev',
'os_install_disk_mount')))
class VariableOsInstallDiskSize(SourceReadonlyVariable): class VariableOsInstallDiskSize(SourceReadonlyVariable):
@ -2118,7 +2073,7 @@ class VariableOsInstallUefi(LocationHelper, Variable):
return self.select('os_device_efi', return self.select('os_device_efi',
os_device_dev=efidev, limit=1) or efidev os_device_dev=efidev, limit=1) or efidev
return efidev return efidev
return list(filter(lambda x: x != "off", map(transform, value))) return [x for x in map(transform, value) if x != "off"]
def choice(self): def choice(self):
deviceParentMap = self.ZipVars('os_device_dev', deviceParentMap = self.ZipVars('os_device_dev',
@ -2233,7 +2188,7 @@ class VariableOsInstallMbr(LocationHelper, Variable):
def set(self, value): def set(self, value):
# support off value # support off value
return list(filter(lambda x: x != "off", value)) return [x for x in value if x != "off"]
def check(self, value): def check(self, value):
if self.GetBool('cl_autopartition_set'): if self.GetBool('cl_autopartition_set'):

@ -96,8 +96,7 @@ class DistroRepository(Linux):
distros = filter(lambda x: x, distros = filter(lambda x: x,
map(self.reDistName.search, map(self.reDistName.search,
self._getAvailableDistributives(dirs))) self._getAvailableDistributives(dirs)))
return sorted(list(set(map(lambda x: x.groupdict()['name'], distros)))) return sorted(list(set([x.groupdict()['name'] for x in distros])))
def opcompareByString(self, buf): def opcompareByString(self, buf):
if buf: if buf:
reOp = re.compile(r"^(!=|=|==|<=|>=|>|<)?(\d+.*)$") reOp = re.compile(r"^(!=|=|==|<=|>=|>|<)?(\d+.*)$")
@ -161,18 +160,15 @@ class DistroRepository(Linux):
return [pathname] return [pathname]
else: else:
# discard inner directories # discard inner directories
return list(filter(lambda x: not path.isdir(path.join(pathname, x)), return [x for x in listDirectory(pathname) if not path.isdir(path.join(pathname, x))]
listDirectory(pathname)))
# get lists files in directories # get lists files in directories
allFiles = map(lambda x: map(lambda y: path.join(x, y), allFiles = map(lambda x: map(lambda y: path.join(x, y),
listdistr(x)), listdistr(x)),
dirs) dirs)
# filter distributives # filter distributives
return list(filter(distfilter, # join files lists to one list
# join files lists to one list return [x for x in reduce(lambda x, y: x + y, allFiles, []) if distfilter(x)]
reduce(lambda x, y: x + y,
allFiles, [])))
def extcomparator(self, *exts): def extcomparator(self, *exts):
"""Compare extensions""" """Compare extensions"""
@ -210,12 +206,10 @@ class DistroRepository(Linux):
availDistrs = self._getAvailableDistributives(dirs, system, shortname, availDistrs = self._getAvailableDistributives(dirs, system, shortname,
march, version, march, version,
build) build)
availDistrs = list(filter(lambda x: x[1] and "ext" in x[1] and availDistrs = [x for x
not x[1]["ext"] in discardType, in [(y, self._getDistrInfo(y)) for y in availDistrs]
map(lambda x: (x, self._getDistrInfo(x)), if x[1] and "ext" in x[1] and not x[1]["ext"] in discardType]
availDistrs))) return [x[0] for x in sorted(availDistrs, self.sortdistrfunc, reverse=True)]
return list(map(lambda x: x[0],
sorted(availDistrs, self.sortdistrfunc, reverse=True)))
def getBestDistributive(self, dirs, system=None, shortname=None, march=None, def getBestDistributive(self, dirs, system=None, shortname=None, march=None,
version=None, build=None, discardType=()): version=None, build=None, discardType=()):
@ -237,7 +231,7 @@ class DistroRepository(Linux):
path.join(y, x)), path.join(y, x)),
listDirectory(y)), listDirectory(y)),
existsdirs, []) existsdirs, [])
listimgs = list(filter(lambda x: x, listimgs)) listimgs = [x for x in listimgs if x]
if listimgs: if listimgs:
return max(listimgs, key=keyfunc).group() return max(listimgs, key=keyfunc).group()
return "" return ""
@ -500,21 +494,17 @@ class VariableClImagePath(ReadonlyVariable):
livedistr = ['/run/initramfs/squashfs', livedistr = ['/run/initramfs/squashfs',
'/run/initramfs/live', '/run/initramfs/live',
'/mnt/cdrom'] '/mnt/cdrom']
livedistr = list(filter(listDirectory, livedistr = list(filter(listDirectory, livedistr))[:1]
livedistr))[:1]
else: else:
livedistr = [] livedistr = []
# search all partition for source installation distributive # search all partition for source installation distributive
rootDev = self.Get('os_install_root_dev') rootDev = self.Get('os_install_root_dev')
livedistr += \ livedistr = [x[0] for x
list(map(lambda x: x[0], in zip(self.Get('os_disk_dev'), self.Get('os_disk_content'))
filter(lambda x: " live" in x[1] and x[0] != rootDev, if " live" in x[1] and x[0] != rootDev]
zip(self.Get('os_disk_dev'),
self.Get('os_disk_content')))))
# add to standard path # add to standard path
return list(filter(path.exists, return list(filter(path.exists, ['/var/calculate/remote/linux',
['/var/calculate/remote/linux', '/var/calculate/linux'] + livedistr))
'/var/calculate/linux'] + livedistr))
class VariableClSource(ReadonlyVariable): class VariableClSource(ReadonlyVariable):

@ -224,9 +224,9 @@ class VariableOsInstallKernelScheduleData(ReadonlyTableVariable):
'CONFIG_IOSCHED_NOOP=y': 'noop', 'CONFIG_IOSCHED_NOOP=y': 'noop',
'CONFIG_IOSCHED_CFQ=y': 'cfq', 'CONFIG_IOSCHED_CFQ=y': 'cfq',
'CONFIG_IOSCHED_DEADLINE=y': 'deadline'} 'CONFIG_IOSCHED_DEADLINE=y': 'deadline'}
installed = list(map(schedulers.get, installed = [schedulers.get(x) for x
filter(lambda x: x in schedulers, in self.Get('os_install_kernel_config')
self.Get('os_install_kernel_config')))) or ['cfq'] if x in schedulers] or ['cfq']
return [[x, "on" if x in installed else "off"] return [[x, "on" if x in installed else "off"]
for x in sorted(schedulers.values())] for x in sorted(schedulers.values())]
@ -341,10 +341,10 @@ class KernelHelper(VariableInterface):
filesWithType = map(lambda x: (x, ftype(x)), filesWithType = map(lambda x: (x, ftype(x)),
filter(path.exists, filter(path.exists,
filelist)) filelist))
return list(filter(lambda x: x[1] and descr in x[1], filesWithType)) return [x for x in filesWithType if x[1] and descr in x[1]]
def getInitrdFiles(self, pathname): def getInitrdFiles(self, pathname):
filelist = list(map(lambda x: path.join(pathname, x), os.listdir(pathname))) filelist = [path.join(pathname, x) for x in os.listdir(pathname)]
return [x for x in filelist if path.exists(x) and InitrdFile.is_cpio(x)] return [x for x in filelist if path.exists(x) and InitrdFile.is_cpio(x)]
def getInitrd(self, arch, shortname, chroot, kernel, suffix="", def getInitrd(self, arch, shortname, chroot, kernel, suffix="",
@ -372,14 +372,12 @@ class KernelHelper(VariableInterface):
bootdir = path.join(chroot, 'boot') bootdir = path.join(chroot, 'boot')
initramfsFiles = self.getInitrdFiles(bootdir) initramfsFiles = self.getInitrdFiles(bootdir)
initramfsWithVer = \ initramfsWithVer = [x for x
list(filter(lambda x: (kernelVersion in x[1] or in [(y, initrd_version_by_name(y)) for y in initramfsFiles]
origKernelVer in x[1]) and \ if (kernelVersion in x[1] or
x[0].endswith(suffix) and \ origKernelVer in x[1]) and
( x[0].endswith(suffix) and
not notsuffix or not x[0].endswith(notsuffix)), (not notsuffix or not x[0].endswith(notsuffix))]
map(lambda x: (x, initrd_version_by_name(x)),
initramfsFiles)))
if initramfsWithVer: if initramfsWithVer:
return path.split(min(initramfsWithVer, return path.split(min(initramfsWithVer,
key=itemgetter(0))[0])[-1] key=itemgetter(0))[0])[-1]
@ -397,18 +395,28 @@ class VariableOsInstallKernel(ReadonlyVariable, KernelHelper):
validKernel = listDirectory(modulesdir) validKernel = listDirectory(modulesdir)
kernelFiles = self.getFilesByType(bootdir, "Linux kernel") kernelFiles = self.getFilesByType(bootdir, "Linux kernel")
installMarch = self.Get('os_install_arch_machine') installMarch = self.Get('os_install_arch_machine')
kernelsWithVer = \ # kernelsWithVer = \
list(map(lambda x: ( # list(map(lambda x: (
x[0], (getTupleVersion("".join(x[1].groups()[0:3:2])), # x[0], (getTupleVersion("".join(x[1].groups()[0:3:2])),
path.getmtime(x[0]))), # path.getmtime(x[0]))),
# convert version to tuple( versionTuple, mtime) # # convert version to tuple( versionTuple, mtime)
# version detect, for this version lib contains moudules # # version detect, for this version lib contains moudules
# kernel arch equal install arch # # kernel arch equal install arch
filter(lambda x: x[1] and x[1].group() in validKernel and # filter(lambda x: x[1] and x[1].group() in validKernel and
installMarch in x[0].rpartition('/')[2], # installMarch in x[0].rpartition('/')[2],
# (filename,version) # # (filename,version)
map(lambda x: (x[0], self.reFindVer.search(x[1])), # map(lambda x: (x[0], self.reFindVer.search(x[1])),
kernelFiles)))) # kernelFiles))))
kernelsWithVer = [(x[0],
(getTupleVersion("".join(x[1].groups()[0:3:2])),
path.getmtime(x[0]))) for x
# convert version to tuple( versionTuple, mtime)
# version detect, for this version lib contains moudules
# kernel arch equal install arch
in [y for y
# (filename,version)
in [(z[0], self.reFindVer.search(z[1])) for z in kernelFiles]
if y[1] and y[1].group() in validKernel and installMarch in y[0].rpartition('/')[2]]]
if kernelsWithVer: if kernelsWithVer:
return path.split(max(kernelsWithVer, key=itemgetter(1))[0])[-1] return path.split(max(kernelsWithVer, key=itemgetter(1))[0])[-1]
else: else:
@ -469,9 +477,8 @@ class VariableOsInstallKernelCpufreq(ReadonlyVariable):
def get(self): def get(self):
"""Get cpufreq (and other from modules_3= param) from conf.d/modules""" """Get cpufreq (and other from modules_3= param) from conf.d/modules"""
cpufreqmods = list(map(lambda x: x.partition('=')[2].strip("\n '\""), cpufreqmods = [x.partition('=')[2].strip("\n '\"") for x
filter(lambda x: x.startswith('modules_3'), in readLinesFile('/etc/conf.d/modules') if x.startswith('modules_3')]
readLinesFile('/etc/conf.d/modules'))))
if cpufreqmods: if cpufreqmods:
return cpufreqmods[0] return cpufreqmods[0]
else: else:

@ -53,9 +53,8 @@ class VariableOsInstallLinguas(LocaleVariable):
def get(self): def get(self):
def get_linguas(lines): def get_linguas(lines):
linguas = list(map(lambda x: x.strip().rpartition('=')[-1].strip('"\''), linguas = [x.strip().rpartition('=')[-1].strip('"\'') for x
filter(lambda x: x.startswith("LINGUAS="), in lines if x.startswith("LINGUAS=")]
lines)))
return linguas[-1] if linguas else "" return linguas[-1] if linguas else ""
makeconf = '/etc/make.conf' makeconf = '/etc/make.conf'
@ -337,11 +336,9 @@ class VariableOsInstallClockTimezone(LocaleVariable):
try: try:
lang = self.Get(self.locale_varname).split('_')[1] lang = self.Get(self.locale_varname).split('_')[1]
nativeTZ = list(map(lambda x: x.encode('utf-8'), nativeTZ = [x.encode('utf-8') for x in country_timezones[lang]]
country_timezones[lang]))
source = nativeTZ + ["---"] + \ source = nativeTZ + ["---"] + \
sorted(filter(lambda x: not x in nativeTZ, source), sorted([x for x in source if not x in nativeTZ], key=sortkey)
key=sortkey)
except (KeyError, IndexError) as e: except (KeyError, IndexError) as e:
pass pass
return list(self.generateComments(source)) return list(self.generateComments(source))

@ -310,11 +310,9 @@ class VariableOsInstallNetName(NetHelper, ReadonlyVariable):
return "" return ""
pciEthernet = lspci(shortInfo=True) pciEthernet = lspci(shortInfo=True)
return list(map(lambda x: "{vendor} {name}".format(**x), return ["{vendor} {name}".format(**x) for x
map(lambda x: pciEthernet.get(getPci(x), in [pciEthernet.get(getPci(y), {'vendor': _("Unknown"), 'name': _("vendor")}) for y
{'vendor': _("Unknown"), in self.Get('os_install_net_interfaces')]]
'name': _("vendor")}),
self.Get('os_install_net_interfaces'))))
class VariableOsInstallNetMacType(NetHelper, ReadonlyVariable): class VariableOsInstallNetMacType(NetHelper, ReadonlyVariable):
@ -349,8 +347,7 @@ class VariableOsInstallNetMac(NetHelper, ReadonlyVariable):
self.label = _("MAC") self.label = _("MAC")
def get(self): def get(self):
return list(map(lambda x: getMac(x).lower(), return [getMac(x).lower() for x in self.Get('os_install_net_interfaces')]
self.Get('os_install_net_interfaces')))
class VariableOsInstallNetStatus(NetHelper, Variable): class VariableOsInstallNetStatus(NetHelper, Variable):
@ -363,8 +360,7 @@ class VariableOsInstallNetStatus(NetHelper, Variable):
self.label = _("IP address") self.label = _("IP address")
def get(self): def get(self):
return list(map(self.getDefaultValue, return list(map(self.getDefaultValue, self.Get('os_install_net_interfaces')))
self.Get('os_install_net_interfaces')))
def getDefaultValue(self, iface): def getDefaultValue(self, iface):
def statusValue(ipaddr, dhcp): def statusValue(ipaddr, dhcp):
@ -389,9 +385,8 @@ class VariableOsInstallNetStatus(NetHelper, Variable):
def set(self, value): def set(self, value):
value = map(lambda x: x.lower() if x else x, value) value = map(lambda x: x.lower() if x else x, value)
ifaces = self.Get('os_install_net_interfaces') ifaces = self.Get('os_install_net_interfaces')
return list(map(lambda x: self.getDefaultValue(x[1]) \ return [self.getDefaultValue(x[1]) if x[0] == "auto" else x[0] for x
if x[0] == "auto" else x[0], in zip(value, ifaces)]
zip(value, ifaces)))
def check(self, value): def check(self, value):
for status in value: for status in value:
@ -415,10 +410,10 @@ class VariableOsInstallNetIp(NetHelper, ReadonlyVariable):
self.label = _("IP address") self.label = _("IP address")
def get(self): def get(self):
return list(map(lambda x: "" if x[1].lower() == "off" else return ["" if x[1].lower() == "off" else
getIp(x[0]) if x[1].lower() == "dhcp" else x[1], getIp(x[0]) if x[1].lower() == "dhcp" else x[1] for x
zip(self.Get('os_install_net_interfaces'), in zip(self.Get('os_install_net_interfaces'),
self.Get('os_install_net_status')))) self.Get('os_install_net_status'))]
# def check(self,value): # def check(self,value):
# dhcps = self.Get('os_install_net_dhcp_set') # dhcps = self.Get('os_install_net_dhcp_set')
@ -439,9 +434,9 @@ class VariableOsInstallNetNetwork(NetHelper, ReadonlyVariable):
self.label = _("Network") self.label = _("Network")
def get(self): def get(self):
return list(map(lambda x: getIpNet(x[0], x[1]) if x[0] and x[1] else "", return [getIpNet(x[0], x[1]) if x[0] and x[1] else "" for x
zip(self.Get('os_install_net_ip'), in zip(self.Get('os_install_net_ip'),
self.Get('os_install_net_mask')))) self.Get('os_install_net_mask'))]
class VariableOsInstallNetCidr(NetHelper, ReadonlyVariable): class VariableOsInstallNetCidr(NetHelper, ReadonlyVariable):
@ -457,8 +452,7 @@ class VariableOsInstallNetCidr(NetHelper, ReadonlyVariable):
""" """
Get CIDR of ip,net (Example: 24) Get CIDR of ip,net (Example: 24)
""" """
return list(map(lambda x: maskToCidr(x) if x else '', return [maskToCidr(x) if x else '' for x in self.Get('os_install_net_mask')]
self.Get('os_install_net_mask')))
class VariableOsInstallNetMask(NetHelper, Variable): class VariableOsInstallNetMask(NetHelper, Variable):
@ -471,8 +465,8 @@ class VariableOsInstallNetMask(NetHelper, Variable):
self.label = _("Mask") self.label = _("Mask")
def get(self): def get(self):
return list(map(lambda x: cidrToMask(getMask(x)), return [cidrToMask(getMask(x)) for x
self.Get('os_install_net_interfaces'))) in self.Get('os_install_net_interfaces')]
def set(self, value): def set(self, value):
""" """
@ -490,9 +484,8 @@ class VariableOsInstallNetMask(NetHelper, Variable):
def check(self, value): def check(self, value):
dhcps = self.Get('os_install_net_status') dhcps = self.Get('os_install_net_status')
wrongMask = list(filter(lambda x: (x[0] or not x[1] in ("off", "dhcp")) and \ wrongMask = [x for x in zip(value, dhcps)
not checkMask(x[0]), if (x[0] or not x[1] in ("off", "dhcp")) and not checkMask(x[0])]
zip(value, dhcps)))
if wrongMask: if wrongMask:
raise VariableError(_("Wrong mask %s") % wrongMask[0][0]) raise VariableError(_("Wrong mask %s") % wrongMask[0][0])
@ -514,8 +507,8 @@ class VariableOsInstallNetDhcpSet(NetHelper, Variable):
self.label = _("DHCP") self.label = _("DHCP")
def get(self): def get(self):
return list(map(lambda x: "on" if x == "dhcp" else "off", return ["on" if x == "dhcp" else "off" for x
self.Get('os_install_net_status'))) in self.Get('os_install_net_status')]
class VariableOsInstallNetRouteData(NetHelper, TableVariable): class VariableOsInstallNetRouteData(NetHelper, TableVariable):
@ -544,19 +537,18 @@ class VariableOsInstallNetRouteData(NetHelper, TableVariable):
interfaces = self.Get('os_install_net_interfaces') interfaces = self.Get('os_install_net_interfaces')
interfaces_status = self.Get('os_install_net_status') interfaces_status = self.Get('os_install_net_status')
interfaces_network = self.Get('os_install_net_network') interfaces_network = self.Get('os_install_net_network')
staticInterface = \ staticInterface = [itemgetter(0, 2)(x) for x
list(map(itemgetter(0, 2), in zip(interfaces, interfaces_status, interfaces_network)
filter(lambda x: not x[1] in ("off", "dhcp"), if not x[1] in ("off", "dhcp")]
zip(interfaces, interfaces_status, interfaces_network))))
route_data = [] route_data = []
if staticInterface: if staticInterface:
staticInterface, skipNet = zip(*staticInterface) staticInterface, skipNet = zip(*staticInterface)
return list(map(lambda x: [x[0], return [[x[0],
x[1].get('via', ''), x[1].get('via', ''),
x[1].get('dev', ''), x[1].get('dev', ''),
x[1].get('src', '')], x[1].get('src', '')] for x
filter(lambda x: not x[0] in skipNet, in ip.getRouteTable(staticInterface)
ip.getRouteTable(staticInterface)))) or [[]] if not x[0] in skipNet] or [[]]
return [[]] return [[]]
def getHumanReadableAuto(self): def getHumanReadableAuto(self):
@ -602,8 +594,7 @@ class VariableOsInstallNetRouteNetwork(NetHelper, FieldValue, Variable):
filter("default".__ne__, filter("default".__ne__,
value)): value)):
raise VariableError(_("Wrong network %s") % wrongnet) raise VariableError(_("Wrong network %s") % wrongnet)
dupNetwork = list(set(filter(lambda x: value.count(x) > 1, dupNetwork = list(set([x for x in value if value.count(x) > 1]))
value)))
if dupNetwork: if dupNetwork:
raise VariableError( raise VariableError(
_("Network '%s' is used more than once") % dupNetwork[0]) _("Network '%s' is used more than once") % dupNetwork[0])
@ -632,13 +623,8 @@ class VariableOsInstallNetRouteGw(NetHelper, FieldValue, Variable):
for wrongip in filterfalse(ip.checkIp, value): for wrongip in filterfalse(ip.checkIp, value):
raise VariableError(_("Wrong gateway IP %s") % wrongip) raise VariableError(_("Wrong gateway IP %s") % wrongip)
wrongGws = [x[GW] for x in [y for y in netsGw if y[GW]]
wrongGws = list(map(lambda x: x[GW], if not ip.isIpInNet(x[GW], *(set(nets) - set(x[NET])))]
filter(lambda x: not ip.isIpInNet(x[GW],
*(set(nets) - set(
x[NET]))),
filter(lambda x: x[GW],
netsGw))))
if wrongGws: if wrongGws:
raise VariableError(_("Gateways %s are unreachable") % raise VariableError(_("Gateways %s are unreachable") %
(",".join(wrongGws))) (",".join(wrongGws)))
@ -678,8 +664,7 @@ class VariableOsInstallNetRouteSrc(NetHelper, FieldValue, Variable):
filter(None, value)): filter(None, value)):
raise VariableError(_("Wrong source IP %s") % wrongip) raise VariableError(_("Wrong source IP %s") % wrongip)
ipAddrs = self.Get('os_install_net_ip') ipAddrs = self.Get('os_install_net_ip')
wrongIps = list(filter(lambda x: x and not x in ipAddrs, wrongIps = [x for x in value if x and not x in ipAddrs]
value))
if wrongIps: if wrongIps:
raise VariableError( raise VariableError(
_("Wrong IP address %s in the specified source IP") % _("Wrong IP address %s in the specified source IP") %
@ -697,14 +682,13 @@ class VariableOsInstallNetRoute(NetHelper, ReadonlyVariable):
self.Get('os_install_net_route_dev'), self.Get('os_install_net_route_dev'),
self.Get('os_install_net_route_src')) self.Get('os_install_net_route_src'))
DEV, IP, CIDR, NET = 0, 1, 2, 1 DEV, IP, CIDR, NET = 0, 1, 2, 1
return list(map(lambda x: performFunc(x[DEV], x[NET], routeMatrix), return [performFunc(x[DEV], x[NET], routeMatrix) for x
# union ip and mask to ip/net # ip and mask to ip/net
map(lambda x: (x[DEV], ip.getIpNet(x[IP], cidr=x[CIDR])) \ in [(y[DEV], ip.getIpNet(y[IP], cidr=y[CIDR]))
if x[IP] and x[CIDR] else (x[DEV], ""), if y[IP] and y[CIDR] else (y[DEV], "") for y
# filter(lambda x:x[IP] and x[CIDR], in zip(self.Get('os_install_net_interfaces'),
zip(self.Get('os_install_net_interfaces'),
self.Get('os_install_net_ip'), self.Get('os_install_net_ip'),
self.Get('os_install_net_cidr'))))) self.Get('os_install_net_cidr'))]]
def get(self): def get(self):
"""Route info for conf.d/net""" """Route info for conf.d/net"""
@ -757,10 +741,8 @@ class VariableOsInstallNetNmroute(VariableOsInstallNetRoute):
def getRouteForInterfaceNM(interface, net, routeMatrix): def getRouteForInterfaceNM(interface, net, routeMatrix):
NET, GW, DEV, SRC = 0, 1, 2, 3 NET, GW, DEV, SRC = 0, 1, 2, 3
defaultGw = list(map(lambda x: "%s;" % x[GW], defaultGw = ["%s;" % x[GW] for x in routeMatrix
filter(lambda x: interface == x[DEV] and \ if interface == x[DEV] and x[NET] == "default"]
x[NET] == "default",
routeMatrix)))
return "{0}\n".format(defaultGw[0] if defaultGw else "") + \ return "{0}\n".format(defaultGw[0] if defaultGw else "") + \
"\n".join( "\n".join(
# build string for route from net,gateway,dev and src # build string for route from net,gateway,dev and src
@ -799,10 +781,8 @@ class VariableOsInstallNetConfAvailable(NetHelper, Variable):
with image as distr: with image as distr:
try: try:
distrPath = image.getDirectory() distrPath = image.getDirectory()
return list(map(itemgetter(0, 2), return [itemgetter(0, 2)(x) for x in mapNetConf
filter(lambda x: not x[1] or isPkgInstalled(x[1], if not x[1] or isPkgInstalled(x[1], prefix=distrPath)]
prefix=distrPath),
mapNetConf)))
except DistributiveError as e: except DistributiveError as e:
pass pass
return sorted(map(itemgetter(0, 2), mapNetConf[-1:]), key=itemgetter(1)) return sorted(map(itemgetter(0, 2), mapNetConf[-1:]), key=itemgetter(1))
@ -822,10 +802,9 @@ class VariableOsInstallNetConf(NetHelper, Variable):
def get(self): def get(self):
"""Net setup (networkmanager or openrc)""" """Net setup (networkmanager or openrc)"""
if list(filter(lambda x: x.lower() == "networkmanager", if [x for x in listDirectory('/etc/runlevels/boot') +
listDirectory('/etc/runlevels/boot') + listDirectory('/etc/runlevels/default')
listDirectory('/etc/runlevels/default'))) \ if x.lower() == "networkmanager"] or self.Get('os_root_type') == "livecd":
or self.Get('os_root_type') == "livecd":
nm = "networkmanager" nm = "networkmanager"
else: else:
nm = "" nm = ""

@ -194,10 +194,9 @@ class VariableClMigrateRootShadowPwd(ReadonlyVariable):
содержит пустую строку содержит пустую строку
""" """
def get(self): def get(self):
rootPasswd = list(map(lambda x: x[1], rootPasswd = [x[1] for x
filter("root".__eq__, in [y.split(':')[0:2] for y in readLinesFile('/etc/shadow')]
map(lambda x: x.split(':')[0:2], if "root".__eq__(x)]
readLinesFile('/etc/shadow')))))
if rootPasswd: if rootPasswd:
rootPasswd = rootPasswd[0] rootPasswd = rootPasswd[0]
else: else:
@ -419,7 +418,7 @@ class VariableClMigrateAdmin(UserHelper, Variable):
for x in self.Get('cl_migrate_user')] for x in self.Get('cl_migrate_user')]
def set(self, value): def set(self, value):
return list(map(lambda x: x if x else self.default_value, value)) return [x if x else self.default_value for x in value]
class VariableOsAvailableGroups(ReadonlyVariable): class VariableOsAvailableGroups(ReadonlyVariable):
@ -476,8 +475,7 @@ class VariableClMigrateUserGroups(UserHelper, Variable):
yield value yield value
def set(self, value): def set(self, value):
value = list(map(lambda x: sorted(list(set(self.process_groups(x)))), value = [sorted(list(set(self.process_groups(x)))) for x in value]
value))
return value return value
def getPrimaryGroup(self, username): def getPrimaryGroup(self, username):
@ -491,11 +489,9 @@ class VariableClMigrateUserGroups(UserHelper, Variable):
User groups User groups
""" """
passwdList = getPasswdUsers() passwdList = getPasswdUsers()
return list(map(lambda x: sorted(self.getPrimaryGroup(x) + return [sorted(self.getPrimaryGroup(x) + (getUserGroups(x)
(getUserGroups(x) if x in passwdList else self.getDefaultGroups())) for x
if x in passwdList else in self.Get('cl_migrate_user')]
self.getDefaultGroups())),
self.Get('cl_migrate_user')))
def choice(self): def choice(self):
""" """
@ -525,15 +521,13 @@ class VariableClMigrateUserPwd(UserHelper, Variable):
if migrateusers: if migrateusers:
lenData = 9 lenData = 9
with open(fileName) as f: with open(fileName) as f:
shadowData = list(filter(lambda x: len(x) == lenData, shadowData = [x for x in [y.rstrip().split(":") for y in f] if len(x) == lenData]
map(lambda x: x.rstrip().split(":"), f))) shadowData = [x for x in shadowData if x[0] in migrateusers]
shadowData = list(filter(lambda x: x[0] in migrateusers, shadowData)) shadowData = [(x[0], x[1]) for x in shadowData]
shadowData = list(map(lambda x: (x[0], x[1]), shadowData)) shadowUsers = [x[0] for x in shadowData]
shadowUsers = list(map(lambda x: x[0], shadowData))
for userName in migrateusers: for userName in migrateusers:
if userName in shadowUsers: if userName in shadowUsers:
userData = list(filter(lambda x: x[0] == userName, userData = [x for x in shadowData if x[0] == userName]
shadowData))
hashPwd = userData[0][1] hashPwd = userData[0][1]
if (sha256_crypt.identify(hashPwd) and if (sha256_crypt.identify(hashPwd) and
sha256_crypt.verify("guest", hashPwd)): sha256_crypt.verify("guest", hashPwd)):
@ -559,8 +553,7 @@ class VariableClMigrateUserPwd(UserHelper, Variable):
""" """
shadow_hash = get_shadow_hash() shadow_hash = get_shadow_hash()
return list(map(lambda x: x if shadow_hash.identify(x) or not x else \ return [x if shadow_hash.identify(x) or not x else shadow_hash.hash(x) for x in value]
shadow_hash.hash(x), value))
class VariableClAutologin(UserHelper, Variable): class VariableClAutologin(UserHelper, Variable):
@ -587,8 +580,8 @@ class VariableClAutologin(UserHelper, Variable):
if (not cmdDomainSet and if (not cmdDomainSet and
self.Get('os_install_root_type') == "livecd") or \ self.Get('os_install_root_type') == "livecd") or \
self.Get('os_install_linux_shortname') == "CMC": self.Get('os_install_linux_shortname') == "CMC":
nonRootUsers = list(filter(lambda x: x != "root",
self.Get('cl_migrate_user'))) nonRootUsers = [x for x in self.Get('cl_migrate_user') if x != "root"]
if nonRootUsers: if nonRootUsers:
return nonRootUsers[0] return nonRootUsers[0]
else: else:
@ -716,14 +709,10 @@ class VariableOsNvidiaMask(ReadonlyVariable):
category = "0300" category = "0300"
vendor = "10de:" vendor = "10de:"
lsPciProg = getProgPath("/usr/sbin/lspci") lsPciProg = getProgPath("/usr/sbin/lspci")
nvidiacards = list(filter(lambda x: " %s: " % category in x, nvidiacards = [x for x in process(lsPciProg, "-d", vendor, "-n")
process(lsPciProg, "-d", vendor, "-n"))) if " %s: " % category in x]
cardsid = \ cardsid = [x.groups()[0] for x
list(map(lambda x: x.groups()[0], in [re.search(r"[0-9a-fA-F]{4}:([0-9a-fA-F]{4})", y) for y in nvidiacards] if x]
filter(lambda x: x,
map(lambda x: re.search(
r"[0-9a-fA-F]{4}:([0-9a-fA-F]{4})", x),
nvidiacards))))
if not cardsid: if not cardsid:
return set() return set()
return set(cardsid) return set(cardsid)
@ -838,9 +827,10 @@ class VariableOsGrub2Path(Variable):
return grubInstall return grubInstall
# find grub-install and check, that this is grub2-install (ver 1.99) # find grub-install and check, that this is grub2-install (ver 1.99)
grubInstall = getProgPath('/usr/sbin/grub-install', prefix=chroot_path) grubInstall = getProgPath('/usr/sbin/grub-install', prefix=chroot_path)
if grubInstall and list(filter(lambda x: "1.99" in x or "2." in x,
process(chroot_cmd, chroot_path, if grubInstall and [x for x
grubInstall, '--version'))): in process(chroot_cmd, chroot_path, grubInstall, '--version')
if "1.99" in x or "2." in x]:
return grubInstall return grubInstall
return "" return ""

Loading…
Cancel
Save