Browse Source

Py3 changes

py3_forced
idziubenko 1 year ago
parent
commit
b1a5dc6e64
  1. 6
      .gitignore
  2. 42
      pym/install/distr.py
  3. 12
      pym/install/variables/X11.py
  4. 10
      pym/install/variables/audio.py
  5. 56
      pym/install/variables/autopartition.py
  6. 194
      pym/install/variables/disk.py
  7. 64
      pym/install/variables/distr.py
  8. 36
      pym/install/variables/kernel.py
  9. 16
      pym/install/variables/locale.py
  10. 96
      pym/install/variables/net.py
  11. 60
      pym/install/variables/system.py

6
.gitignore

@ -0,0 +1,6 @@
revert_changes_to_vmachine
push_to_vmachine*
.vscode
*.pyc
*.pyo
*.bak

42
pym/install/distr.py

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

12
pym/install/variables/X11.py

@ -91,8 +91,8 @@ class ResolutionVariable(VideoVariable):
"1600x900", "1600x1200", "2048x1152", "2560x1440",
"2560x1600"]
if self.fbres:
return map(lambda x: "%s-32" % x,
resolutions)
return list(map(lambda x: "%s-32" % x,
resolutions))
else:
return resolutions
@ -100,7 +100,7 @@ class ResolutionVariable(VideoVariable):
"""
Check resolution format 1234x567
"""
if not re.match('^\d+x\d+(-\d+(@\d+)?)?$', value):
if not re.match(r'^\d+x\d+(-\d+(@\d+)?)?$', value):
raise VariableError(
_("Wrong resolution {resolution} {example}").format(
resolution=value,
@ -183,7 +183,7 @@ class VariableOsInstallX11VideoAvailable(VideoVariable):
return []
def humanReadable(self):
return map(lambda x: self.driver_names.get(x, x), self.Get())
return list(map(lambda x: self.driver_names.get(x, x), self.Get()))
class VariableOsX11KmsVideoDrv(ReadonlyVariable):
@ -220,8 +220,8 @@ class VariableOsInstallX11VideoDrv(VideoVariable):
values = self.Get('os_install_x11_video_available')
else:
values = self.nox_video_drivers()
return map(lambda x: (x, self.driver_names.get(x, x)),
(x for x in self.driver_names.keys() if x in values))
return list(map(lambda x: (x, self.driver_names.get(x, x)),
(x for x in self.driver_names.keys() if x in values)))
def get(self):
if self.Get('os_install_x11_server_set') == 'on':

10
pym/install/variables/audio.py

@ -88,10 +88,10 @@ class VariableOsAudioAvailable(Variable):
with image as distr:
try:
distrPath = image.getDirectory()
return map(lambda x: x[0::2],
return list(map(lambda x: x[0::2],
filter(lambda x: not x[1] or isPkgInstalled(x[1],
prefix=distrPath),
mapAudioConf))
mapAudioConf)))
except DistributiveError as e:
pass
return sorted(map(lambda x: x[0::2], mapAudioConf[-1:]),
@ -134,7 +134,7 @@ class VariableOsAudioData(ReadonlyTableVariable):
def get(self, hr=HumanReadable.No):
# /proc/asound/card*/pcm*p/info
data = readFile('/proc/asound/cards')
cards = re.findall('^\s*(\d+).*\s-\s(.+)\n\s+\S.* at .*$',
cards = re.findall(r'^\s*(\d+).*\s-\s(.+)\n\s+\S.* at .*$',
data, re.M)
if cards:
return list(self.generate_cards(cards))
@ -211,12 +211,12 @@ class VariableOsAudioHw(Variable):
def get_deprecated(self):
asound_data = readFile('/etc/asound.conf')
default_card_re = re.compile('defaults.ctl.card\s+(\d+)')
default_card_re = re.compile(r'defaults.ctl.card\s+(\d+)')
entry = default_card_re.search(asound_data)
if entry and entry.groups()[0] in self.Get('os_audio_id'):
return "%s,0" % entry.groups()[0]
default_card_re = re.compile(
'pcm.!default {[^}]+card\s+(\d+)[^}]+device\s+(\d+)[^}]+}')
r'pcm.!default {[^}]+card\s+(\d+)[^}]+device\s+(\d+)[^}]+}')
entry = default_card_re.search(asound_data)
if entry:
entry = "%s,%s" % entry.groups()

56
pym/install/variables/autopartition.py

@ -43,16 +43,16 @@ class SizeHelper(VariableInterface):
def set(self, value):
# convert table from value to MB
sizeMap = {'kB': Sizes.kB,
'K': Sizes.K,
'M': Sizes.M,
'Mb': Sizes.Mb,
'G': Sizes.G,
'Gb': Sizes.Gb,
'T': Sizes.T,
'Tb': Sizes.Tb}
sizeMap = {r'kB': Sizes.kB,
r'K': Sizes.K,
r'M': Sizes.M,
r'Mb': Sizes.Mb,
r'G': Sizes.G,
r'Gb': Sizes.Gb,
r'T': Sizes.T,
r'Tb': Sizes.Tb}
value = value.strip()
reSizeValue = re.compile('^(\d+)\s*(%s)?' % "|".join(sizeMap.keys()))
reSizeValue = re.compile(r'^(\d+)\s*(%s)?' % r"|".join(sizeMap.keys()))
res = reSizeValue.search(value)
if not res:
return "0"
@ -98,9 +98,9 @@ class VariableHrMemorySize(ReadonlyVariable):
def get(self):
reMemTotal = re.compile(r'^MemTotal:\s*(\d+)\s*kB$')
totalMemList = filter(lambda x: x,
totalMemList = list(filter(lambda x: x,
map(reMemTotal.search,
readLinesFile('/proc/meminfo')))
readLinesFile('/proc/meminfo'))))
if totalMemList:
size = int(totalMemList[0].group(1)) * Sizes.K
return str(size)
@ -149,7 +149,7 @@ class VariableClAutopartitionDeviceData(ReadonlyTableVariable):
'cl_autopartition_device_size',
'cl_autopartition_device_name']
re_raid = re.compile("raid[1-9]")
re_raid = re.compile(r"raid[1-9]")
def get(self, hr=HumanReadable.No):
def generator():
@ -212,7 +212,7 @@ class VariableClAutopartitionDevice(AutopartitionHelper, Variable):
self.label = _("Devices for install")
def get(self):
choiceVal = map(lambda x: x[0], self.choice())
choiceVal = list(map(lambda x: x[0], self.choice()))
devicesTypes = self.Select(['os_device_dev','os_device_type'],
where='os_device_dev', _in=choiceVal)
notFlashDevices = [x[0] for x in devicesTypes if x[1] != 'flash']
@ -255,8 +255,8 @@ class VariableClAutopartitionDevice(AutopartitionHelper, Variable):
def checkOnRaid(self, valuelist):
disks = self.Select('os_disk_dev',
where='os_disk_parent', _in=valuelist)
raids = filter(None, self.Select('os_disk_raid',
where='os_disk_dev', _in=disks))
raids = list(filter(None, self.Select('os_disk_raid',
where='os_disk_dev', _in=disks)))
raidDisks = self.Select('os_disk_dev', where='os_disk_raid', _in=raids)
raidDevices = self.Select('os_disk_parent',
where='os_disk_dev',
@ -288,7 +288,7 @@ class VariableClAutopartitionDevice(AutopartitionHelper, Variable):
"""
Проверить схемы RAID, чтобы исключить базирование их на lvm
"""
typecheck = re.compile("lvm.*raid")
typecheck = re.compile(r"lvm.*raid")
for dev, fulltype in self.ZipVars("os_device_dev",
"os_device_fulltype"):
if dev in valuelist:
@ -689,17 +689,29 @@ class VariableClAutopartitionLvmVgname(Variable):
"""
def get(self):
# def generateName(startName):
# yield startName
# for i in count(20):
# yield "%s%d" % (startName, i)
# instead this just so there won't be an infinite loop
def generateName(startName):
yield startName
for i in count(20):
for i in range(20, 1000):
yield "%s%d" % (startName, i)
for name in generateName("calculate"):
disks = self.Select('os_lvm_pvname', where='os_lvm_vgname', eq=name)
devices = self.Select('os_disk_parent',
where='os_disk_dev', _in=disks)
if set(devices) <= set(self.Get('cl_autopartition_device')):
return name
#TODO should replace this
raise Exception
class VariableClAutopartitionDiskData(ReadonlyTableVariable):
@ -772,10 +784,10 @@ class VariableClAutopartitionDiskSize(DiskFilter, ReadonlyVariable):
field = "disk_size"
def get(self):
return map(str, super(VariableClAutopartitionDiskSize, self).get())
return list(map(str, super(VariableClAutopartitionDiskSize, self).get()))
def humanReadable(self):
return map(humanreadableSize, self.Get())
return list(map(humanreadableSize, self.Get()))
class VariableClAutopartitionDiskDataFull(ReadonlyTableVariable):
@ -864,10 +876,10 @@ class VariableClAutopartitionDiskSizeFull(ReadonlyVariable):
def get(self):
var_factory = self.Get('cl_autopartition_factory')
return map(str, var_factory.disk_size)
return list(map(str, var_factory.disk_size))
def humanReadable(self):
return map(humanreadableSize, self.Get())
return list(map(humanreadableSize, self.Get()))
class VariableClAutopartitionRaid(ReadonlyVariable):

194
pym/install/variables/disk.py

@ -45,13 +45,13 @@ setLocalTranslate('cl_install3', sys.modules[__name__])
class DeviceHelper(VariableInterface):
rePassDevice = re.compile("^/block/(?!%s)" % "|".join(['sr', 'fd',
'ram', 'loop']))
rePassDevice = re.compile(r"^/block/(?!%s)" % r"|".join([r'sr', r'fd',
r'ram', r'loop']))
def getBlockDevices(self):
"""Get interest devices from sys block path"""
return filter(self.rePassDevice.search,
device.udev.get_block_devices())
return list(filter(self.rePassDevice.search,
device.udev.get_block_devices()))
def separateDevice(self, dev):
"""
@ -59,8 +59,8 @@ class DeviceHelper(VariableInterface):
Using for sort. (Example: sda2 ("sda",2), md5p1 ("md",5,"p",1)
"""
return map(lambda x: int(x) if x.isdigit() else x,
re.findall('\d+|\D+', dev))
return list(map(lambda x: int(x) if x.isdigit() else x,
re.findall(r'\d+|\D+', dev)))
def mapUdevProperty(self, var, prop, default):
"""Get each element from var through udev [prop]"""
@ -164,7 +164,7 @@ class VariableOsDeviceDev(DeviceHelper, ReadonlyVariable):
Disk devices
"""
type = "list"
re_disk_raid = re.compile("^disk-.*-raid\d+$", re.I)
re_disk_raid = re.compile(r"^disk-.*-raid\d+$", re.I)
def init(self):
pass
@ -228,8 +228,8 @@ class VariableOsDeviceType(ReadonlyVariable):
device.devfs.listdir(diskIdPath, fullpath=False)))
else:
self.usbdevices = []
return map(self.getType,
self.Get('os_device_dev'))
return list(map(self.getType,
self.Get('os_device_dev')))
class VariableOsDeviceParent(ReadonlyVariable):
@ -313,8 +313,8 @@ class VariableOsDeviceMap(ReadonlyVariable):
type = "list"
def get(self):
return map(lambda x: str(x[0]),
enumerate(self.Get('os_device_dev')))
return list(map(lambda x: str(x[0]),
enumerate(self.Get('os_device_dev'))))
class VariableOsDeviceArraySet(ReadonlyVariable):
@ -334,9 +334,9 @@ class VariableOsDeviceArraySet(ReadonlyVariable):
else:
return "off"
return map(lambda x: isArray(*x),
return list(map(lambda x: isArray(*x),
zip(self.Get('os_device_dev'),
self.Get('os_device_name')))
self.Get('os_device_name'))))
class VariableOsDeviceSsdSet(ReadonlyVariable):
@ -361,9 +361,9 @@ class VariableOsDeviceSsdSet(ReadonlyVariable):
else:
return "off"
return map(lambda x: isSsd(*x),
return list(map(lambda x: isSsd(*x),
zip(self.Get('os_device_dev'),
self.Get('os_device_name')))
self.Get('os_device_name'))))
class VariableOsDeviceSyspath(ReadonlyVariable):
@ -403,10 +403,10 @@ class VariableOsDeviceVirtualSet(ReadonlyVariable):
else:
return "off"
return map(lambda x: isVirtual(*x),
return list(map(lambda x: isVirtual(*x),
zip(self.Get('os_device_dev'),
self.Get('os_device_name'),
self.Get('os_device_syspath')))
self.Get('os_device_syspath'))))
class VariableOsDeviceTable(ReadonlyVariable):
@ -444,8 +444,8 @@ class VariableOsDeviceTable(ReadonlyVariable):
else:
return getTable(dev)
return map(getByAutopartition,
self.Get('os_device_dev'))
return list(map(getByAutopartition,
self.Get('os_device_dev')))
class VariableOsDeviceName(ReadonlyVariable):
@ -475,8 +475,8 @@ class VariableOsDeviceName(ReadonlyVariable):
return ""
def get(self):
return map(self.getName,
self.Get('os_device_dev'))
return list(map(self.getName,
self.Get('os_device_dev')))
class VariableOsDeviceSize(ReadonlyVariable):
@ -487,12 +487,12 @@ class VariableOsDeviceSize(ReadonlyVariable):
def get(self):
"""Get device size"""
return map(lambda x: getPartitionSize(name=x, inBytes=True),
self.Get('os_device_dev'))
return list(map(lambda x: getPartitionSize(name=x, inBytes=True),
self.Get('os_device_dev')))
def humanReadable(self):
return map(humanreadableSize,
self.Get())
return list(map(humanreadableSize,
self.Get()))
#############################################
@ -526,7 +526,7 @@ class VariableOsDiskDev(DeviceHelper, ReadonlyVariable):
def get(self):
# получить блочные утсройства, в списке устройства с таблицей раздела
# разделены '/'
re_parent = re.compile("^/block/[^/]+")
re_parent = re.compile(r"^/block/[^/]+")
disks = self.getBlockDevices()
parents = {re_parent.search(x).group()
for x in disks if x.count("/") > 2}
@ -536,8 +536,8 @@ class VariableOsDiskDev(DeviceHelper, ReadonlyVariable):
return list(sorted((x for x in dev_names), key=self.separateDevice))
def humanReadable(self):
return map(self.getPerfectName,
self.Get())
return list(map(self.getPerfectName,
self.Get()))
class VariableOsDiskMount(DeviceHelper, ReadonlyVariable):
@ -550,8 +550,8 @@ class VariableOsDiskMount(DeviceHelper, ReadonlyVariable):
disk_hash = self.Get('os_disk_dev')
fstab = FStab('/etc/fstab', devs=disk_hash)
rootdev = self.Get('os_root_dev')
return map(lambda x: '/' if x == rootdev else fstab.getBy(eq=x) or "",
self.Get('os_disk_dev'))
return list(map(lambda x: '/' if x == rootdev else fstab.getBy(eq=x) or "",
self.Get('os_disk_dev')))
class VariableOsDiskContent(ReadonlyVariable):
@ -564,8 +564,8 @@ class VariableOsDiskContent(ReadonlyVariable):
"""
TODO: need to write
"""
return map(lambda x: "",
self.Get('os_disk_dev'))
return list(map(lambda x: "",
self.Get('os_disk_dev')))
class VariableOsDiskFormat(ReadonlyVariable):
"""
@ -593,8 +593,8 @@ class VariableOsDiskFormat(ReadonlyVariable):
pass
return fs
return map(getFormat,
self.Get('os_disk_dev'))
return list(map(getFormat,
self.Get('os_disk_dev')))
class VariableOsDiskType(ReadonlyVariable):
@ -602,8 +602,8 @@ class VariableOsDiskType(ReadonlyVariable):
List type (lvm,raid,partition,disk)
"""
type = "list"
re_raid = re.compile("-raid\d+$")
re_raid_partition = re.compile("-raid\d+-partition$")
re_raid = re.compile(r"-raid\d+$")
re_raid_partition = re.compile(r"-raid\d+-partition$")
def get(self):
"""Get partition scheme"""
@ -642,9 +642,9 @@ class VariableOsDiskType(ReadonlyVariable):
lvmUsedDisks[x].append(dev)
else:
lvmUsedDisks[x] = [dev]
return map(lambda x: x[1],
return list(map(lambda x: x[1],
map(forMember,
types))
types)))
class VariableOsDiskRaid(ReadonlyVariable):
@ -672,8 +672,8 @@ class VariableOsDiskLvm(DeviceHelper, ReadonlyVariable):
def get(self):
"""Get each element from var through udev [prop]"""
return map(self.getLvmName,
self.Get('os_disk_dev'))
return list(map(self.getLvmName,
self.Get('os_disk_dev')))
class VariableOsDiskUuid(DeviceHelper, ReadonlyVariable):
@ -723,10 +723,10 @@ class VariableOsDiskId(DeviceHelper, ReadonlyVariable):
'21686148-6449-6e6f-744e-656564454649': 'EF02',
'c12a7328-f81f-11d2-ba4b-00a0c93ec93b': 'EF00',
'0fc63daf-8483-4772-8e79-3d69d8477de4': '8300'}
return map(lambda x: mapTypeUUID.get(x, x),
return list(map(lambda x: mapTypeUUID.get(x, x),
map(lambda x: x.rpartition("x")[2],
self.mapUdevProperty('os_disk_dev', 'ID_PART_ENTRY_TYPE',
'')))
''))))
class VariableOsDiskGrub(ReadonlyVariable):
@ -753,10 +753,10 @@ class VariableOsDiskGrub(ReadonlyVariable):
else:
return ""
return map(getGrubMap,
return list(map(getGrubMap,
zip(self.Get('os_disk_dev'),
self.Get('os_disk_type'),
self.Get('os_disk_parent')))
self.Get('os_disk_parent'))))
class VariableOsDiskPart(ReadonlyVariable):
@ -786,12 +786,12 @@ class VariableOsDiskSize(ReadonlyVariable):
def get(self):
"""Get disk size"""
return map(lambda x: getPartitionSize(name=x, inBytes=True),
self.Get('os_disk_dev'))
return list(map(lambda x: getPartitionSize(name=x, inBytes=True),
self.Get('os_disk_dev')))
def humanReadable(self):
return map(humanreadableSize,
self.Get())
return list(map(humanreadableSize,
self.Get()))
class VariableOsDiskName(DeviceHelper, ReadonlyVariable):
@ -817,8 +817,8 @@ class VariableOsDiskOptions(ReadonlyVariable):
def getFormat(dev):
return fstab.getBy(what=fstab.OPTS, eq=dev)
return map(getFormat,
self.Get('os_disk_dev'))
return list(map(getFormat,
self.Get('os_disk_dev')))
################################################
@ -1042,11 +1042,11 @@ class VariableOsLocationSource(LocationHelper, DeviceHelper, Variable):
return path.normpath(val)
return val
return map(normpath, value)
return list(map(normpath, value))
def choice(self):
return map(lambda x: (x, self.getPerfectName(x) or x),
self.fixOsDiskDev(self.availDevs(choice=True))) + [("", "")]
return list(map(lambda x: (x, self.getPerfectName(x) or x),
self.fixOsDiskDev(self.availDevs(choice=True)))) + [("", "")]
def fixOsDiskDev(self, sourcelist=None):
"""
@ -1141,12 +1141,12 @@ class VariableOsLocationDest(LocationHelper, Variable):
return ""
return mount
return map(installMountPoint,
return list(map(installMountPoint,
filter(lambda x: x[0] in source,
zip(self.Get('os_disk_dev'),
self.Get('os_disk_mount')) + \
zip(self.Get('os_bind_path'),
self.Get('os_bind_mountpoint'))))
list(zip(self.Get('os_disk_dev'),
self.Get('os_disk_mount'))) + \
list(zip(self.Get('os_bind_path'),
self.Get('os_bind_mountpoint'))))))
def set(self, value):
"""Add abilitiy not specify root"""
@ -1157,7 +1157,7 @@ class VariableOsLocationDest(LocationHelper, Variable):
return val
value = map(normpath, value)
return map(lambda x: x or "/", value)
return list(map(lambda x: x or "/", value))
def choice(self):
if self.Get('cl_install_type') == 'flash':
@ -1179,7 +1179,7 @@ class VariableOsLocationDest(LocationHelper, Variable):
not "/usr" in value:
for mp, size in filter(lambda x: x[0] == '/' and x[1].isdigit() and \
int(x[1]) < minroot,
izip(value,
zip(value,
self.Get("os_location_size"))):
raise VariableError(
_("The root partition should be at least %s") % "7 Gb")
@ -1189,19 +1189,19 @@ class VariableOsLocationDest(LocationHelper, Variable):
################################
if not source:
return
if not filter(lambda x: x == "/", value):
if not list(filter(lambda x: x == "/", value)):
raise VariableError(_("To install the system, you need to "
"specify the root device"))
################################
disks = filter(lambda x: x[0].startswith('/dev/') and x[1],
zip(source, value))
disksDevs = map(lambda x: x[0], disks)
binds = filter(lambda x: not x[0].startswith('/dev/') and x[1],
zip(source, value))
disks = list(filter(lambda x: x[0].startswith('/dev/') and x[1],
zip(source, value)))
disksDevs = list(map(lambda x: x[0], disks))
binds = list(filter(lambda x: not x[0].startswith('/dev/') and x[1],
zip(source, value)))
##########################
# detect efi specifing
##########################
reEfi = re.compile("/u?efi", re.I)
reEfi = re.compile(r"/u?efi", re.I)
if any(reEfi.search(x) for x in value):
if self.Get('cl_client_type') == 'gui':
raise VariableError(
@ -1271,10 +1271,10 @@ class VariableOsLocationDest(LocationHelper, Variable):
DEVICE, MP = 0, 1
srcMountPoints = map(lambda x: x[DEVICE], binds)
destMountPoints = map(lambda x: x[MP], binds)
wrongBind = filter(lambda x: x in destMountPoints, srcMountPoints)
wrongBind = list(filter(lambda x: x in destMountPoints, srcMountPoints))
if wrongBind:
incompBind = filter(lambda x: x[1] == wrongBind[0],
zip(srcMountPoints, destMountPoints))
incompBind = list(filter(lambda x: x[1] == wrongBind[0],
zip(srcMountPoints, destMountPoints)))
raise VariableError(
_("Source directory %(src)s is already used "
"for binding '%(bindSrc)s' to '%(bindDst)s'") \
@ -1298,8 +1298,8 @@ class VariableOsLocationDest(LocationHelper, Variable):
installTypes = zip(self.Get('os_install_disk_dev'),
self.Get('os_install_disk_type'))
for checkType in ("raid", "lvm"):
memberData = filter(lambda x: checkType + "member" in x[1],
installTypes)
memberData = list(filter(lambda x: checkType + "member" in x[1],
installTypes))
if memberData:
raise VariableError(
_("Unable to use {part} partition used by active "
@ -1317,13 +1317,13 @@ class VariableOsLocationFormat(LocationHelper, Variable):
def get(self):
if self.Get('cl_autopartition_set') == "on":
return self.Get('cl_autopartition_disk_format') + \
map(lambda x: "", self.Get('cl_autopartition_bind_path'))
list(map(lambda x: "", self.Get('cl_autopartition_bind_path')))
else:
mount = self.Get("os_location_dest")
source = self.Get("os_location_source")
value = [""] * len(source)
return map(self.defaultFormat(),
zip(source, mount, value))
return list(map(self.defaultFormat(),
zip(source, mount, value)))
def choice(self):
if self.Get('cl_install_type') == "flash":
@ -1384,8 +1384,8 @@ class VariableOsLocationFormat(LocationHelper, Variable):
value = map(lambda x: "vfat" if x == "uefi" else x, value)
mount = self.Get("os_location_dest")
source = self.Get("os_location_source")
return map(self.defaultFormat(),
zip(source, mount, value))
return list(map(self.defaultFormat(),
zip(source, mount, value)))
def check(self, value):
osInstallRootType = self.Get('os_install_root_type')
@ -1423,17 +1423,17 @@ class VariableOsLocationPerformFormat(LocationHelper, Variable):
def get(self):
if self.Get('cl_autopartition_set') == "on":
return map(lambda x: "on",
self.Get('cl_autopartition_disk_format')) + \
map(lambda x: "",
self.Get('cl_autopartition_bind_path'))
return list(map(lambda x: "on",
self.Get('cl_autopartition_disk_format'))) + \
list(map(lambda x: "",
self.Get('cl_autopartition_bind_path')))
else:
mount = self.Get("os_location_dest")
source = self.Get("os_location_source")
fs = self.Get("os_location_format")
value = [""] * len(source)
return map(self.defaultPerformFormat(),
zip(source, mount, fs, value))
return list(map(self.defaultPerformFormat(),
zip(source, mount, fs, value)))
fixNtfs = lambda self, x: {'ntfs-3g': 'ntfs'}.get(x, x)
@ -1531,11 +1531,11 @@ class VariableOsLocationPerformFormat(LocationHelper, Variable):
self.Get('os_location_dest'),
self.Get('os_location_format'),
value)
return map(self.defaultPerformFormat(),
return list(map(self.defaultPerformFormat(),
map(lambda x: [x[DEV], x[MP], x[FS], ""] \
if x[FORMAT] == "off" and not x[DEV].startswith("/dev/")
else x,
info))
info)))
class VariableOsLocationSize(LocationHelper, SourceReadonlyVariable):
@ -1678,8 +1678,8 @@ class VariableOsInstallDiskDev(ReadonlyVariable, DeviceHelper):
self.Get('os_install_disk_dev_base'))
def humanReadable(self):
return map(lambda x: self.getPerfectName(x, defaultValue=x),
self.Get())
return list(map(lambda x: self.getPerfectName(x, defaultValue=x),
self.Get()))
class VariableOsInstallDiskUuid(ReadonlyVariable):
@ -1691,7 +1691,7 @@ class VariableOsInstallDiskUuid(ReadonlyVariable):
def get(self):
diskDev = self.Get('os_install_disk_dev')
hashUUID = getUUIDDict(revers=True)
return map(lambda x: hashUUID.get(x, "")[5:], diskDev)
return list(map(lambda x: hashUUID.get(x, "")[5:], diskDev))
class VariableOsInstallDiskPartuuid(ReadonlyVariable):
"""
@ -1756,9 +1756,9 @@ class VariableOsInstallDiskUse(ReadonlyVariable):
def get(self):
"""Get real id (by cl_uuid_set) device"""
if self.Get('cl_uuid_set') == "on":
return map(lambda x: "UUID=%s" % x[0] if x[0] else x[1],
return list(map(lambda x: "UUID=%s" % x[0] if x[0] else x[1],
zip(self.Get('os_install_disk_uuid'),
self.Get('os_install_disk_dev')))
self.Get('os_install_disk_dev'))))
else:
return self.Get('os_install_disk_dev')
@ -1820,11 +1820,11 @@ class VariableOsInstallDiskPerformFormat(ReadonlyVariable):
type = "bool-list"
def get(self):
_format = map(lambda x: x[2],
_format = list(map(lambda x: x[2],
filter(lambda x: x[0].startswith('/dev/') and x[1],
zip(self.Get('os_location_source'),
self.Get('os_location_dest'),
self.Get('os_location_perform_format'))))
self.Get('os_location_perform_format')))))
if self.GetBool('cl_autopartition_set'):
efiformat = ['on' for x in self.Get('os_install_uefi')]
res = efiformat + _format
@ -1880,9 +1880,9 @@ class VariableOsInstallDiskName(Variable):
else:
return diskLabel.get(dev, '')
return map(changeLabel,
return list(map(changeLabel,
self.ZipVars('os_install_disk_dev',
'os_install_disk_mount'))
'os_install_disk_mount')))
class VariableOsInstallDiskSize(SourceReadonlyVariable):
@ -2058,7 +2058,7 @@ class VariableOsInstallUefi(LocationHelper, Variable):
opt = ["--uefi"]
metavalue = "EFI"
re_not0_raid = re.compile("-raid[1-9]")
re_not0_raid = re.compile(r"-raid[1-9]")
def init(self):
self.label = _("UEFI boot")
@ -2118,7 +2118,7 @@ class VariableOsInstallUefi(LocationHelper, Variable):
return self.select('os_device_efi',
os_device_dev=efidev, limit=1) or efidev
return efidev
return filter(lambda x: x != "off", map(transform, value))
return list(filter(lambda x: x != "off", map(transform, value)))
def choice(self):
deviceParentMap = self.ZipVars('os_device_dev',
@ -2233,7 +2233,7 @@ class VariableOsInstallMbr(LocationHelper, Variable):
def set(self, value):
# support off value
return filter(lambda x: x != "off", value)
return list(filter(lambda x: x != "off", value))
def check(self, value):
if self.GetBool('cl_autopartition_set'):

64
pym/install/variables/distr.py

@ -42,21 +42,21 @@ setLocalTranslate('cl_install3', sys.modules[__name__])
class DistroRepository(Linux):
contentCache = {}
marches = ['i686', 'x86_64']
marches = [r'i686', r'x86_64']
extensiton = ['iso', 'tar.bz2', 'tar.gz', 'tar.7z', 'tar.lzma']
extensiton = [r'iso', r'tar.bz2', r'tar.gz', r'tar.7z', r'tar.lzma']
reDistName = re.compile("""
reDistName = re.compile(r"""
^.*/(?P<os_linux_shortname>%(name)s)
-(?P<os_linux_ver>%(ver)s)
(?:-(?P<serial_id>%(ser)s))?
-(?P<os_arch_machine>%(march)s)
.(?P<ext>%(ext)s)$""" %
{'name': "[a-z0-9]+",
'ver': r"(\d+\.)*\d+",
'ser': r"\d+",
'march': "|".join(marches),
'ext': "|".join(extensiton)
{r'name': r"[a-z0-9]+",
r'ver': r"(\d+\.)*\d+",
r'ser': r"\d+",
r'march': r"|".join(marches),
r'ext': r"|".join(extensiton)
}, re.X)
def _getDistrInfo(self, filename):
@ -71,9 +71,9 @@ class DistroRepository(Linux):
distdic = match.groupdict()
distdic["os_linux_build"] = ""
if "os_linux_ver" in distdic:
if re.match("^\d{8}$", distdic["os_linux_ver"]):
distdic["os_linux_build"] = distdic["os_linux_ver"]
distdic["os_linux_ver"] = ""
if re.match(r"^\d{8}$", distdic["os_linux_ver"]):
distdic[r"os_linux_build"] = distdic["os_linux_ver"]
distdic[r"os_linux_ver"] = ""
return distdic
def getImage(self, scratch, rootType, imagePath, march=None,
@ -100,7 +100,7 @@ class DistroRepository(Linux):
def opcompareByString(self, buf):
if buf:
reOp = re.compile("^(!=|=|==|<=|>=|>|<)?(\d+.*)$")
reOp = re.compile(r"^(!=|=|==|<=|>=|>|<)?(\d+.*)$")
res = reOp.search(buf)
if res:
return ({'!=': operator.ne,
@ -161,18 +161,18 @@ class DistroRepository(Linux):
return [pathname]
else:
# discard inner directories
return filter(lambda x: not path.isdir(path.join(pathname, x)),
listDirectory(pathname))
return list(filter(lambda x: not path.isdir(path.join(pathname, x)),
listDirectory(pathname)))
# get lists files in directories
allFiles = map(lambda x: map(lambda y: path.join(x, y),
listdistr(x)),
dirs)
# filter distributives
return filter(distfilter,
return list(filter(distfilter,
# join files lists to one list
reduce(lambda x, y: x + y,
allFiles, []))
allFiles, [])))
def extcomparator(self, *exts):
"""Compare extensions"""
@ -210,12 +210,12 @@ class DistroRepository(Linux):
availDistrs = self._getAvailableDistributives(dirs, system, shortname,
march, version,
build)
availDistrs = filter(lambda x: x[1] and "ext" in x[1] and
availDistrs = list(filter(lambda x: x[1] and "ext" in x[1] and
not x[1]["ext"] in discardType,
map(lambda x: (x, self._getDistrInfo(x)),
availDistrs))
return map(lambda x: x[0],
sorted(availDistrs, self.sortdistrfunc, reverse=True))
availDistrs)))
return list(map(lambda x: x[0],
sorted(availDistrs, self.sortdistrfunc, reverse=True)))
def getBestDistributive(self, dirs, system=None, shortname=None, march=None,
version=None, build=None, discardType=()):
@ -237,7 +237,7 @@ class DistroRepository(Linux):
path.join(y, x)),
listDirectory(y)),
existsdirs, [])
listimgs = filter(lambda x: x, listimgs)
listimgs = list(filter(lambda x: x, listimgs))
if listimgs:
return max(listimgs, key=keyfunc).group()
return ""
@ -245,15 +245,15 @@ class DistroRepository(Linux):
def getBestStage(self, dirs, march=None, hardened=None):
"""Get latest stage by march"""
if march:
march = {'x86_64': 'amd64'}.get(march, march)
march = {r'x86_64': r'amd64'}.get(march, march)
else:
march = "[^-]+"
march = r"[^-]+"
if hardened is None:
hardened = "(?:-hardened)?"
hardened = r"(?:-hardened)?"
elif hardened is True:
hardened = "-hardened"
hardened = r"-hardened"
elif hardened is False:
hardened = ""
hardened = r""
reStage = re.compile(r'^.*/stage3-%s%s-(\d+)\.tar\.bz2$' %
(march, hardened), re.S)
return self._findLatestFile(dirs, reStage, lambda x: x.groups()[0])
@ -500,21 +500,21 @@ class VariableClImagePath(ReadonlyVariable):
livedistr = ['/run/initramfs/squashfs',
'/run/initramfs/live',
'/mnt/cdrom']
livedistr = filter(listDirectory,
livedistr)[:1]
livedistr = list(filter(listDirectory,
livedistr))[:1]
else:
livedistr = []
# search all partition for source installation distributive
rootDev = self.Get('os_install_root_dev')
livedistr += \
map(lambda x: x[0],
list(map(lambda x: x[0],
filter(lambda x: " live" in x[1] and x[0] != rootDev,
zip(self.Get('os_disk_dev'),
self.Get('os_disk_content'))))
self.Get('os_disk_content')))))
# add to standard path
return filter(path.exists,
return list(filter(path.exists,
['/var/calculate/remote/linux',
'/var/calculate/linux'] + livedistr)
'/var/calculate/linux'] + livedistr))
class VariableClSource(ReadonlyVariable):

36
pym/install/variables/kernel.py

@ -142,10 +142,10 @@ class VariableOsInstallKernelConfig(ReadonlyVariable):
makefile_path = path.join(distr_path, kernel_src, "Makefile")
# get version from Makefile
re_makefile = re.compile("^VERSION = (\S+)\n"
"PATCHLEVEL = (\S+)\n"
"SUBLEVEL = (\S+)\n"
"EXTRAVERSION = (\S*)\n", re.M)
re_makefile = re.compile(r"^VERSION = (\S+)\n"
r"PATCHLEVEL = (\S+)\n"
r"SUBLEVEL = (\S+)\n"
r"EXTRAVERSION = (\S*)\n", re.M)
if path.exists(makefile_path):
with open(makefile_path) as f:
match = re_makefile.search(f.read(200))
@ -224,9 +224,9 @@ class VariableOsInstallKernelScheduleData(ReadonlyTableVariable):
'CONFIG_IOSCHED_NOOP=y': 'noop',
'CONFIG_IOSCHED_CFQ=y': 'cfq',
'CONFIG_IOSCHED_DEADLINE=y': 'deadline'}
installed = map(schedulers.get,
installed = list(map(schedulers.get,
filter(lambda x: x in schedulers,
self.Get('os_install_kernel_config'))) or ['cfq']
self.Get('os_install_kernel_config')))) or ['cfq']
return [[x, "on" if x in installed else "off"]
for x in sorted(schedulers.values())]
@ -332,7 +332,7 @@ class KernelHelper(VariableInterface):
Helper for kernel variables
"""
reFindVer = re.compile(
"(?<=version )(\d+\.?\d*\.?\d*\.?\d*)([^\d* ])*(\d*)")
r"(?<=version )(\d+\.?\d*\.?\d*\.?\d*)([^\d* ])*(\d*)")
def getFilesByType(self, pathname, descr):
"""Get files from "pathname" has "descr" in descriptions"""
@ -341,16 +341,16 @@ class KernelHelper(VariableInterface):
filesWithType = map(lambda x: (x, ftype(x)),
filter(path.exists,
filelist))
return filter(lambda x: x[1] and descr in x[1], filesWithType)
return list(filter(lambda x: x[1] and descr in x[1], filesWithType))
def getInitrdFiles(self, pathname):
filelist = map(lambda x: path.join(pathname, x), os.listdir(pathname))
filelist = list(map(lambda x: path.join(pathname, x), os.listdir(pathname)))
return [x for x in filelist if path.exists(x) and InitrdFile.is_cpio(x)]
def getInitrd(self, arch, shortname, chroot, kernel, suffix="",
notsuffix=""):
"""Get initrd for kernel"""
reInitrdVer = re.compile("(initrd|initramfs)-(.+?)(-install)?$", re.S)
reInitrdVer = re.compile(r"(initrd|initramfs)-(.+?)(-install)?$", re.S)
def initrd_version_by_name(filename):
resInitrdVer = reInitrdVer.search(filename)
@ -373,13 +373,13 @@ class KernelHelper(VariableInterface):
bootdir = path.join(chroot, 'boot')
initramfsFiles = self.getInitrdFiles(bootdir)
initramfsWithVer = \
filter(lambda x: (kernelVersion in x[1] or
list(filter(lambda x: (kernelVersion in x[1] or
origKernelVer in x[1]) and \
x[0].endswith(suffix) and \
(
not notsuffix or not x[0].endswith(notsuffix)),
map(lambda x: (x, initrd_version_by_name(x)),
initramfsFiles))
initramfsFiles)))
if initramfsWithVer:
return path.split(min(initramfsWithVer,
key=itemgetter(0))[0])[-1]
@ -398,17 +398,17 @@ class VariableOsInstallKernel(ReadonlyVariable, KernelHelper):
kernelFiles = self.getFilesByType(bootdir, "Linux kernel")
installMarch = self.Get('os_install_arch_machine')
kernelsWithVer = \
map(lambda x: (
list(map(lambda x: (
x[0], (getTupleVersion("".join(x[1].groups()[0:3:2])),
path.getmtime(x[0]))),
# convert version to tuple( versionTuple, mtime)
# version detect, for this version lib contains moudules
# kernel arch equal install arch
ifilter(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],
# (filename,version)
imap(lambda x: (x[0], self.reFindVer.search(x[1])),
kernelFiles)))
map(lambda x: (x[0], self.reFindVer.search(x[1])),
kernelFiles))))
if kernelsWithVer:
return path.split(max(kernelsWithVer, key=itemgetter(1))[0])[-1]
else:
@ -469,9 +469,9 @@ class VariableOsInstallKernelCpufreq(ReadonlyVariable):
def get(self):
"""Get cpufreq (and other from modules_3= param) from conf.d/modules"""
cpufreqmods = map(lambda x: x.partition('=')[2].strip("\n '\""),
cpufreqmods = list(map(lambda x: x.partition('=')[2].strip("\n '\""),
filter(lambda x: x.startswith('modules_3'),
readLinesFile('/etc/conf.d/modules')))
readLinesFile('/etc/conf.d/modules'))))
if cpufreqmods:
return cpufreqmods[0]
else:

