Modified method of printing variables.

develop
Самоукин Алексей 14 years ago
parent a2de191f04
commit f78ef27c35

Binary file not shown.

@ -612,6 +612,7 @@ storage of variables templates")%location)
%str(varsFilter))
cl_overriding.exit(1)
ret = {}
dictServicesVars = {}
for section, moduleVar, fillobj in self._importList:
dataVar = moduleVar.Data
dictVars = dir(dataVar)
@ -624,30 +625,43 @@ storage of variables templates")%location)
if reFilter and not reFilter.search(nameVar):
continue
self.Get(nameVar)
ret[nameVar] = getattr(self, nameVar)
return ret
variable = getattr(self, nameVar)
service = variable.service.lower()
ret[nameVar] = variable
if not service in dictServicesVars:
dictServicesVars[service] = {}
dictServicesVars[service][nameVar] = variable
return ret, dictServicesVars
def printVars(self, varsFilter=None, varsNames=[], outFormat="default",
verbose=1):
"""распечатать список переменных с значениями"""
var=self.getVars(varsFilter, varsNames, verbose=verbose)
if outFormat == "default":
def getLenElements(varsDict):
mlen_name=0;
mlen_type=0;
mlen_mode=0;
for i,j in var.items():
for i,j in varsDict.items():
if len(i)>mlen_name:
mlen_name=len(i)
if not '[' in var[i].mode:
mode="[%s]"%(var[i].mode.lower())
var[i].mode=mode
if not '[' in varsDict[i].mode:
mode="[%s]"%(varsDict[i].mode.lower())
varsDict[i].mode=mode
if len(mode)>mlen_mode:
mlen_mode=len(mode)
plist=var.keys()
return mlen_name, mlen_type, mlen_mode
def printVarsTable(varsDict, title, lenList=()):
"""print variables table"""
if lenList:
mlen_name, mlen_type, mlen_mode = lenList;
else:
mlen_name, mlen_type, mlen_mode = getLenElements(varsDict)
plist=varsDict.keys()
plist.sort()
br = fillstr("-",mlen_name) + " " +\
fillstr("-",mlen_mode) + " " + fillstr("-",10)
cl_overriding.printSUCCESS(_("The list of variables:"))
cl_overriding.printSUCCESS(title)
cl_overriding.printSUCCESS(br)
cl_overriding.printSUCCESS(\
_toUNICODE(_("Variable name")).center(mlen_name).encode('UTF-8') +\
" " + _("Mode") + " " +_("Value"))
@ -656,9 +670,22 @@ storage of variables templates")%location)
if i.endswith("_pw"):
p_val = "***"
else:
p_val=var[i].value
columnWrite(i, mlen_name, var[i].mode.lower(), mlen_mode, p_val)
cl_overriding.printSUCCESS(br)
p_val=varsDict[i].value
columnWrite(i, mlen_name, varsDict[i].mode.lower(),
mlen_mode, p_val)
var, dictPkgVars = self.getVars(varsFilter, varsNames, verbose=verbose)
if outFormat == "default":
lenList = getLenElements(var)
libService = 'main'
if libService in dictPkgVars:
var = dictPkgVars.pop(libService)
printVarsTable(var, _("The list of %s variables:")%'library',
lenList=lenList)
for service in dictPkgVars.keys():
var = dictPkgVars[service]
cl_overriding.printSUCCESS("")
printVarsTable(var, _("The list of %s variables:")%service,
lenList=lenList)
elif outFormat == "xml":
xmlObj = _varsXML()
varNames = sorted(var.keys())

Loading…
Cancel
Save