当前位置: 首页>>代码示例>>Python>>正文


Python Node.addDir方法代码示例

本文整理汇总了Python中Node.Node.addDir方法的典型用法代码示例。如果您正苦于以下问题:Python Node.addDir方法的具体用法?Python Node.addDir怎么用?Python Node.addDir使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node.Node的用法示例。


在下文中一共展示了Node.addDir方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: build

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import addDir [as 别名]

#.........这里部分代码省略.........
				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:
								raise ConfigError("Error in ini file - syntax on values statement in section %s" % section)

							tag = v[0]
							vals = v[1].split(',')
							vdict[tag] = vals
							
						h = KeyValHarvester(section, lopts, vdict, verbose)
						harvesters.append(h)
						
				else: # section does not have the necessary virtual share tags
					raise ConfigError("Error - Section %s needs tags, values, or alpha option" % section)
					

		sl = self.loadShares()
		if len(sl) == 0:
			raise ConfigError("Error - no shares are defined")

		root = Node(title, self.opts)

		if sharepage:
			shares = Node("Browse Shares", self.opts)
			for name, path, type in sl:
				if type == SHARETYPE_VIDEO:
					print "Processing video share " + name
					s = VideoShare(self.opts, name, path, vidlist, harvesters)
					print "%d Videos found" % s.VideoCount()
				else: # type == SHARETYPE_DVD
					print "Processing DVD share " + name
					s = DVDShare(self.opts, name, path, vidlist, harvesters)
					print "%d DVD Videos found" % s.VideoCount()
					
				shares.addDir(s)
			root.addDir(shares)
		else:
			for name, path, type in sl:
				if type == SHARETYPE_VIDEO:
					print "Processing video share " + name
					s = VideoShare(self.opts, name, path, vidlist, harvesters)
					print "%d Videos found" % s.VideoCount()
				else: # type == SHARETYPE_DVD
					print "Processing DVD share " + name
					s = DVDShare(self.opts, name, path, vidlist, harvesters)
					print "%d DVD Videos found" % s.VideoCount()

				root.addDir(s)
				
		root.sort()

		for h in sorted(harvesters, cmpHarvesters):
			title = h.formatDisplayText(None)
			nd = h.getNode()
			vc, gc = h.videoCount()
			if gc == None:
				print "%s count: %d videos" % (title, vc)
			else:
				print "%s count: %d videos in %d groups" % (title, vc, gc)
			root.addDir(nd)
			if verbose:
				pm = h.getPathMap()
				for k in sorted(pm.keys()):
					print "%s: %s%s%s.jpg" % (k, artworkDir, os.sep, pm[k])

		if sortroot: root.sort()
		
		self.cache = root

		return root
开发者ID:jbernardis,项目名称:pytivo-video-mgr2,代码行数:104,代码来源:VideoCache.py

