本文整理汇总了Python中Node.Node.sort方法的典型用法代码示例。如果您正苦于以下问题:Python Node.sort方法的具体用法?Python Node.sort怎么用?Python Node.sort使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.sort方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import sort [as 别名]
class Harvester:
def __init__(self, name, opts):
self.name = name
self.hpath = Legalize(name)
self.opts = opts.copy()
groupTag = self.opts['group']
if groupTag == None:
self.root = Node(name, opts, path=self.hpath)
else:
self.root = Node(name, opts, path=self.hpath, title = "%s (grouped by %s)" % (name, metaTranslate(groupTag)))
self.nodeMap = {}
self.pathMap = {}
self.pathMap[name] = self.hpath
self.count = 0
self.gcount = 0
def getPathMap(self):
return self.pathMap
def formatDisplayText(self, fmt):
n = self.name
groupTag = self.opts['group']
if groupTag:
n += " (grouped by %s)" % metaTranslate(groupTag)
return n
def getNode(self):
self.root.sort()
for n in self.nodeMap.keys():
self.nodeMap[n].sort()
return self.root
def videoCount(self):
if self.opts['group'] == None:
return (self.count, None)
else:
return (self.count, self.gcount)
def harvest(self, vf):
if self.opts['shares']:
# skip the video unless it's in one of the shares
# we are including
found = False
vfsl = vf.getShareList();
for s in self.opts['shares']:
if s in vfsl:
found = True
break
if not found:
return False
return True
示例2: build
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import sort [as 别名]
def build(self, verbose=False):
def cmpHarvesters(a, b):
ta = a.formatDisplayText(None)
tb = b.formatDisplayText(None)
return cmp(ta, tb)
title = "Main Menu"
sharepage = True
sortroot = False
vidlist = VideoList()
harvesters = []
if self.cfg.has_option(OPTSECT, 'sharepage'):
v = self.cfg.get(OPTSECT, 'sharepage')
if v.lower() == 'false':
sharepage = False
if self.cfg.has_option(OPTSECT, 'topsubtitle'):
title = self.cfg.get(OPTSECT, 'topsubtitle')
if self.cfg.has_option(OPTSECT, 'sortroot'):
f = self.cfg.get(OPTSECT, 'sortroot').lower()
if f == 'true':
sortroot = True
elif f == 'false':
sortroot = False
else:
raise ConfigError("Error - sortroot must be true or false")
for section in self.cfg.sections():
if section not in [OPTSECT, 'tivos', 'pytivos']:
lopts = self.opts.copy()
if self.cfg.has_option(section, 'sort'):
lopts['sortopt'] = self.cfg.get(section,'sort').split()
if self.cfg.has_option(section, 'sortdirection'):
lval = self.cfg.get(section, 'sortdirection').lower()
if lval == 'down':
lopts['sortup'] = False
elif lval == 'up':
lopts['sortup'] = True
else:
raise ConfigError("Error in ini file - sortdirection must be up or down")
if self.cfg.has_option(section, 'tagorder'):
lval = self.cfg.get(section, 'tagorder').lower()
if lval == 'down':
lopts['tagssortup'] = False
elif lval == 'up':
lopts['tagssortup'] = True
else:
raise ConfigError("Error in ini file - tagorder must be up or down")
else:
lopts['tagssortup'] = True
if self.cfg.has_option(section, 'display)'):
lopts['dispopt'] = self.cfg.get(section, 'display').split()
if self.cfg.has_option(section, 'displaysep'):
lopts['dispsep'] = self.cfg.get(section, 'displaysep')
if self.cfg.has_option(section, 'groupby'):
lopts['group'] = self.cfg.get(section, 'groupby')
lopts['shares'] = None
if self.cfg.has_option(section, "shares"):
inc = self.cfg.get(section, "shares").split(",")
lopts['shares'] = [s.strip() for s in inc]
hasTags = self.cfg.has_option(section, 'tags')
hasValues = self.cfg.has_option(section, 'values')
hasAlpha = self.cfg.has_option(section, 'alpha')
if hasTags:
if hasValues or hasAlpha:
raise ConfigError("Error - tags, values, and alpha are mutually exclusive in section %s" % section)
h = KeySetHarvester(section, lopts, self.cfg.get(section,'tags').split(), verbose)
harvesters.append(h)
elif hasAlpha:
if hasValues:
raise ConfigError("Error - tags, values, and alpha are mutually exclusive in section %s" % section)
mkey = self.cfg.get(section, 'alpha')
h = AlphaHarvester(section, lopts, mkey, verbose)
harvesters.append(h)
elif hasValues:
if self.cfg.get(section, 'values').lower() == 'all':
h = AllHarvester(section, lopts, verbose)
harvesters.append(h)
else:
terms = self.cfg.get(section, 'values').split('/')
vdict = {}
for t in terms:
v = t.split(':')
if len(v) != 2:
#.........这里部分代码省略.........