py3 changes

py3_forced
idziubenko 3 years ago
parent 7af58688a6
commit ae95430482

6
.gitignore vendored

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

@ -73,6 +73,7 @@ from os import path
from .datavars import BuilderError
from .emerge_fetch import EmergeFetcher, EmergeFetcherError
from calculate.lib.utils.grub import GrubCommand
from functools import reduce
_ = lambda x: x
from calculate.lib.cl_lang import (setLocalTranslate, getLazyLocalTranslate)
@ -231,7 +232,7 @@ class Builder(Update):
:return:
"""
data = []
re_subbuild = re.compile("\/[^-]+-[^-]+-(\d+)-[^-]+$", re.I)
re_subbuild = re.compile(r"\/[^-]+-[^-]+-(\d+)-[^-]+$", re.I)
for container_dn in listDirectory(dn, fullPath=True):
with ContainerDistributive(container_dn) as distro:
info = distro.get_information()
@ -269,7 +270,7 @@ class Builder(Update):
x['release'],
x['arch'],
x['variant'])):
info = grps.next()
info = next(grps)
dist_key = "{dist}:{release}:{arch}:{variant}".format(**info)
try:
indexsystem.write("{dist};{release};{arch};"
@ -856,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('>=x11-drivers/nvidia-drivers[^"]+')
reMask = re.compile(r'>=x11-drivers/nvidia-drivers[^"]+')
for block in reBlock.findall(eclassdata):
nvidia_ids, mask_data = block
m = reMask.search(mask_data)
@ -1289,7 +1290,7 @@ class Builder(Update):
self._update_binhost_packages()
if path.exists(pathPackages):
re_keywords = re.compile(
'^(KEYWORDS|SYNC):.*$\n', re.M)
r'^(KEYWORDS|SYNC):.*$\n', re.M)
data = readFile(pathPackages)
data_blocks = data.split('\n\n')
modified_blocks = [
@ -1563,10 +1564,10 @@ class Builder(Update):
map(lambda x: os.unlink(x) if path.islink(x) else os.rmdir(x),
map(lambda x: path.join(pathname, x), dirs))
for node, mode, dmode, major, minor in [
("console", 0600, stat.S_IFCHR, 5, 1),
("tty1", 0600, stat.S_IFCHR, 4, 1),
("null", 0666, stat.S_IFCHR, 1, 3),
("zero", 0666, stat.S_IFCHR, 1, 5)]:
("console", 0o600, stat.S_IFCHR, 5, 1),
("tty1", 0o600, stat.S_IFCHR, 4, 1),
("null", 0o666, stat.S_IFCHR, 1, 3),
("zero", 0o666, stat.S_IFCHR, 1, 5)]:
nodePath = path.join(devPath, node)
os.mknod(nodePath, mode | dmode, os.makedev(major, minor))
os.chmod(nodePath, mode)
@ -1961,10 +1962,10 @@ class Builder(Update):
if all(y not in pretend for y in x)]
required_pkgs = list(set(chain(*required_pkgs)))
clear_req_pkgs = filter(
clear_req_pkgs = list(filter(
None, [x.strip() for x in system_ini.getVar(
"automagic-clear",
package["CATEGORY/PN"]).split(",")])
package["CATEGORY/PN"]).split(",")]))
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(
">>> Fetching \({c}\d+{c} of {c}\d+{c}\) {c}(.*?){c}{nl}(.*?)"
"(?=>>> Fetching|$)".format(c=_color_block, nl=_new_line), re.S)
r">>> Fetching \({c}\d+{c} of {c}\d+{c}\) {c}(.*?){c}{nl}(.*?)"
r"(?=>>> Fetching|$)".format(c=_color_block, nl=_new_line), re.S)
re_filename = re.compile("^{c} [*] {c}(\S+).*;-\)".format(c=_color_block),
re_filename = re.compile(r"^{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(
"{nl}( {c}\*{c} The driver.*to be downloaded.*?)"
"{nl}{nl}".format(c=self._color_block,
r"{nl}( {c}\*{c} The driver.*to be downloaded.*?)"
r"{nl}{nl}".format(c=self._color_block,
nl=self._new_line), data, re.S)
if extension:
extension = extension.group(1)

@ -14,10 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import action
import builder
import linux
import profiles
import images
from . import action
from . import builder
from . import linux
from . import profiles
from . import images
section = "builder"

@ -27,7 +27,7 @@ from calculate.lib.utils.portage import getSquashList, isPkgInstalled
from calculate.lib.variables.system import RootType
import calculate.update.variables.update as update
from .action import Actions
import linux as vars_linux
from . import linux as vars_linux
import datetime
from calculate.install import distr
import calculate.lib.utils.device as device
@ -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("^[A-Za-z][A-Za-z0-9/:_+-]+$", value):
if value and not re.match(r"^[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("[/:]", "_", self.Get('cl_builder_id'))
return re.sub(r"[/:]", "_", self.Get('cl_builder_id'))
return ""
@ -789,8 +789,8 @@ class VariableClBuilderParentPath(ReadonlyVariable):
def get(self):
builder_path = self.Get('cl_builder_path')
return ("../" * len(filter(None,
builder_path.split('/'))))[:-1]
return ("../" * len(list(filter(None,
builder_path.split('/')))))[:-1]
class VariableClBuilderStageSet(ReadonlyVariable):
@ -1139,8 +1139,8 @@ class VariableClBuilderKernelVer(KernelInfo):
return self.get_src_kernel_version(src)
def get_config_version(self, configfile):
re_config = re.compile("Automatically generated file;.*\n"
".*?Linux/\S+\s+(\S+)\s", re.M)
re_config = re.compile(r"Automatically generated file;.*\n"
r".*?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 +1160,10 @@ class VariableClBuilderKernelVer(KernelInfo):
return version
# 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))
@ -1238,7 +1238,7 @@ class VariableClBuilderKernel(KernelData):
def filter(self, iterable, version=None):
ftype = typeFile(magic=0x4).getMType
re_kver = re.compile("bzImage, version (\S+)\s")
re_kver = re.compile(r"bzImage, version (\S+)\s")
for fn in iterable:
m = re_kver.search(ftype(fn))
if m.group(1) == version:
@ -1595,7 +1595,7 @@ class VariableClLivemenuPath(ReadonlyVariable):
def get(self):
data = readFile(self.grub_config)
m = re.search('^livepath=([^\n]+)', data, re.M)
m = re.search(r'^livepath=([^\n]+)', data, re.M)
if m:
return m.group(1).strip("'\"")
return ""

@ -26,8 +26,8 @@ from calculate.lib.datavars import ReadonlyVariable, HumanReadable, \
ReadonlyTableVariable, FieldValue, VariableError, Variable, \
VariableInterface
from calculate.install.variables import system, X11, locale, audio
import builder
from action import Actions
from . import builder
from .action import Actions
_ = lambda x: x
@ -123,11 +123,11 @@ class VariableClBuilderImageData(ReadonlyTableVariable):
parser = re.compile(
r"^.*/(.*?)-((\d{8})|(\d[0-9.]*\d(?:_beta\d+|_alpha\d+|_rc\d+)?))"
"(-\d+)?-(x86_64|i686)\.iso$")
r"(-\d+)?-(x86_64|i686)\.iso$")
ver_parser = re.compile(
r"^.*/(.*?)-((?:\d[0-9.]*)?\d(?:_beta\d+|_alpha\d+|_rc\d+)?)"
".*\.iso$")
r".*\.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 map(lambda x: (x, self.driver_names.get(x, x)), values)
return list(map(lambda x: (x, self.driver_names.get(x, x)), values))
class VariableClBuilderAudio(GrubOptionVariable, audio.VariableOsAudio):

@ -122,7 +122,7 @@ class DataVarsBuilderLinux(linux.LinuxDataVars):
if isinstance(image, distr.ContainerDistributive):
c = image.get_information()
else:
re_stage = re.compile("stage(\d)-(amd64|x86)-(\d{8}).tar.\w+")
re_stage = re.compile(r"stage(\d)-(amd64|x86)-(\d{8}).tar.\w+")
m = re_stage.search(fn)
if m:
map_arch = {'amd64': 'x86_64', 'x86': 'i686'}
@ -481,8 +481,8 @@ class VariableClBuilderSyncOverlayRep(ReadonlyVariable):
else:
dv = self.Get('cl_builder_linux_datavars')
if dv:
return filter(lambda x: x not in ("portage", "gentoo"),
dv.Get('cl_repository_name'))
return list(filter(lambda x: x not in ("portage", "gentoo"),
dv.Get('cl_repository_name')))
else:
return []

@ -26,13 +26,13 @@ from calculate.update.update import UpdateError
from .datavars import BuilderError
from .variables.action import Actions as BuilderActions
from calculate.lib.utils.git import GitError
from utils.cl_builder_prepare import ClBuilderPrepareAction
from utils.cl_builder_profile import ClBuilderProfileAction
from utils.cl_builder_break import ClBuilderBreakAction
from utils.cl_builder_update import ClBuilderUpdateAction
from utils.cl_builder_restore import ClBuilderRestoreAction
from utils.cl_builder_image import ClBuilderImageAction
from utils.cl_builder_menu import ClBuilderMenuAction
from .utils.cl_builder_prepare import ClBuilderPrepareAction
from .utils.cl_builder_profile import ClBuilderProfileAction
from .utils.cl_builder_break import ClBuilderBreakAction
from .utils.cl_builder_update import ClBuilderUpdateAction
from .utils.cl_builder_restore import ClBuilderRestoreAction
from .utils.cl_builder_image import ClBuilderImageAction
from .utils.cl_builder_menu import ClBuilderMenuAction
_ = lambda x: x
from calculate.lib.cl_lang import setLocalTranslate, getLazyLocalTranslate

@ -1,4 +1,4 @@
#!/usr/bin/env python2
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# setup.py --- Setup script for calculate-builder

Loading…
Cancel
Save