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

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

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

@ -27,7 +27,7 @@ from calculate.lib.utils.portage import getSquashList, isPkgInstalled
from calculate.lib.variables.system import RootType from calculate.lib.variables.system import RootType
import calculate.update.variables.update as update import calculate.update.variables.update as update
from .action import Actions from .action import Actions
import linux as vars_linux from . import linux as vars_linux
import datetime import datetime
from calculate.install import distr from calculate.install import distr
import calculate.lib.utils.device as device import calculate.lib.utils.device as device
@ -618,7 +618,7 @@ class VariableClBuilderNewId(BaseBuildId):
def check(self, value): def check(self, value):
if not value and self.Get('cl_builder_source_filename'): if not value and self.Get('cl_builder_source_filename'):
raise VariableError(_("Please specify the build ID")) 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")) raise VariableError(_("Wrong symbols in the build ID"))
if value in self.Get('cl_builder_storage'): if value in self.Get('cl_builder_storage'):
raise VariableError(_("Build %s already exists") % _u8(value)) raise VariableError(_("Build %s already exists") % _u8(value))
@ -737,7 +737,7 @@ class VariableClBuilderIdPath(ReadonlyVariable):
def get(self): def get(self):
build_id = self.Get('cl_builder_id') build_id = self.Get('cl_builder_id')
if build_id: if build_id:
return re.sub("[/:]", "_", self.Get('cl_builder_id')) return re.sub(r"[/:]", "_", self.Get('cl_builder_id'))
return "" return ""
@ -789,8 +789,8 @@ class VariableClBuilderParentPath(ReadonlyVariable):
def get(self): def get(self):
builder_path = self.Get('cl_builder_path') builder_path = self.Get('cl_builder_path')
return ("../" * len(filter(None, return ("../" * len(list(filter(None,
builder_path.split('/'))))[:-1] builder_path.split('/')))))[:-1]
class VariableClBuilderStageSet(ReadonlyVariable): class VariableClBuilderStageSet(ReadonlyVariable):
@ -1139,8 +1139,8 @@ class VariableClBuilderKernelVer(KernelInfo):
return self.get_src_kernel_version(src) return self.get_src_kernel_version(src)
def get_config_version(self, configfile): def get_config_version(self, configfile):
re_config = re.compile("Automatically generated file;.*\n" re_config = re.compile(r"Automatically generated file;.*\n"
".*?Linux/\S+\s+(\S+)\s", re.M) r".*?Linux/\S+\s+(\S+)\s", re.M)
if path.exists(configfile): if path.exists(configfile):
with open(configfile) as f: with open(configfile) as f:
match = re_config.search(f.read(200)) match = re_config.search(f.read(200))
@ -1160,10 +1160,10 @@ class VariableClBuilderKernelVer(KernelInfo):
return version return version
# get version from Makefile # get version from Makefile
re_makefile = re.compile("^VERSION = (\S+)\n" re_makefile = re.compile(r"^VERSION = (\S+)\n"
"PATCHLEVEL = (\S+)\n" r"PATCHLEVEL = (\S+)\n"
"SUBLEVEL = (\S+)\n" r"SUBLEVEL = (\S+)\n"
"EXTRAVERSION = (\S*)\n", re.M) r"EXTRAVERSION = (\S*)\n", re.M)
if path.exists(makefile_path): if path.exists(makefile_path):
with open(makefile_path) as f: with open(makefile_path) as f:
match = re_makefile.search(f.read(200)) match = re_makefile.search(f.read(200))
@ -1238,7 +1238,7 @@ class VariableClBuilderKernel(KernelData):
def filter(self, iterable, version=None): def filter(self, iterable, version=None):
ftype = typeFile(magic=0x4).getMType 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: for fn in iterable:
m = re_kver.search(ftype(fn)) m = re_kver.search(ftype(fn))
if m.group(1) == version: if m.group(1) == version:
@ -1595,7 +1595,7 @@ class VariableClLivemenuPath(ReadonlyVariable):
def get(self): def get(self):
data = readFile(self.grub_config) data = readFile(self.grub_config)
m = re.search('^livepath=([^\n]+)', data, re.M) m = re.search(r'^livepath=([^\n]+)', data, re.M)
if m: if m:
return m.group(1).strip("'\"") return m.group(1).strip("'\"")
return "" return ""

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

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

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

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

Loading…
Cancel
Save