ascendente
632b88b79f
cometimento
2e5946ed6e
@ -0,0 +1,5 @@
|
||||
from calculate.vars.datavars import Variable, ReadonlyVariable
|
||||
|
||||
class Chroot(Variable):
|
||||
properties = [ReadonlyVariable]
|
||||
value = "/"
|
@ -1,5 +1,7 @@
|
||||
from calculate.vars.datavars import Variable, ReadonlyVariable
|
||||
from calculate.variables.datavars import Variable, StringType
|
||||
'''
|
||||
main:
|
||||
chroot -> string
|
||||
'''
|
||||
|
||||
class Chroot(Variable):
|
||||
properties = [ReadonlyVariable]
|
||||
value = "/"
|
||||
Variable('chroot', type=StringType.readonly, source='/')
|
||||
|
@ -0,0 +1,13 @@
|
||||
from calculate.variables.datavars import Variable, ListType, HashType
|
||||
'''
|
||||
system:
|
||||
env_order -> list
|
||||
env_path -> hash
|
||||
'''
|
||||
|
||||
# Список мест, где есть calculate.ini файлы.
|
||||
Variable('env_order', type=ListType.readonly,
|
||||
source=['grp', 'system', 'etc', 'local', 'remote'])
|
||||
|
||||
# Отображение множества мест, где есть calculate.ini файлы, на пути к ним.
|
||||
Variable('env_path', type=HashType, source=dict())
|
@ -1,16 +1,22 @@
|
||||
import pytest
|
||||
import os
|
||||
from calculate.vars.datavars import Namespace, Variable, CyclicVariableError,\
|
||||
VariableError, ReadonlyVariable,\
|
||||
ChoiceVariable, IntegerVariable,\
|
||||
StringVariable, DefaultValue,\
|
||||
TableVariable, HashVariable,\
|
||||
VariableNotFoundError
|
||||
from calculate.vars.vars_loader import NamespaceIniFiller, VariableLoader,\
|
||||
ProfileFiller, NamespaceIniFillerStrict
|
||||
|
||||
|
||||
@pytest.mark.vars
|
||||
from calculate.variables.old_vars.datavars import Namespace, Variable,\
|
||||
CyclicVariableError,\
|
||||
VariableError,\
|
||||
ReadonlyVariable,\
|
||||
ChoiceVariable,\
|
||||
IntegerVariable,\
|
||||
StringVariable,\
|
||||
DefaultValue,\
|
||||
TableVariable, HashVariable,\
|
||||
VariableNotFoundError
|
||||
from calculate.variables.old_vars.vars_loader import NamespaceIniFiller,\
|
||||
VariableLoader,\
|
||||
ProfileFiller,\
|
||||
NamespaceIniFillerStrict
|
||||
|
||||
|
||||
@pytest.mark.old_vars
|
||||
class TestNamespace:
|
||||
def test_init_empty_namespace(self):
|
||||
ns = Namespace()
|
@ -0,0 +1,9 @@
|
||||
[main]
|
||||
chroot = /any/other/path
|
||||
|
||||
[level]
|
||||
simple = weird value
|
||||
|
||||
[os][linux]
|
||||
fullname = full_name
|
||||
shortname = SN
|
@ -0,0 +1,2 @@
|
||||
[main]
|
||||
chroot = /any/other/path
|
@ -0,0 +1,3 @@
|
||||
gentoo:main
|
||||
..
|
||||
../../../desktop
|
@ -0,0 +1,2 @@
|
||||
..
|
||||
../../20
|
@ -0,0 +1 @@
|
||||
..
|
@ -0,0 +1 @@
|
||||
..
|
@ -0,0 +1,2 @@
|
||||
[os][linux]
|
||||
arch = amd64
|
@ -0,0 +1,2 @@
|
||||
calculate:default/amd64/20/desktop
|
||||
..
|
@ -0,0 +1,21 @@
|
||||
[os][linux]
|
||||
ver = 20
|
||||
shortname = CLD
|
||||
fullname = Calculate Linux Desktop
|
||||
subname = KDE
|
||||
|
||||
[os][hashvar]
|
||||
value1 = 20
|
||||
value2 = 30
|
||||
|
||||
[os][tablevar][0]
|
||||
dev = /dev/sda1
|
||||
mount = swap
|
||||
|
||||
[os][tablevar][1]
|
||||
dev = /dev/sda2
|
||||
mount = /
|
||||
|
||||
[os][tablevar][2]
|
||||
dev = /dev/sda5
|
||||
mount = /var/calculate
|
@ -0,0 +1 @@
|
||||
..
|
@ -0,0 +1,2 @@
|
||||
calculate:default/amd64/20/desktop
|
||||
..
|
@ -0,0 +1 @@
|
||||
..
|
@ -0,0 +1,3 @@
|
||||
[os][linux]
|
||||
shortname = Calculate
|
||||
test = test
|
@ -0,0 +1,6 @@
|
||||
from calculate.variables.datavars import Namespace, Variable, StringType,\
|
||||
IntegerType, BooleanType
|
||||
|
||||
Variable('strange_variable', source='weird_value', type=StringType)
|
||||
|
||||
Variable('plain_variable', source=True, type=BooleanType)
|
@ -1,5 +1,5 @@
|
||||
from calculate.vars.alt_datavars import Namespace, Variable, StringType,\
|
||||
IntegerType
|
||||
from calculate.variables.datavars import Namespace, Variable, StringType,\
|
||||
IntegerType
|
||||
|
||||
with Namespace('ns'):
|
||||
Variable('var_1', source='value_1', type=StringType)
|
@ -1,6 +1,6 @@
|
||||
from calculate.vars.alt_datavars import Namespace, Variable, Dependence,\
|
||||
StringType, HashType, TableType,\
|
||||
ListType, FloatType
|
||||
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
||||
StringType, HashType, TableType,\
|
||||
ListType, FloatType
|
||||
|
||||
|
||||
Variable('simple', type=StringType, source='simple value')
|
@ -1,4 +1,4 @@
|
||||
from calculate.vars.alt_datavars import Variable, StringType, Dependence
|
||||
from calculate.variables.datavars import Variable, StringType, Dependence
|
||||
|
||||
|
||||
Variable('vargetter', type=StringType,
|
@ -0,0 +1,4 @@
|
||||
from calculate.variables.datavars import Variable, StringType
|
||||
|
||||
|
||||
Variable('chroot', type=StringType.readonly, source='/')
|
@ -0,0 +1,4 @@
|
||||
from calculate.variables.datavars import Variable, StringType
|
||||
|
||||
|
||||
Variable('chroot', type=StringType, source='/')
|
@ -0,0 +1,38 @@
|
||||
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
||||
StringType, HashType, TableType
|
||||
|
||||
with Namespace('linux'):
|
||||
Variable('shortname', source='', type=StringType)
|
||||
|
||||
Variable('ver', source='', type=StringType)
|
||||
|
||||
Variable('fullname', source='', type=StringType)
|
||||
|
||||
Variable('subname', source='', type=StringType)
|
||||
|
||||
Variable('arch', source='', type=StringType)
|
||||
|
||||
Variable('test', source='', type=StringType)
|
||||
|
||||
def get_title(subname, fullname, ver):
|
||||
if subname.value:
|
||||
return '{} {} {}'.format(fullname.value, subname.value, ver.value)
|
||||
else:
|
||||
return '{} {}'.format(fullname.value, ver.value)
|
||||
Variable('title', type=StringType,
|
||||
source=Dependence('.subname', '.fullname', '.ver',
|
||||
depend=get_title))
|
||||
|
||||
Variable('hashvar', source={'value1': 'test1',
|
||||
'value2': 'test2'}, type=HashType)
|
||||
|
||||
Variable('calculate', type=StringType,
|
||||
source=Dependence('.hashvar',
|
||||
depend=lambda hashvar: "{} {}".format(
|
||||
hashvar.value['value1'],
|
||||
hashvar.value['value2'])))
|
||||
|
||||
Variable('tablevar', type=TableType, source=[{"dev": "/dev/sdb1",
|
||||
"mount": "/"},
|
||||
{"dev": "/dev/sdb2",
|
||||
"mount": "/var/calculate"}])
|
@ -0,0 +1,4 @@
|
||||
from calculate.variables.datavars import Variable, StringType
|
||||
|
||||
|
||||
Variable('chroot', type=StringType, source='/')
|
@ -0,0 +1,38 @@
|
||||
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
||||
StringType, HashType, TableType
|
||||
|
||||
with Namespace('linux'):
|
||||
Variable('shortname', source='', type=StringType)
|
||||
|
||||
Variable('ver', source='', type=StringType)
|
||||
|
||||
Variable('fullname', source='', type=StringType)
|
||||
|
||||
Variable('subname', source='', type=StringType)
|
||||
|
||||
Variable('arch', source='', type=StringType)
|
||||
|
||||
Variable('test', source='', type=StringType)
|
||||
|
||||
def get_title(subname, fullname, ver):
|
||||
if subname.value:
|
||||
return '{} {} {}'.format(fullname.value, subname.value, ver.value)
|
||||
else:
|
||||
return '{} {}'.format(fullname.value, ver.value)
|
||||
Variable('title', type=StringType,
|
||||
source=Dependence('.subname', '.fullname', '.ver',
|
||||
depend=get_title))
|
||||
|
||||
Variable('hashvar', source={'value1': 'test1',
|
||||
'value2': 'test2'}, type=HashType)
|
||||
|
||||
Variable('calculate', type=StringType,
|
||||
source=Dependence('.hashvar',
|
||||
depend=lambda hashvar: "{} {}".format(
|
||||
hashvar.value['value1'],
|
||||
hashvar.value['value2'])))
|
||||
|
||||
Variable('tablevar', type=TableType, source=[{"dev": "/dev/sdb1",
|
||||
"mount": "/"},
|
||||
{"dev": "/dev/sdb2",
|
||||
"mount": "/var/calculate"}])
|
@ -0,0 +1,62 @@
|
||||
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
||||
StringType, HashType, TableType,\
|
||||
ListType, FloatType
|
||||
|
||||
|
||||
Variable('simple', type=StringType, source='simple value')
|
||||
|
||||
Variable('use_local_simple', type=StringType,
|
||||
source=Dependence('.simple',
|
||||
depend=lambda simple: 'Using {}'.format(
|
||||
simple.value)))
|
||||
|
||||
Variable('use_full_simple', type=StringType,
|
||||
source=Dependence('level.simple',
|
||||
depend=lambda simple: 'Using {}'.format(
|
||||
simple.value)))
|
||||
|
||||
Variable('disks', type=ListType,
|
||||
source=["/dev/sda1", "/dev/sda2", "/dev/sda3"])
|
||||
|
||||
Variable('version', type=FloatType, source='1.0')
|
||||
|
||||
Variable('my_shortname', type=StringType, source='CLD')
|
||||
|
||||
Variable('linux', type=HashType,
|
||||
source=Dependence('.version', '.my_shortname',
|
||||
depend=lambda version, my_shortname:
|
||||
{'version': version.value,
|
||||
'shortname': my_shortname.value}))
|
||||
|
||||
Variable('shortname_test', type=StringType,
|
||||
source=Dependence('.linux.shortname',
|
||||
depend=lambda shortname: '{} test'.format(
|
||||
shortname.value)))
|
||||
|
||||
Variable('device_list', type=ListType,
|
||||
source=["/dev/sda", "/dev/sdb"])
|
||||
|
||||
|
||||
def get_device_table(device_list):
|
||||
map_data = {'/dev/sda': ["hdd", "Samsung SSD"],
|
||||
'/dev/sdb': ["flash", "Transcend 64GB"],
|
||||
'/dev/sdc': ["usbhdd", "WD 1TB"]}
|
||||
default_value = ["hdd", "Unknown"]
|
||||
print('device_list = {}'.format(device_list.value))
|
||||
return [{"dev": device,
|
||||
"type": map_data.get(device, default_value)[0],
|
||||
"name": map_data.get(device, default_value)[1]}
|
||||
for device in device_list.value]
|
||||
|
||||
|
||||
Variable('device', type=TableType, source=Dependence('.device_list',
|
||||
depend=get_device_table))
|
||||
|
||||
Variable('device_child', type=StringType,
|
||||
source=Dependence('.device',
|
||||
depend=lambda device: device.value[0]['type']))
|
||||
|
||||
with Namespace('level_3'):
|
||||
Variable('my_var_1', type=StringType, source='testing')
|
||||
|
||||
Variable('my_var_2', type=StringType, source='testing_2')
|
@ -0,0 +1,7 @@
|
||||
from calculate.variables.datavars import Variable, StringType, Dependence
|
||||
|
||||
|
||||
Variable('vargetter', type=StringType,
|
||||
source=Dependence('main.chroot',
|
||||
depend=lambda chroot:
|
||||
'{} test'.format(chroot.value)))
|
@ -0,0 +1,4 @@
|
||||
from calculate.variables.datavars import Variable, StringType
|
||||
|
||||
|
||||
Variable('chroot', type=StringType, source='/')
|
@ -0,0 +1,38 @@
|
||||
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
||||
StringType, HashType, TableType
|
||||
|
||||
with Namespace('linux'):
|
||||
Variable('shortname', source='', type=StringType)
|
||||
|
||||
Variable('ver', source='', type=StringType)
|
||||
|
||||
Variable('fullname', source='', type=StringType)
|
||||
|
||||
Variable('subname', source='', type=StringType)
|
||||
|
||||
Variable('arch', source='', type=StringType)
|
||||
|
||||
Variable('test', source='', type=StringType)
|
||||
|
||||
def get_title(subname, fullname, ver):
|
||||
if subname.value:
|
||||
return '{} {} {}'.format(fullname.value, subname.value, ver.value)
|
||||
else:
|
||||
return '{} {}'.format(fullname.value, ver.value)
|
||||
Variable('title', type=StringType,
|
||||
source=Dependence('.subname', '.fullname', '.ver',
|
||||
depend=get_title))
|
||||
|
||||
Variable('hashvar', source={'value1': 'test1',
|
||||
'value2': 'test2'}, type=HashType)
|
||||
|
||||
Variable('calculate', type=StringType,
|
||||
source=Dependence('.hashvar',
|
||||
depend=lambda hashvar: "{} {}".format(
|
||||
hashvar.value['value1'],
|
||||
hashvar.value['value2'])))
|
||||
|
||||
Variable('tablevar', type=TableType, source=[{"dev": "/dev/sdb1",
|
||||
"mount": "/"},
|
||||
{"dev": "/dev/sdb2",
|
||||
"mount": "/var/calculate"}])
|
@ -1,6 +0,0 @@
|
||||
from calculate.vars.alt_datavars import Namespace, Variable, StringType,\
|
||||
IntegerType, BooleanType
|
||||
|
||||
Variable('strange_variable', source='weird_value', type=StringType)
|
||||
|
||||
Variable('plain_variable', source=True, type=BooleanType)
|
@ -1,5 +0,0 @@
|
||||
from calculate.vars.alt_datavars import Variable, StringType
|
||||
|
||||
|
||||
Variable('chroot', type=StringType, source='/', readonly=True)
|
||||
print('chroot really created')
|
Carregando…
Criar uma nova questão referindo esta