16
pym/install/variables/locale.py

@ -53,9 +53,9 @@ class VariableOsInstallLinguas(LocaleVariable):
def get(self):
def get_linguas(lines):
linguas = map(lambda x: x.strip().rpartition('=')[-1].strip('"\''),
linguas = list(map(lambda x: x.strip().rpartition('=')[-1].strip('"\''),
filter(lambda x: x.startswith("LINGUAS="),
lines))
lines)))
return linguas[-1] if linguas else ""
makeconf = '/etc/make.conf'
@ -137,8 +137,8 @@ class VariableOsInstallLocaleLang(LocaleVariable):
return self.Get('os_locale_lang')
def choice(self):
return zip(self.Get('os_lang'),
map(str, self.Get('os_lang', humanreadable=True)))
return list(zip(self.Get('os_lang'),
map(str, self.Get('os_lang', humanreadable=True))))
class VariableOsInstallLocaleKeyboardLayout(LocaleVariable):
@ -164,8 +164,8 @@ class VariableOsInstallLocaleKeyboardLayout(LocaleVariable):
return self.Get('os_locale_keyboard_layout')
def choice(self):
return zip(self.Get('os_keyboard_layout'),
map(str, self.Get('os_keyboard_layout', humanreadable=True)))
return list(zip(self.Get('os_keyboard_layout'),
map(str, self.Get('os_keyboard_layout', humanreadable=True))))
class VariableOsInstallLocaleLanguage(LocaleVariable):