示例2: harvest

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import addDir [as 别名]
	def harvest(self, vf):	
		if not Harvester.harvest(self, vf):
			return
		# get the metadata for the video we are trying to add
		mvf = vf.getMeta()
		k = self.metakey
		if not k in mvf:
			return
		
		if type(mvf[k]) is list:
			raise ConfigError("Configuration Error - tag for alpha cannot be a list")
		
		if k in [ 'title', 'episodeTitle' ] and self.opts['ignorearticle']:
			data = stripArticle(mvf[k])
		else:
			data = mvf[k]
			
		keychar = data[0].upper()
		if keychar not in AlphaKeys:
			keychar = OTHER
			
		groupTag = self.opts['group']
		if groupTag == None:
			# no grouping for this share OR video does not have
			# grouping metadata item
			if keychar not in self.nodeMap:
				# we've not seen this value yet - create a Node
				# and link it in
				path=os.path.join(self.hpath, Legalize(keychar))
				target = Node(keychar + "... ", self.opts, path=path)
				self.pathMap[os.path.join(self.name, keychar)] = path
				self.nodeMap[keychar] = target
				self.root.addDir(target)
			else:
				# otherwise we've seen it so just use it
				target = self.nodeMap[keychar]
				
			target.addVideo(vf)
					
		else:
			# otherwise we are grouping
			if groupTag not in mvf:
				grplist = [OTHER]
			else:
				grp = mvf[groupTag]
				if type(grp) is list:
					grplist = grp
				else:
					grplist = [grp]

			for grp in grplist:
				grpTitle = "%s: %s" % (metaTranslate(groupTag), grp)
				if grp not in self.nodeMap:
					path=os.path.join(self.hpath, Legalize(grp))
					grpNode = Node(grp, self.opts, title = grpTitle, path=path)
					self.pathMap[os.path.join(self.name, grp)] = path
					self.nodeMap[grp] = grpNode
					self.root.addDir(grpNode)
					self.gcount += 1
				else:
					grpNode = self.nodeMap[grp]
						
				mvkey = grpTitle + "/" + keychar
				if mvkey not in self.nodeMap:
					path=os.path.join(self.hpath, Legalize(grp), Legalize(keychar))
					target = Node(keychar + "... ", self.opts, title = mvkey + "...", path=path)
					self.pathMap[os.path.join(self.name, grp, keychar)] = path
					self.nodeMap[mvkey] = target
					grpNode.addDir(target)
				else:
					target = self.nodeMap[mvkey]
					
				target.addVideo(vf)
				
		self.count += 1
开发者ID:jbernardis,项目名称:pytivo-video-mgr2,代码行数:77,代码来源:Meta.py

示例3: harvest

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import addDir [as 别名]
	def harvest(self, vf):
		if not Harvester.harvest(self, vf):
			return
		# get the metadata for the video
		mvf = vf.getMeta()
		groupTag = self.opts['group']
		
		addlist = []
		
		# now scan through our list of keys
		mkmatch = 0
		for mk in self.metakeys:	
			# check if the video even has this key	
			if mk in mvf:
				mkmatch += 1
				# it does - get the values and build up our worklist
				if type(mvf[mk]) is list:
					for mv in mvf[mk]:
						if mv not in addlist:
							addlist.append(mv)
				else:
					mv = mvf[mk]
					if mv not in addlist:
						addlist.append(mv)
						
		if mkmatch == 0 and self.verbose:
			print "%s does not have any of meta tag(s) %s" % (vf.getFullPath(), str(self.metakeys))
					
		# now go through the worklist and build the structure as we go
		tally = False
		for mv in addlist:
			if groupTag == None:
				# no grouping for this share OR video does not have
				# grouping metadata item
				if mv not in self.nodeMap:
					# we've not seen this value yet - create a Node
					# and link it in
					target = Node(mv, self.opts)
					self.nodeMap[mv] = target
					self.root.addDir(target)
				else:
					# otherwise we've seen it so just use it
					target = self.nodeMap[mv]
					
			else:
				# otherwise we are grouping
				if groupTag not in mvf:
					grp = OTHER
				else:
					grp = mvf[groupTag]
					if type(grp) is list:
						raise ConfigError ("Configuration Error - grouping item must not be a list")

				grpTitle = "%s: %s" % (metaTranslate(groupTag), grp)
				if grp not in self.nodeMap:
					grpNode = Node(grp, self.opts, title = grpTitle)
					self.nodeMap[grp] = grpNode
					self.root.addDir(grpNode)
					self.gcount += 1
				else:
					grpNode = self.nodeMap[grp]
					
				mvkey = grpTitle + "/" + mv
				if mvkey not in self.nodeMap:
					target = Node(mv, self.opts, title = mvkey)
					self.nodeMap[mvkey] = target
					grpNode.addDir(target)
				else:
					target = self.nodeMap[mvkey]
					
			target.addVideo(vf)
			tally = True
			
		if tally:
			self.count += 1
开发者ID:thspencer,项目名称:pytivo-video-mgr2,代码行数:77,代码来源:Meta.py


注:本文中的Node.Node.addDir方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。