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.
39 lines
1.5 KiB
39 lines
1.5 KiB
4 years ago
|
from calculate.variables.datavars import Namespace, Variable, Dependence,\
|
||
4 years ago
|
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,
|
||
4 years ago
|
source=Dependence('.hashvar',
|
||
|
depend=lambda hashvar: "{} {}".format(
|
||
|
hashvar.value['value1'],
|
||
|
hashvar.value['value2'])))
|
||
4 years ago
|
|
||
|
Variable('tablevar', type=TableType, source=[{"dev": "/dev/sdb1",
|
||
|
"mount": "/"},
|
||
|
{"dev": "/dev/sdb2",
|
||
|
"mount": "/var/calculate"}])
|