fixed/reverted regex

py3_forced
idziubenko 3 years ago
parent ae95430482
commit 947cf9660c

@ -232,7 +232,7 @@ class Builder(Update):
:return:
"""
data = []
re_subbuild = re.compile(r"\/[^-]+-[^-]+-(\d+)-[^-]+$", re.I)
re_subbuild = re.compile("\/[^-]+-[^-]+-(\d+)-[^-]+$", re.I)
for container_dn in listDirectory(dn, fullPath=True):
with ContainerDistributive(container_dn) as distro:
info = distro.get_information()
@ -857,7 +857,7 @@ class Builder(Update):
eclassdata = readFile(nvidia_eclass)
reBlock = re.compile(
r"if has \$\{nvidia_gpu\}\s+\\([^;]+);\s*then(.*?)fi", re.S)
reMask = re.compile(r'>=x11-drivers/nvidia-drivers[^"]+')
reMask = re.compile('>=x11-drivers/nvidia-drivers[^"]+')
for block in reBlock.findall(eclassdata):
nvidia_ids, mask_data = block
m = reMask.search(mask_data)
@ -1290,7 +1290,7 @@ class Builder(Update):
self._update_binhost_packages()
if path.exists(pathPackages):
re_keywords = re.compile(
r'^(KEYWORDS|SYNC):.*$\n', re.M)
'^(KEYWORDS|SYNC):.*$\n', re.M)
data = readFile(pathPackages)
data_blocks = data.split('\n\n')
modified_blocks = [
@ -1318,37 +1318,33 @@ class Builder(Update):
os.makedirs(pkgDir)
if path.exists(dbPkg) and path.exists(pkgDir):
# get pkg list from distro
pkgList = \
reduce(lambda x, y: x + y,
map(lambda x: map(
lambda z: path.join(x, "%s.tbz2" % z),
os.listdir(path.join(dbPkg, x))),
os.listdir(dbPkg)), [])
pkgList = reduce(lambda x, y: x + y,
((path.join(x, "%s.tbz2" % z) for z
in os.listdir(path.join(dbPkg, x))) for x
in os.listdir(dbPkg)),
[])
# get binary packages
binList = \
reduce(lambda x, y: x + y,
map(lambda x: map(
lambda z: path.join(x, z)[len(pkgDir) + 1:],
os.listdir(path.join(x))),
filter(lambda x: path.isdir(x),
map(lambda x: path.join(pkgDir, x),
os.listdir(pkgDir)))), [])
binList = reduce(lambda x, y: x + y,
((path.join(x, y)[len(pkgDir) + 1:] for y
in os.listdir(path.join(x))) for x
in (z for z in (path.join(pkgDir, o) for o
in os.listdir(pkgDir))
if path.isdir(z))),
[])
# remove files which in binary and not in db/pkg
removeList = list(set(binList) - set(pkgList))
if removeList:
removelist_str = ",".join(
path.basename(x) for x in removeList)
logger.info(removelist_str)
map(lambda x: os.unlink(x),
map(lambda x: pathJoin(pkgDir, x),
removeList))
map(lambda x: os.unlink(x),
(pathJoin(pkgDir, x) for x in removeList))
# remove empty directories
map(lambda x: os.rmdir(x),
filter(lambda x: path.isdir(x) and not os.listdir(x),
map(lambda x: path.join(pkgDir, x),
os.listdir(pkgDir))))
map(lambda x: os.rmdir(x), (x for x in (path.join(pkgDir, y) for y
in os.listdir(pkgDir))
if path.isdir(x) and not os.listdir(x)))
self.regenPackages(chrootPath, pkgDir[len(chrootPath):])
except OSError as e:
@ -1562,7 +1558,7 @@ class Builder(Update):
for pathname, dirs, files in os.walk(devPath, topdown=False):
map(lambda x: os.unlink(path.join(pathname, x)), files)
map(lambda x: os.unlink(x) if path.islink(x) else os.rmdir(x),
map(lambda x: path.join(pathname, x), dirs))
(path.join(pathname, x) for x in dirs))
for node, mode, dmode, major, minor in [
("console", 0o600, stat.S_IFCHR, 5, 1),
("tty1", 0o600, stat.S_IFCHR, 4, 1),
@ -1962,10 +1958,12 @@ class Builder(Update):
if all(y not in pretend for y in x)]
required_pkgs = list(set(chain(*required_pkgs)))
clear_req_pkgs = list(filter(
None, [x.strip() for x in system_ini.getVar(
"automagic-clear",
package["CATEGORY/PN"]).split(",")]))
clear_req_pkgs = [x for x
in [x.strip() for x
in system_ini.getVar("automagic-clear",
package["CATEGORY/PN"]).split(",")]
if x]
waste_pkgs = [x for x in clear_req_pkgs if
all(y["CATEGORY/PN"] != x
for y in required_pkgs)]

@ -46,10 +46,10 @@ class EmergeFetcher(object):
_color_block = EmergeInformationBlock._color_block
_new_line = EmergeInformationBlock._new_line
re_fetching = re.compile(
r">>> Fetching \({c}\d+{c} of {c}\d+{c}\) {c}(.*?){c}{nl}(.*?)"
r"(?=>>> Fetching|$)".format(c=_color_block, nl=_new_line), re.S)
">>> Fetching \({c}\d+{c} of {c}\d+{c}\) {c}(.*?){c}{nl}(.*?)"
"(?=>>> Fetching|$)".format(c=_color_block, nl=_new_line), re.S)
re_filename = re.compile(r"^{c} [*] {c}(\S+).*;-\)".format(c=_color_block),
re_filename = re.compile("^{c} [*] {c}(\S+).*;-\)".format(c=_color_block),
re.M)
lock_token = "is already locked by another fetcher"
@ -69,8 +69,8 @@ class EmergeFetcher(object):
errno=EmergeFetcherError.FetchErrno.Lock)
if self.manually_token in data:
extension = re.search(
r"{nl}( {c}\*{c} The driver.*to be downloaded.*?)"
r"{nl}{nl}".format(c=self._color_block,
"{nl}( {c}\*{c} The driver.*to be downloaded.*?)"
"{nl}{nl}".format(c=self._color_block,
nl=self._new_line), data, re.S)
if extension:
extension = extension.group(1)

@ -618,7 +618,7 @@ class VariableClBuilderNewId(BaseBuildId):
def check(self, value):
if not value and self.Get('cl_builder_source_filename'):
raise VariableError(_("Please specify the build ID"))
if value and not re.match(r"^[A-Za-z][A-Za-z0-9/:_+-]+$", value):
if value and not re.match("^[A-Za-z][A-Za-z0-9/:_+-]+$", value):
raise VariableError(_("Wrong symbols in the build ID"))
if value in self.Get('cl_builder_storage'):
raise VariableError(_("Build %s already exists") % _u8(value))
@ -737,7 +737,7 @@ class VariableClBuilderIdPath(ReadonlyVariable):
def get(self):
build_id = self.Get('cl_builder_id')
if build_id:
return re.sub(r"[/:]", "_", self.Get('cl_builder_id'))
return re.sub("[/:]", "_", self.Get('cl_builder_id'))
return ""
@ -789,8 +789,7 @@ class VariableClBuilderParentPath(ReadonlyVariable):
def get(self):
builder_path = self.Get('cl_builder_path')
return ("../" * len(list(filter(None,
builder_path.split('/')))))[:-1]
return ("../" * len([x for x in builder_path.split('/') if x]))[:-1]
class VariableClBuilderStageSet(ReadonlyVariable):
@ -922,7 +921,7 @@ class VariableClBuilderImageFilename(Variable):
isoname = "%s-%s-%s%s" % (shortname, buildnumber,
arch, suffix)
fullname = ""
for i_dn in filter(None, (addon_dn, dn)):
for i_dn in (x for x in (addon_dn, dn) if x):
fullname = path.join(i_dn, isoname)
if not rewrite and path.exists(fullname):
break
@ -1139,8 +1138,8 @@ class VariableClBuilderKernelVer(KernelInfo):
return self.get_src_kernel_version(src)
def get_config_version(self, configfile):
re_config = re.compile(r"Automatically generated file;.*\n"
r".*?Linux/\S+\s+(\S+)\s", re.M)
re_config = re.compile("Automatically generated file;.*\n"
".*?Linux/\S+\s+(\S+)\s", re.M)
if path.exists(configfile):
with open(configfile) as f:
match = re_config.search(f.read(200))
@ -1160,10 +1159,10 @@ class VariableClBuilderKernelVer(KernelInfo):
return version
# get version from Makefile
re_makefile = re.compile(r"^VERSION = (\S+)\n"
r"PATCHLEVEL = (\S+)\n"
r"SUBLEVEL = (\S+)\n"
r"EXTRAVERSION = (\S*)\n", re.M)
re_makefile = re.compile("^VERSION = (\S+)\n"
"PATCHLEVEL = (\S+)\n"
"SUBLEVEL = (\S+)\n"
"EXTRAVERSION = (\S*)\n", re.M)
if path.exists(makefile_path):
with open(makefile_path) as f:
match = re_makefile.search(f.read(200))
@ -1201,6 +1200,10 @@ class KernelData(ReadonlyVariable):
def get_files_by_type(self, pathname, descr):
ftype = typeFile(magic=0x4).getMType
# print("DEBUG get files by type")
# print("pathname: ", pathname)
# print("listDirectory: ", listDirectory(pathname, fullPath=True))
# raise Exception(f"path: {pathname}")
for x in listDirectory(pathname, fullPath=True):
if descr in ftype(x):
yield x
@ -1238,7 +1241,7 @@ class VariableClBuilderKernel(KernelData):
def filter(self, iterable, version=None):
ftype = typeFile(magic=0x4).getMType
re_kver = re.compile(r"bzImage, version (\S+)\s")
re_kver = re.compile("bzImage, version (\S+)\s")
for fn in iterable:
m = re_kver.search(ftype(fn))
if m.group(1) == version:

@ -123,11 +123,11 @@ class VariableClBuilderImageData(ReadonlyTableVariable):
parser = re.compile(
r"^.*/(.*?)-((\d{8})|(\d[0-9.]*\d(?:_beta\d+|_alpha\d+|_rc\d+)?))"
r"(-\d+)?-(x86_64|i686)\.iso$")
"(-\d+)?-(x86_64|i686)\.iso$")
ver_parser = re.compile(
r"^.*/(.*?)-((?:\d[0-9.]*)?\d(?:_beta\d+|_alpha\d+|_rc\d+)?)"
r".*\.iso$")
".*\.iso$")
def sortkey(self, x):
m = self.parser.search(x)
@ -307,7 +307,7 @@ class VariableClBuilderX11VideoDrv(GrubOptionVariable,
def choice(self):
values = (X11.VariableOsInstallX11VideoAvailable.supported +
[self.default_video])
return list(map(lambda x: (x, self.driver_names.get(x, x)), values))
return [(x, self.driver_names.get(x, x)) for x in values]
class VariableClBuilderAudio(GrubOptionVariable, audio.VariableOsAudio):

@ -404,8 +404,7 @@ class VariableClBuilderPortdirOverlay(ReadonlyVariable):
def get(self):
return [location
for name, location in
filter(None, self.Get('builder.cl_builder_repository_data'))
for name, location in (x for x in self.Get('builder.cl_builder_repository_data') if x)
if name not in ("portage", "gentoo")]
@ -481,8 +480,8 @@ class VariableClBuilderSyncOverlayRep(ReadonlyVariable):
else:
dv = self.Get('cl_builder_linux_datavars')
if dv:
return list(filter(lambda x: x not in ("portage", "gentoo"),
dv.Get('cl_repository_name')))
return [x for x in dv.Get('cl_repository_name')
if x not in ("portage", "gentoo")]
else:
return []

Loading…
Cancel
Save