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.
46 lines
1.8 KiB
46 lines
1.8 KiB
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
|
StringType, HashType, TableType,\
|
|
ListType, 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)
|
|
|
|
Variable('test_3', type=ListType, source=['a', 'b', 'c'])
|
|
|
|
Variable('test_4', type=ListType, source=[1, 2, 3])
|
|
|
|
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"}])
|