本文整理汇总了Python中Helper.Helper.listFindAndAdd方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.listFindAndAdd方法的具体用法?Python Helper.listFindAndAdd怎么用?Python Helper.listFindAndAdd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Helper.Helper
的用法示例。
在下文中一共展示了Helper.listFindAndAdd方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Helper import Helper [as 别名]
# 或者: from Helper.Helper import listFindAndAdd [as 别名]
class Config:
data = {}
helper = False
withDependencies = False
def __init__(self, arg):
self.withDependencies = arg
self.helper = Helper()
def getConf(self):
return self.data
# =================== Checking ====================== #
def createQueue(self, conf):
queue = []
try:
for key, vals in conf.iteritems():
if (type(vals) is list):
for val in vals:
self.checkDependencies(key, val, conf, queue)
elif (type(vals) is dict):
for name, params in vals.iteritems():
self.checkDependencies(key, name, conf, queue, params)
else:
self.checkDependencies(key, vals, conf, queue)
return self.sortQueue(queue)
except:
print sys.exc_info()
def checkDependencies(self, folder, className, conf, queue, params=False):
curClass = self.helper.getClass(folder + '.' + self.helper.ucfirst(className))()
if hasattr(curClass, 'dependencies') and self.withDependencies == '1':
for val in curClass.dependencies:
curVal = val.split('.')
if curVal[0] in conf:
if curVal[1] == conf[curVal[0]] or (hasattr(conf[curVal[0]], 'keys') and curVal[1] in conf[curVal[0]].keys()):
continue
self.checkDependencies(curVal[0], curVal[1], conf, queue)
if params:
curClass.attrs = {}
for key, val in params.iteritems():
curClass.attrs[key] = val
self.helper.listAdd(curClass, queue)
def sortQueue(self, queue):
newQueue = []
for val in queue:
if hasattr(val, 'sortOrder'):
for sortEl in val.sortOrder:
self.helper.listFindAndAdd(sortEl, queue, newQueue)
if hasattr(val, 'dependencies'):
for sortEl in val.dependencies:
self.helper.listFindAndAdd(sortEl, queue, newQueue)
self.helper.listMerge(queue, newQueue)
return newQueue
# =================== Creation ====================== #
def createConf(self):
self.data['dist'] = self.setDist()
self.data['language'] = self.setLang()
self.data['server'] = self.setServer()
# self.data['db'] = self.setDb()
return self.getConf()
def choice(self, arr, question, isRequired=False):
string = '===== '+question+' =====\n'
num = 0
for key, val in arr.iteritems():
string += str(num)+'. '+key+'\n'
num += 1;
if (isRequired is False): string += str(num)+'. Nothing\n'
curChoice = raw_input(string+'Your choice? ')
if (curChoice == str(num) and isRequired is False): print ''
try:
return arr.keys()[int(curChoice)]
except:
print 'not correct number'
func = inspect.getouterframes(inspect.currentframe())[1][3]
getattr(self, func)()
def setDist(self):
grep = self.helper.execute("cat /etc/lsb-release")
dist = grep.split('\n')[0].split('=')[1].lower()
if (dist in self.dist):
return self.dist[dist]
else:
dist = raw_input('type your linux distribution name? ').lower()
if (dist in self.dist):
return dist
else:
sys.exit('Sorry, this distribution does not supported:(')
#.........这里部分代码省略.........