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


Python Tools.keys方法代码示例

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


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

示例1: buildBouquets

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import keys [as 别名]
	def buildBouquets(self, path, provider_config, services, sections, section_identifier, preferred_order, channels_on_top, bouquets_to_hide, section_prefix):
		channels_on_top = channels_on_top[0]
		if len(section_prefix) > 0:
			section_prefix = section_prefix + " - "
		current_number = 0
		
		# as first thing we're going to cleanup channels
		# with a numeration inferior to the first section
		first_section_number = sorted(sections.keys())[0]
		for number in sorted(services["video"].keys()):
			if number >= first_section_number:
				break

			del(services["video"][number])

		print>>log, "[BouquetsWriter] Writing %s bouquet..." % section_identifier

		force_keep_numbers = False
		
		# swap channels
		swapDict = {}
		for swaprule in preferred_order:
			if swaprule[0] in services["video"] and swaprule[1] in services["video"] and services["video"][swaprule[1]]["service_type"] >= 17:
				swapDict[swaprule[0]] = swaprule[1]
				swapDict[swaprule[1]] = swaprule[0]
		
		if provider_config.isMakeNormalMain():
			bouquet_current = open(path + "/%s%s.main.tv" % (self.ABM_BOUQUET_PREFIX, section_identifier), "w")
			current_bouquet_list = []
			current_bouquet_list.append("#NAME %sAll channels\n" % section_prefix)
			
			# Clear unused sections
			sections_c = sections.copy()
			sections_c = Tools().clearsections(services, sections_c, 'ALL', "video")

			# small hack to handle the "preferred_order" list
			higher_number = sorted(services["video"].keys())[-1]
			preferred_order_tmp = []

			# expand a range into a list
			for number in range(1, higher_number + 1):
				preferred_order_tmp.append(number)

			# Always write first not hidden section on top of list
			for number in preferred_order_tmp:
				if number in sections_c and number not in bouquets_to_hide:
					current_bouquet_list.append("#SERVICE 1:64:0:0:0:0:0:0:0:0:\n")
					current_bouquet_list.append("#DESCRIPTION %s%s\n" % (section_prefix, sections_c[number]))
					first_section = number
					break
					
			# Use separate section counter. Preferred_order_tmp has swapped numbers. Can put sections on wrong places
			section_number = 1
			for number in preferred_order_tmp:
				if section_number in sections_c and section_number not in bouquets_to_hide and section_number != first_section:
					current_bouquet_list.append("#SERVICE 1:64:0:0:0:0:0:0:0:0:\n")
					current_bouquet_list.append("#DESCRIPTION %s%s\n" % (section_prefix, sections_c[section_number]))
				if number in swapDict:
					number = swapDict[number]
				if number in services["video"] and number not in bouquets_to_hide:
					current_bouquet_list.append("#SERVICE 1:0:%x:%x:%x:%x:%x:0:0:0:\n" % (
							services["video"][number]["service_type"],
							services["video"][number]["service_id"],
							services["video"][number]["transport_stream_id"],
							services["video"][number]["original_network_id"],
							services["video"][number]["namespace"]
						))
					if "interactive_name" in services["video"][number]:
						current_bouquet_list.append("#DESCRIPTION %s\n" % services["video"][number]["interactive_name"])
				else:
					current_bouquet_list.append("#SERVICE 1:832:d:0:0:0:0:0:0:0:\n")
					current_bouquet_list.append("#DESCRIPTION  \n")

				current_number += 1
				section_number += 1

			bouquet_current.write(''.join(current_bouquet_list))
			bouquet_current.close()
			del current_bouquet_list

		elif provider_config.isMakeHDMain() or provider_config.isMakeFTAHDMain():
			bouquet_current = open(path + "/%s%s.main.tv" % (self.ABM_BOUQUET_PREFIX, section_identifier), "w")
			current_bouquet_list = []
			if provider_config.isMakeHDMain():
				hd_or_ftahd = "HD"
				current_bouquet_list.append("#NAME %sHD Channels\n" % section_prefix)
			elif provider_config.isMakeFTAHDMain():
				hd_or_ftahd = "FTAHD"
				current_bouquet_list.append("#NAME %sFTA HD Channels\n" % section_prefix)

			higher_number = sorted(sections.keys())[0]
			
			# Clear unused sections
			sections_c = sections.copy()
			sections_c = Tools().clearsections(services, sections_c, hd_or_ftahd, "video")
			
			section_keys_temp = sorted(sections_c.keys())
			section_key_current = section_keys_temp[0]

			if higher_number > 1:
#.........这里部分代码省略.........
开发者ID:dark4019,项目名称:oe-alliance-plugins,代码行数:103,代码来源:bouquetswriter.py

示例2: buildBouquets

