You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
2.2 KiB
61 lines
2.2 KiB
def import_variables():
|
|
from calculate.variables.datavars import (
|
|
Namespace,
|
|
Variable,
|
|
Dependence,
|
|
StringType,
|
|
HashType,
|
|
TableType,
|
|
IntegerType,
|
|
FloatType
|
|
)
|
|
|
|
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_1', source=12, type=IntegerType)
|
|
|
|
Variable('test_2', source=1.2, type=FloatType)
|
|
|
|
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('hashvar_0', source={'value1': 'test1',
|
|
'value2': 'test2'}, type=HashType)
|
|
|
|
Variable('hashvar_1', source={'key1': 'value1',
|
|
'key2': 'value2'}, type=HashType)
|
|
|
|
Variable('hashvar_2', source={'id_1': 1349,
|
|
'id_2': 1575}, type=HashType)
|
|
|
|
Variable('calculate', type=StringType,
|
|
source=Dependence('.hashvar_0',
|
|
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"}])
|