|
|
|
@ -294,30 +294,16 @@ class Variable(VariableInterface):
|
|
|
|
|
"""Get value of other value"""
|
|
|
|
|
if not varname or varname == self.name:
|
|
|
|
|
return self._get()
|
|
|
|
|
print("DEBUG Get")
|
|
|
|
|
print(varname)
|
|
|
|
|
|
|
|
|
|
varObj = self.parent.getInfo(varname)
|
|
|
|
|
if varname in ["os_lvm_data"]:
|
|
|
|
|
print(varname)
|
|
|
|
|
print(self.section)
|
|
|
|
|
# print(f"{self.section}.{varname}")
|
|
|
|
|
print("%s.%s" % (self.section, varname))
|
|
|
|
|
print(not "." in varname)
|
|
|
|
|
varname = f"{self.section}.{varname}"
|
|
|
|
|
print(not "." in varname)
|
|
|
|
|
print(self.parent)
|
|
|
|
|
|
|
|
|
|
# varObj.modeGet = Variable.UNCOMPAT
|
|
|
|
|
if not "." in varname:
|
|
|
|
|
# varname = "%s.%s" % tuple([self.section, varname])
|
|
|
|
|
varname = f"{self.section}.{varname}"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
res = self.parent.Get(varname, humanreadable)
|
|
|
|
|
if varname in ["install.os_lvm_data"]:
|
|
|
|
|
print("AFTER GET")
|
|
|
|
|
raise Exception
|
|
|
|
|
|
|
|
|
|
# build dependence for check and uncompatible
|
|
|
|
|
if varObj:
|
|
|
|
|
if self.modeGet == Variable.NONE:
|
|
|
|
@ -350,21 +336,12 @@ class Variable(VariableInterface):
|
|
|
|
|
"""
|
|
|
|
|
Get zipped values of variables specified by list 'argvVarNames'
|
|
|
|
|
"""
|
|
|
|
|
print("Im zipVars")
|
|
|
|
|
if "humanreadable" in kw:
|
|
|
|
|
hr = kw['humanreadable']
|
|
|
|
|
# return zip(*list(map(lambda x:self.Get(x, humanreadable=hr),
|
|
|
|
|
# argvVarNames)))
|
|
|
|
|
return list(zip(*map(lambda x:self.Get(x, humanreadable=hr),
|
|
|
|
|
argvVarNames)))
|
|
|
|
|
else:
|
|
|
|
|
print("beep")
|
|
|
|
|
print(argvVarNames)
|
|
|
|
|
tt = self.Get(argvVarNames[0])
|
|
|
|
|
print(tt)
|
|
|
|
|
raise Exception
|
|
|
|
|
tmp = list(map(self.Get, argvVarNames))
|
|
|
|
|
print(tmp)
|
|
|
|
|
|
|
|
|
|
return zip(*tmp)
|
|
|
|
|
return list(zip(*map(self.Get, argvVarNames)))
|
|
|
|
|
|
|
|
|
|
def _get_format_value(self):
|
|
|
|
|
return self._value_formatter.format(
|
|
|
|
@ -376,15 +353,9 @@ class Variable(VariableInterface):
|
|
|
|
|
Calculate value method
|
|
|
|
|
"""
|
|
|
|
|
if self.__class__.value_format:
|
|
|
|
|
val = self._get_format_value()
|
|
|
|
|
# print("DEBUG get - value_format")
|
|
|
|
|
# print(val)
|
|
|
|
|
return val
|
|
|
|
|
return self._get_format_value()
|
|
|
|
|
if self.__class__.value:
|
|
|
|
|
val = self.__class__.value
|
|
|
|
|
# print("DEBUG get - value")
|
|
|
|
|
# print(val)
|
|
|
|
|
return val
|
|
|
|
|
return self.__class__.value
|
|
|
|
|
else:
|
|
|
|
|
return [] if "list" in self.type else ""
|
|
|
|
|
|
|
|
|
@ -455,22 +426,18 @@ class Variable(VariableInterface):
|
|
|
|
|
"""
|
|
|
|
|
# variable need refill
|
|
|
|
|
if self.invalid:
|
|
|
|
|
# print('was invalid')
|
|
|
|
|
# get net value
|
|
|
|
|
if self.fullname in self.parent.iniCache and self.iniread():
|
|
|
|
|
# print("return ", self.value)
|
|
|
|
|
return self.value
|
|
|
|
|
else:
|
|
|
|
|
oldModeGet = self.modeGet
|
|
|
|
|
try:
|
|
|
|
|
# print("trying to get")
|
|
|
|
|
self.modeGet = Variable.NONE
|
|
|
|
|
value = self.get()
|
|
|
|
|
self.untrusted = self.__class__.untrusted
|
|
|
|
|
finally:
|
|
|
|
|
self.modeGet = oldModeGet
|
|
|
|
|
# if value not equal previous value
|
|
|
|
|
# print("value from get: ", value)
|
|
|
|
|
if value != self.value:
|
|
|
|
|
# invalidate depended variables
|
|
|
|
|
self.invalidate()
|
|
|
|
@ -481,15 +448,10 @@ class Variable(VariableInterface):
|
|
|
|
|
self.value = value
|
|
|
|
|
# return self.value
|
|
|
|
|
val = self.value
|
|
|
|
|
# print("DEBUGGG")
|
|
|
|
|
# print(val)
|
|
|
|
|
# print(type(val))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if isinstance(val, bytes):
|
|
|
|
|
val = str(val, encoding="UTF-8")
|
|
|
|
|
# print(val)
|
|
|
|
|
# print(type(val))
|
|
|
|
|
|
|
|
|
|
return val
|
|
|
|
|
|
|
|
|
|
def choice(self):
|
|
|
|
@ -508,7 +470,7 @@ class Variable(VariableInterface):
|
|
|
|
|
if isinstance(res, GeneratorType):
|
|
|
|
|
res = tuple(res)
|
|
|
|
|
if res and type(res[0]) in (tuple, list):
|
|
|
|
|
return zip(*res)
|
|
|
|
|
return list(zip(*res))
|
|
|
|
|
else:
|
|
|
|
|
return res, None
|
|
|
|
|
|
|
|
|
@ -1110,14 +1072,12 @@ class SimpleDataVars(object):
|
|
|
|
|
"""
|
|
|
|
|
Get zipped values of variables specified by list 'argvVarNames'
|
|
|
|
|
"""
|
|
|
|
|
print("DEBUG ZIPVARS")
|
|
|
|
|
raise Exception
|
|
|
|
|
# if "humanreadable" in kw:
|
|
|
|
|
# hr = kw['humanreadable']
|
|
|
|
|
# return zip(*list(map(lambda x:self.Get(x, humanreadable=hr),
|
|
|
|
|
# argvVarNames)))
|
|
|
|
|
# else:
|
|
|
|
|
# return zip(*list(map(self.Get, argvVarNames)))
|
|
|
|
|
if "humanreadable" in kw:
|
|
|
|
|
hr = kw['humanreadable']
|
|
|
|
|
return zip(*map(lambda x:self.Get(x, humanreadable=hr),
|
|
|
|
|
argvVarNames))
|
|
|
|
|
else:
|
|
|
|
|
return zip(*map(self.Get, argvVarNames))
|
|
|
|
|
|
|
|
|
|
def select(self, *fields, **kw):
|
|
|
|
|
"""
|
|
|
|
@ -1184,7 +1144,6 @@ class SimpleDataVars(object):
|
|
|
|
|
_if=None,
|
|
|
|
|
sort=None, sortkey=None, limit=None, zipVars=None):
|
|
|
|
|
"""Select value from table variables"""
|
|
|
|
|
print("DEBUG SELECT")
|
|
|
|
|
if zipVars is None:
|
|
|
|
|
zipVars = self.ZipVars
|
|
|
|
|
if func or _if:
|
|
|
|
@ -1209,15 +1168,10 @@ class SimpleDataVars(object):
|
|
|
|
|
else:
|
|
|
|
|
filterFunc = lambda x: x
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not type(where) in (tuple, list):
|
|
|
|
|
where = [where]
|
|
|
|
|
woffset = len(where)
|
|
|
|
|
|
|
|
|
|
print("SELECT HALFWAY")
|
|
|
|
|
print(isinstance(selField, (tuple, list)))
|
|
|
|
|
|
|
|
|
|
if isinstance(selField, (tuple, list)):
|
|
|
|
|
count = len(selField) + woffset
|
|
|
|
|
mapFunc = lambda x: x[woffset:]
|
|
|
|
@ -1227,12 +1181,6 @@ class SimpleDataVars(object):
|
|
|
|
|
count = 1 + woffset
|
|
|
|
|
fields = where + [selField]
|
|
|
|
|
mapFunc = lambda x: x[woffset]
|
|
|
|
|
print("BEEP")
|
|
|
|
|
print(fields)
|
|
|
|
|
tmp = zipVars(*fields)
|
|
|
|
|
print(tmp)
|
|
|
|
|
|
|
|
|
|
raise Exception
|
|
|
|
|
res = list(filter(filterFunc,
|
|
|
|
|
zipVars(*fields)))
|
|
|
|
|
if sort:
|
|
|
|
@ -1496,15 +1444,15 @@ class DataVars(SimpleDataVars):
|
|
|
|
|
def Get(self, varname, humanreadable=HumanReadable.No):
|
|
|
|
|
"""Threading safety Get"""
|
|
|
|
|
|
|
|
|
|
if varname in ["install.os_lvm_data"]:
|
|
|
|
|
print("DEBUG datavars Get")
|
|
|
|
|
# if varname in ["install.os_lvm_data"]:
|
|
|
|
|
# print("DEBUG datavars Get")
|
|
|
|
|
|
|
|
|
|
DataVars.l.acquire()
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
var = self.__Get(varname, humanreadable)
|
|
|
|
|
if varname in ["install.os_lvm_data"]:
|
|
|
|
|
print("DEBUG AFTER")
|
|
|
|
|
# if varname in ["install.os_lvm_data"]:
|
|
|
|
|
# print("DEBUG AFTER")
|
|
|
|
|
finally:
|
|
|
|
|
DataVars.l.release()
|
|
|
|
|
|
|
|
|
@ -1519,21 +1467,21 @@ class DataVars(SimpleDataVars):
|
|
|
|
|
return self.filledVars[varname] if varname in self.filledVars else ""
|
|
|
|
|
|
|
|
|
|
def splitVarname(self, varname):
|
|
|
|
|
if varname in ["install.os_lvm_data"]:
|
|
|
|
|
print("DEBUG in splitVarname")
|
|
|
|
|
print(varname)
|
|
|
|
|
print(type(varname))
|
|
|
|
|
# if varname in ["install.os_lvm_data"]:
|
|
|
|
|
# print("DEBUG in splitVarname")
|
|
|
|
|
# print(varname)
|
|
|
|
|
# print(type(varname))
|
|
|
|
|
res = self.reRightVar.search(varname)
|
|
|
|
|
|
|
|
|
|
if res:
|
|
|
|
|
if res.group(1):
|
|
|
|
|
if varname in ["install.os_lvm_data"]:
|
|
|
|
|
print("DEBUG2 in splitVarname")
|
|
|
|
|
print(res)
|
|
|
|
|
print(bool(res))
|
|
|
|
|
print(res.group(1))
|
|
|
|
|
print(bool(res.group(1)))
|
|
|
|
|
# raise Exception
|
|
|
|
|
# if varname in ["install.os_lvm_data"]:
|
|
|
|
|
# print("DEBUG2 in splitVarname")
|
|
|
|
|
# print(res)
|
|
|
|
|
# print(bool(res))
|
|
|
|
|
# print(res.group(1))
|
|
|
|
|
# print(bool(res.group(1)))
|
|
|
|
|
# # raise Exception
|
|
|
|
|
return res.groups()
|
|
|
|
|
else:
|
|
|
|
|
return self.defaultModule, res.group(2)
|
|
|
|
@ -1547,8 +1495,8 @@ class DataVars(SimpleDataVars):
|
|
|
|
|
try:
|
|
|
|
|
# tm = time.time()
|
|
|
|
|
# load variable if it isn't loaded
|
|
|
|
|
if varname in ["install.os_lvm_data"]:
|
|
|
|
|
print("DEBUG in __GET")
|
|
|
|
|
# if varname in ["install.os_lvm_data"]:
|
|
|
|
|
# print("DEBUG in __GET")
|
|
|
|
|
section, varname = self.splitVarname(varname)
|
|
|
|
|
|
|
|
|
|
if (varname not in self.loadVariables or
|
|
|
|
@ -1565,8 +1513,8 @@ class DataVars(SimpleDataVars):
|
|
|
|
|
if varObj.section not in (section, "main"):
|
|
|
|
|
self.raiseVariableNotFound(varname, parent=self,
|
|
|
|
|
section=section)
|
|
|
|
|
if varname in ["os_lvm_data"]:
|
|
|
|
|
print("DEBUG2 in __GET")
|
|
|
|
|
# if varname in ["os_lvm_data"]:
|
|
|
|
|
# print("DEBUG2 in __GET")
|
|
|
|
|
# if for this variable already use Get method
|
|
|
|
|
if varObj.invalid and varObj in self.requestVariables:
|
|
|
|
|
varnames = "-".join(map(lambda x: x.name,
|
|
|
|
@ -1585,8 +1533,6 @@ class DataVars(SimpleDataVars):
|
|
|
|
|
if not humanreadable:
|
|
|
|
|
if self.requestVariables:
|
|
|
|
|
self.requestVariables.pop()
|
|
|
|
|
if varname in ["os_lvm_data"]:
|
|
|
|
|
print("DEBUG3 in __GET")
|
|
|
|
|
return res
|
|
|
|
|
except BaseException:
|
|
|
|
|
while len(self.requestVariables):
|
|
|
|
|