Исправлена работа с SimpleDataVars

develop 3.4.0_alpha5
Mike Hiretsky 9 years ago
parent 118e545272
commit deba504716

@ -789,6 +789,7 @@ class SimpleDataVars(object):
def __init__(self, *objs):
self.allVars = {}
self.cache = {}
self.changed = set()
for obj in objs:
obj.parent = self
self.allVars[obj.getVariableName()] = obj
@ -808,11 +809,14 @@ class SimpleDataVars(object):
def Set(self, varname, value):
varname = varname.rpartition(".")[2]
self.cache[varname] = value
self.changed.add(varname)
def Invalidate(self, varname):
varname = varname.rpartition(".")[2]
if varname in self.cache:
self.cache.pop(varname)
if varname in self.changed:
self.changed.remove(varname)
def GetBool(self,varname):
return Variable.isTrue(self.Get(varname))
@ -834,7 +838,7 @@ class SimpleDataVars(object):
return self.Get(item)
def __setitem__(self, key, value):
self.cache[key] = value
self.Set(key, value)
def prepare_all(self):
for var in self.allVars.keys():
@ -860,7 +864,7 @@ class SimpleDataVars(object):
(dict(config.items(varobj.section, raw=True))
if config.has_section(varobj.section)
else {})
if not varname in self.cache:
if not varname in self.changed:
val = self.unserialize(varobj.type or "string",
importVars[varobj.section].get(varname,'').encode('utf-8'))
if val and val != [[]] or varname in importVars[varobj.section]:

@ -317,16 +317,19 @@ class LinuxDataVars(SimpleDataVars):
inifile = path.join(systemRoot, os.path.dirname(makeprofile),
os.readlink(makeprofile))
self.flIniFileFrom(inifile, system_root=systemRoot)
for inifile in ("etc/calculate/calculate.env",
"etc/calculate/calculate3.env",
"etc/calculate/calculate2.env"):
self.flIniFileFrom(path.join(systemRoot, inifile),
system_root=systemRoot)
self.flCalculateEnv(systemRoot)
else:
self.cache = cache
def flCalculateEnv(self, systemRoot):
for inifile in ("etc/calculate/calculate.env",
"etc/calculate/calculate3.env",
"etc/calculate/calculate2.env"):
self.flIniFileFrom(path.join(systemRoot, inifile),
system_root=systemRoot)
def init_variables(self):
self.cache['cl_chroot_path'] = self.systemRoot
self['cl_chroot_path'] = self.systemRoot
return True
def change_root(self, dn, new_root='/'):

Loading…
Cancel
Save