Fixed importing of the variables modules. fixed #52

master
Иванов Денис 3 years ago
parent 6f932eab2f
commit 18df9f853a

@ -516,10 +516,8 @@ class VariableLoader:
self.logger = datavars.logger
self.ini_filler = NamespaceIniFiller()
self.variables_path = variables_path
self.variables_package = '.'.join(
variables_path[len(__file__) -
len('calculate/variables/loader.py'):].split('/'))
self.variables_path = os.path.normpath(variables_path)
self.variables_package = '.'.join(self.variables_path.split("/"))
self.repository_map = repository_map
def load_variables_package(self, package_name: str) -> None:

@ -5,9 +5,10 @@ from calculate.variables.datavars import (
Calculate,
Static
)
from calculate.vars.main.os.func import get_arch_machine, get_arch_gentoo
from .func import get_arch_machine, get_arch_gentoo
from calculate.utils.system import SystemType
import re
import os
import platform
@ -47,7 +48,7 @@ def get_version_from_gentoo_files(systemroot, profilefile):
"""Get version from gentoo files"""
systemroot = systemroot.value
gentoo_file = os.path.join(systemroot, "etc/gentoo-release")
re_ver = re.compile("^(\d+\.)*\d+$", re.S)
re_ver = re.compile(r"^(\d+\.)*\d+$", re.S)
if os.path.exists(gentoo_file):
gentoo_link = self.Get('cl_make_profile')
if os.path.islink(gentoo_link):
@ -59,7 +60,7 @@ def get_version_from_gentoo_files(systemroot, profilefile):
def get_version_from_uname():
"""Get version from uname"""
re_ver = re.search("^(\d+\.)*\d", platform.release(), re.S)
re_ver = re.search(r"^(\d+\.)*\d", platform.release(), re.S)
if re_ver:
return re_ver.group()
@ -77,24 +78,30 @@ def import_variables():
source=Calculate(get_arch_gentoo, ".machine"))
with Namespace("gentoo"):
Variable('make_profile', type=StringType, source=Calculate(lambda x:x.value,
"os.gentoo.make_profile"))
Variable('make_profile', type=StringType,
source=Calculate(lambda x: x.value,
"os.gentoo.make_profile"))
Variable("subsystem", type=StringType,
source=Calculate(lambda : SystemType.detect()))
source=Calculate(lambda: SystemType.detect()))
with Namespace("container"):
Variable("type", type=StringType, source="")
with Namespace("linux"):
Variable("shortname", type=StringType,
source=Calculate(detect_other_shortname, "main.cl.chroot_path"))
source=Calculate(detect_other_shortname,
"main.cl.chroot_path"))
Variable("name", type=StringType,
source=Calculate(dict_value, dictLinuxName, ".shortname", Static("Linux")))
source=Calculate(dict_value, dictLinuxName,
".shortname", Static("Linux")))
Variable("subname", type=StringType,
source=Calculate(dict_value, dictLinuxSubName, ".shortname", Static("")))
source=Calculate(dict_value, dictLinuxSubName,
".shortname", Static("")))
Variable("system", type=StringType,
source=Calculate(dict_value, dictNameSystem, ".shortname", Static("")))
source=Calculate(dict_value, dictNameSystem,
".shortname", Static("")))
Variable("ver", type=StringType,
source=Calculate(get_linux_version, "main.cl.chroot_path", "main.os.gentoo.make_profile"))
source=Calculate(get_linux_version, "main.cl.chroot_path",
"main.os.gentoo.make_profile"))
Variable("build", type=StringType, source="")

Loading…
Cancel
Save