parent
9140335ad5
commit
dbf841c689
@ -1,62 +1,68 @@
|
|||||||
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
def import_variables():
|
||||||
StringType, HashType, TableType,\
|
from calculate.variables.datavars import (
|
||||||
ListType, FloatType
|
Namespace,
|
||||||
|
Variable,
|
||||||
|
Dependence,
|
||||||
Variable('simple', type=StringType, source='simple value')
|
StringType,
|
||||||
|
HashType,
|
||||||
Variable('use_local_simple', type=StringType,
|
TableType,
|
||||||
source=Dependence('.simple',
|
ListType,
|
||||||
depend=lambda simple: 'Using {}'.format(
|
FloatType
|
||||||
|
)
|
||||||
|
|
||||||
|
Variable('simple', type=StringType, source='simple value')
|
||||||
|
|
||||||
|
Variable('use_local_simple', type=StringType,
|
||||||
|
source=Dependence('.simple',
|
||||||
|
depend=lambda simple: 'Using {}'.format(
|
||||||
simple.value)))
|
simple.value)))
|
||||||
|
|
||||||
Variable('use_full_simple', type=StringType,
|
Variable('use_full_simple', type=StringType,
|
||||||
source=Dependence('level.simple',
|
source=Dependence('level.simple',
|
||||||
depend=lambda simple: 'Using {}'.format(
|
depend=lambda simple: 'Using {}'.format(
|
||||||
simple.value)))
|
simple.value)))
|
||||||
|
|
||||||
Variable('disks', type=ListType,
|
Variable('disks', type=ListType,
|
||||||
source=["/dev/sda1", "/dev/sda2", "/dev/sda3"])
|
source=["/dev/sda1", "/dev/sda2", "/dev/sda3"])
|
||||||
|
|
||||||
Variable('version', type=FloatType, source='1.0')
|
Variable('version', type=FloatType, source='1.0')
|
||||||
|
|
||||||
Variable('my_shortname', type=StringType, source='CLD')
|
Variable('my_shortname', type=StringType, source='CLD')
|
||||||
|
|
||||||
Variable('linux', type=HashType,
|
Variable('linux', type=HashType,
|
||||||
source=Dependence('.version', '.my_shortname',
|
source=Dependence('.version', '.my_shortname',
|
||||||
depend=lambda version, my_shortname:
|
depend=lambda version, my_shortname:
|
||||||
{'version': version.value,
|
{'version': version.value,
|
||||||
'shortname': my_shortname.value}))
|
'shortname': my_shortname.value}))
|
||||||
|
|
||||||
Variable('shortname_test', type=StringType,
|
Variable('shortname_test', type=StringType,
|
||||||
source=Dependence('.linux.shortname',
|
source=Dependence('.linux.shortname',
|
||||||
depend=lambda shortname: '{} test'.format(
|
depend=lambda shortname: '{} test'.format(
|
||||||
shortname.value)))
|
shortname.value)))
|
||||||
|
|
||||||
Variable('device_list', type=ListType,
|
Variable('device_list', type=ListType,
|
||||||
source=["/dev/sda", "/dev/sdb"])
|
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]
|
|
||||||
|
|
||||||
|
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',
|
Variable('device', type=TableType, source=Dependence(
|
||||||
depend=get_device_table))
|
'.device_list',
|
||||||
|
depend=get_device_table))
|
||||||
|
|
||||||
Variable('device_child', type=StringType,
|
Variable('device_child', type=StringType,
|
||||||
source=Dependence('.device',
|
source=Dependence('.device',
|
||||||
depend=lambda device: device.value[0]['type']))
|
depend=lambda device: device.value[0]['type']))
|
||||||
|
|
||||||
with Namespace('level_3'):
|
with Namespace('level_3'):
|
||||||
Variable('my_var_1', type=StringType, source='testing')
|
Variable('my_var_1', type=StringType, source='testing')
|
||||||
|
|
||||||
Variable('my_var_2', type=StringType, source='testing_2')
|
Variable('my_var_2', type=StringType, source='testing_2')
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
from calculate.variables.datavars import Variable, StringType, Calculate
|
def import_variables():
|
||||||
|
from calculate.variables.datavars import Variable, StringType, Calculate
|
||||||
|
|
||||||
|
Variable('vargetter', type=StringType,
|
||||||
Variable('vargetter', type=StringType,
|
source=Calculate(lambda chroot: '{} test'.format(chroot.value),
|
||||||
source=Calculate(lambda chroot: '{} test'.format(chroot.value),
|
'main.chroot'))
|
||||||
'main.chroot'))
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from calculate.variables.datavars import Variable, StringType
|
def import_variables():
|
||||||
|
from calculate.variables.datavars import Variable, StringType
|
||||||
|
|
||||||
|
Variable('chroot', type=StringType.readonly, source='/')
|
||||||
Variable('chroot', type=StringType.readonly, source='/')
|
|
||||||
|
@ -1,19 +1,17 @@
|
|||||||
import os
|
def import_variables():
|
||||||
from calculate.variables.datavars import Variable, ListType, HashType
|
'''
|
||||||
'''
|
system:
|
||||||
system:
|
env_order -> list
|
||||||
env_order -> list
|
env_path -> hash
|
||||||
env_path -> hash
|
'''
|
||||||
'''
|
import os
|
||||||
|
from calculate.variables.datavars import Variable, ListType, HashType
|
||||||
|
|
||||||
|
TESTFILES_PATH = os.path.join(os.getcwd(), 'tests/variables/testfiles')
|
||||||
|
# Список мест, где есть calculate.ini файлы.
|
||||||
|
Variable('env_order', type=ListType, source=['system', 'local'])
|
||||||
|
|
||||||
TESTFILES_PATH = os.path.join(os.getcwd(), 'tests/variables/testfiles')
|
# Отображение множества мест, где есть calculate.ini файлы, на пути к ним.
|
||||||
|
Variable('env_path', type=HashType,
|
||||||
|
source={'system': os.path.join(TESTFILES_PATH,
|
||||||
# Список мест, где есть calculate.ini файлы.
|
'ini_vars/calculate_6.ini')})
|
||||||
Variable('env_order', type=ListType, source=['system', 'local'])
|
|
||||||
|
|
||||||
# Отображение множества мест, где есть calculate.ini файлы, на пути к ним.
|
|
||||||
Variable('env_path', type=HashType,
|
|
||||||
source={'system': os.path.join(TESTFILES_PATH,
|
|
||||||
'ini_vars/calculate_6.ini')})
|
|
||||||
|
@ -1,50 +1,60 @@
|
|||||||
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
def import_variables():
|
||||||
StringType, HashType, TableType,\
|
from calculate.variables.datavars import (
|
||||||
ListType, IntegerType, FloatType
|
Namespace,
|
||||||
|
Variable,
|
||||||
|
Dependence,
|
||||||
|
StringType,
|
||||||
|
HashType,
|
||||||
|
TableType,
|
||||||
|
IntegerType,
|
||||||
|
FloatType
|
||||||
|
)
|
||||||
|
|
||||||
with Namespace('linux'):
|
with Namespace('linux'):
|
||||||
Variable('shortname', source='', type=StringType)
|
Variable('shortname', source='', type=StringType)
|
||||||
|
|
||||||
Variable('ver', source='', type=StringType)
|
Variable('ver', source='', type=StringType)
|
||||||
|
|
||||||
Variable('fullname', source='', type=StringType)
|
Variable('fullname', source='', type=StringType)
|
||||||
|
|
||||||
Variable('subname', source='', type=StringType)
|
Variable('subname', source='', type=StringType)
|
||||||
|
|
||||||
Variable('arch', source='', type=StringType)
|
Variable('arch', source='', type=StringType)
|
||||||
|
|
||||||
Variable('test_1', source=12, type=IntegerType)
|
Variable('test_1', source=12, type=IntegerType)
|
||||||
|
|
||||||
Variable('test_2', source=1.2, type=FloatType)
|
Variable('test_2', source=1.2, type=FloatType)
|
||||||
|
|
||||||
def get_title(subname, fullname, ver):
|
def get_title(subname, fullname, ver):
|
||||||
if subname.value:
|
if subname.value:
|
||||||
return '{} {} {}'.format(fullname.value, subname.value, ver.value)
|
return '{} {} {}'.format(fullname.value,
|
||||||
else:
|
subname.value,
|
||||||
return '{} {}'.format(fullname.value, ver.value)
|
ver.value)
|
||||||
Variable('title', type=StringType,
|
else:
|
||||||
source=Dependence('.subname', '.fullname', '.ver',
|
return '{} {}'.format(fullname.value, ver.value)
|
||||||
depend=get_title))
|
Variable('title', type=StringType,
|
||||||
|
source=Dependence('.subname', '.fullname', '.ver',
|
||||||
|
depend=get_title))
|
||||||
|
|
||||||
Variable('hashvar', source={'value1': 'test1',
|
Variable('hashvar', source={'value1': 'test1',
|
||||||
'value2': 'test2'}, type=HashType)
|
'value2': 'test2'}, type=HashType)
|
||||||
|
|
||||||
Variable('hashvar_0', source={'value1': 'test1',
|
Variable('hashvar_0', source={'value1': 'test1',
|
||||||
'value2': 'test2'}, type=HashType)
|
'value2': 'test2'}, type=HashType)
|
||||||
|
|
||||||
Variable('hashvar_1', source={'key1': 'value1',
|
Variable('hashvar_1', source={'key1': 'value1',
|
||||||
'key2': 'value2'}, type=HashType)
|
'key2': 'value2'}, type=HashType)
|
||||||
|
|
||||||
Variable('hashvar_2', source={'id_1': 1349,
|
Variable('hashvar_2', source={'id_1': 1349,
|
||||||
'id_2': 1575}, type=HashType)
|
'id_2': 1575}, type=HashType)
|
||||||
|
|
||||||
Variable('calculate', type=StringType,
|
Variable('calculate', type=StringType,
|
||||||
source=Dependence('.hashvar_0',
|
source=Dependence('.hashvar_0',
|
||||||
depend=lambda hashvar: "{} {}".format(
|
depend=lambda hashvar: "{} {}".format(
|
||||||
hashvar.value['value1'],
|
hashvar.value['value1'],
|
||||||
hashvar.value['value2'])))
|
hashvar.value['value2'])))
|
||||||
|
|
||||||
Variable('tablevar', type=TableType, source=[{"dev": "/dev/sdb1",
|
Variable('tablevar', type=TableType, source=[{"dev": "/dev/sdb1",
|
||||||
"mount": "/"},
|
"mount": "/"},
|
||||||
{"dev": "/dev/sdb2",
|
{"dev": "/dev/sdb2",
|
||||||
"mount": "/var/calculate"}])
|
"mount": "/var/calculate"}])
|
||||||
|
Loading…
Reference in new issue