# 需要导入模块: from tools import Tools [as 别名]
# 或者: from tools.Tools import keys [as 别名]
	def buildBouquets(self, path, provider_config, services, sections, section_identifier, preferred_order, bouquets_to_hide, section_prefix):
		if len(section_prefix) > 0:
			section_prefix = section_prefix + " - "
		current_number = 0

		# as first thing we're going to cleanup channels
		# with a numeration inferior to the first section
		first_section_number = sorted(sections.keys())[0]
		for number in sorted(services["video"].keys()):
			if number >= first_section_number:
				break

			del(services["video"][number])

		print>>log, "[ABM-BouquetsWriter] Writing %s bouquet..." % section_identifier

		force_keep_numbers = False

		# swap channels
		swapDict = {}
		for swaprule in preferred_order:
			if swaprule[0] in services["video"] and swaprule[1] in services["video"] and services["video"][swaprule[1]]["service_type"] in DvbScanner.HD_ALLOWED_TYPES and services["video"][swaprule[0]]["service_type"] not in DvbScanner.HD_ALLOWED_TYPES:
				# conditional is optional. If not present the swaprule is automatically added to the swap dict. If conditional is present it must evaluate to True
				conditional = len(swaprule) > 2 and swaprule[2] or None
				if not conditional or eval(conditional, {}, {'service_sd': services["video"][swaprule[0]], 'service_hd': services["video"][swaprule[1]]}):
					swapDict[swaprule[0]] = swaprule[1]
					swapDict[swaprule[1]] = swaprule[0]

		# create a swapped list for fulltime use in HD bouquets
		if provider_config.isMakeHDMain() or \
			provider_config.isMakeFTAHDMain() or \
			provider_config.isMakeHD() or \
			provider_config.isMakeFTAHD():
			services_swapped = {"video":{}}
			for number in services["video"]:
				if number in swapDict:
					services_swapped["video"][swapDict[number]] = services["video"][number]
				else:
					services_swapped["video"][number] = services["video"][number]

		if provider_config.isMakeNormalMain():
			bouquet_current = open(path + "/%s%s.main.tv" % (self.ABM_BOUQUET_PREFIX, section_identifier), "w")
			current_bouquet_list = []
			current_bouquet_list.append("#NAME %s%s\n" % (section_prefix, _('All channels')))

			# Clear unused sections
			sections_c = sections.copy()
			sections_c = Tools().clearsections(services, sections_c, 'ALL', "video")

			# small hack to handle the "preferred_order" list
			higher_number = sorted(services["video"].keys())[-1]
			preferred_order_tmp = []

			# expand a range into a list
			for number in range(1, higher_number + 1):
				preferred_order_tmp.append(number)

			# Always write first not hidden section on top of list
			for number in preferred_order_tmp:
				if number in sections_c and number not in bouquets_to_hide:
					current_bouquet_list.append(self.styledBouquetMarker("%s%s" % (section_prefix, sections_c[number])))
					first_section = number
					break

			# Use separate section counter. Preferred_order_tmp has swapped numbers. Can put sections on wrong places
			section_number = 1
			for number in preferred_order_tmp:
				if section_number in sections_c and section_number not in bouquets_to_hide and section_number != first_section:
					current_bouquet_list.append(self.styledBouquetMarker("%s%s" % (section_prefix, sections_c[section_number])))
				if provider_config.isSwapChannels() and number in swapDict:
					number = swapDict[number]
				if number in services["video"] and number not in bouquets_to_hide:
					current_bouquet_list.append(self.bouquetServiceLine(services["video"][number]))
				else:
					current_bouquet_list.append("#SERVICE 1:832:d:0:0:0:0:0:0:0:\n")
					current_bouquet_list.append("#DESCRIPTION  \n")

				current_number += 1
				section_number += 1

			bouquet_current.write(''.join(current_bouquet_list))
			bouquet_current.close()
			del current_bouquet_list

		elif provider_config.isMakeHDMain() or provider_config.isMakeFTAHDMain():
			bouquet_current = open(path + "/%s%s.main.tv" % (self.ABM_BOUQUET_PREFIX, section_identifier), "w")
			current_bouquet_list = []
			if provider_config.isMakeHDMain():
				hd_or_ftahd = "HD"
				current_bouquet_list.append("#NAME %s%s\n" % (section_prefix, _('HD Channels')))
			elif provider_config.isMakeFTAHDMain():
				hd_or_ftahd = "FTAHD"
				current_bouquet_list.append("#NAME %s%s\n" % (section_prefix, _('FTA HD Channels')))

			higher_number = sorted(sections.keys())[0]

			# Clear unused sections
			sections_c = sections.copy()
			sections_c = Tools().clearsections(services_swapped, sections_c, hd_or_ftahd, "video")

#.........这里部分代码省略.........
开发者ID:davesayers2014,项目名称:AutoBouquetsMaker,代码行数:103,代码来源:bouquetswriter.py


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