Добавлены переменные

main.os.arch.machine текущая архитектуа (i686, i386, x86_64)
main.os.arch.gentoo (x86, amd64)
install.os.arch.machine
install.os.arch.gentoo
master
parent 133ebdce00
commit 9842b85723

@ -0,0 +1,10 @@
import os
from calculate.variables.datavars import Variable, Namespace, Dependence, \
StringType, BooleanType, HashType, Calculate, Copy
from calculate.vars.main.os.func import get_arch_gentoo
with Namespace("arch"):
Variable("machine", type=StringType,
source=Copy("main.os.arch.machine"))
Variable("gentoo", type=StringType,
source=Calculate(get_arch_gentoo, ".machine"))

@ -0,0 +1,9 @@
from calculate.variables.datavars import Variable, Namespace, Dependence, \
StringType, BooleanType, HashType, Calculate
from .func import *
with Namespace("arch"):
Variable("machine", type=StringType,
source=Calculate(get_arch_machine))
Variable("gentoo", type=StringType,
source=Calculate(get_arch_gentoo, ".machine"))

@ -0,0 +1,14 @@
import re
import platform
def get_arch_machine():
return platform.machine()
def get_arch_gentoo(arch_machine):
arch = arch_machine.value
if re.search("i.86", arch):
return "x86"
else:
return {
"x86_64": "amd64"
}.get(arch,arch)

@ -1,6 +1,7 @@
import pytest
import calculate.vars.main.os.x11 as main_os_x11
import calculate.vars.main.cl as main_cl
import calculate.vars.main.os as main_os
from calculate.vars.main.cl import CmdlineParams
import mock
from itertools import chain
@ -90,3 +91,27 @@ def test_main_cl_cmdline(case):
with mock.patch('calculate.vars.main.cl.readFile') as readFile:
readFile.return_value = case["data"]
assert main_cl.get_calculate_cmdline() == case["result"]
@pytest.mark.parametrize('case',
[
{
"source": "i686",
"result": "x86"
},
{
"source": "i386",
"result": "x86"
},
{
"source": "x86_64",
"result": "amd64"
},
],
ids=lambda x:"{}->{}".format(x["source"],x["result"]))
@pytest.mark.calculate_vars
def test_main_os_get_arch_gentoo(case):
class Var:
def __init__(self, value):
self.value = value
assert main_os.get_arch_gentoo(Var(case["source"])) == case["result"]

Loading…
Cancel
Save