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


Python ConfigSubsection.dict方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Components.config import ConfigSubsection [as 别名]
# 或者: from Components.config.ConfigSubsection import dict [as 别名]
class DVDProject:
	MAX_SL = 4480
	MAX_DL = 8150
	def __init__(self):
		self.titles = [ ]
		self.target = None
		self.settings = ConfigSubsection()
		self.settings.name = ConfigText(fixed_size = False, visible_width = 40)
		self.settings.authormode = ConfigSelection(choices = [("menu_linked", _("Linked titles with a DVD menu")), ("just_linked", _("Direct playback of linked titles without menu")), ("menu_seperate", _("Seperate titles with a main menu")), ("data_ts", _("Dreambox format data DVD (HDTV compatible)"))])
		self.settings.titlesetmode = ConfigSelection(choices = [("single", _("Simple titleset (compatibility for legacy players)")), ("multi", _("Complex (allows mixing audio tracks and aspects)"))], default="multi")
		self.settings.output = ConfigSelection(choices = [("iso", _("Create DVD-ISO")), ("dvd", _("Burn DVD"))])
		self.settings.isopath = ConfigText(fixed_size = False, visible_width = 40)
		self.settings.dataformat = ConfigSelection(choices = [("iso9660_1", ("ISO9660 Level 1")), ("iso9660_4", ("ISO9660 version 2")), ("udf", ("UDF"))])
		self.settings.menutemplate = ConfigFilename()
		self.settings.vmgm = ConfigFilename()
		self.filekeys = ["vmgm", "isopath", "menutemplate"]
		self.menutemplate = MenuTemplate()
		self.error = ""
		self.session = None

	def addService(self, service):
		title = DVDTitle.DVDTitle(self)
		title.addService(service)
		self.titles.append(title)
		return title

	def saveProject(self, path):
		from Tools.XMLTools import stringToXML
		list = []
		list.append('<?xml version="1.0" encoding="utf-8" ?>\n')
		list.append('<DreamDVDBurnerProject>\n')
		list.append('\t<settings ')
		for key, val in self.settings.dict().iteritems():
			list.append( key + '="' + str(val.getValue()) + '" ' )
		list.append('/>\n')
		list.append('\t<titles>\n')
		for title in self.titles:
			list.append('\t\t<title>\n')
			list.append('\t\t\t<path>')
			list.append(stringToXML(title.source.getPath()))
			list.append('</path>\n')
			list.append('\t\t\t<properties ')
			audiotracks = []
			for key, val in title.properties.dict().iteritems():
				if type(val) is ConfigSubList:
					audiotracks.append('\t\t\t<audiotracks>\n')
					for audiotrack in val:
						audiotracks.append('\t\t\t\t<audiotrack ')
						for subkey, subval in audiotrack.dict().iteritems():
							audiotracks.append( subkey + '="' + str(subval.getValue()) + '" ' )
						audiotracks.append(' />\n')
					audiotracks.append('\t\t\t</audiotracks>\n')
				else:
					list.append( key + '="' + str(val.getValue()) + '" ' )
			list.append('/>\n')
			for line in audiotracks:
				list.append(line)
			list.append('\t\t</title>\n')
		list.append('\t</titles>\n')
		list.append('</DreamDVDBurnerProject>\n')

		name = self.settings.name.getValue()
		i = 0
		filename = path + name + ".ddvdp.xml"
		while fileExists(filename):
			i = i+1
			filename = path + name + str(i).zfill(3) + ".ddvdp.xml"
		try:	
			file = open(filename, "w")
			for x in list:
				file.write(x)
			file.close()
		except:
			return False
		return filename

	def load(self, filename):
		ret = self.loadProject(filename)
		if ret:
			ret = self.menutemplate.loadTemplate(self.settings.menutemplate.getValue())
			self.error += self.menutemplate.error
		return ret

	def loadProject(self, filename):
		#try:
			if not fileExists(filename):
				self.error = "xml file not found!"
				#raise AttributeError
			file = open(filename, "r")
			data = file.read().decode("utf-8").replace('&',"&amp;").encode("ascii",'xmlcharrefreplace')
			file.close()
			projectfiledom = xml.dom.minidom.parseString(data)
			for node in projectfiledom.childNodes[0].childNodes:
			  print "node:", node
			  if node.nodeType == xml.dom.minidom.Element.nodeType:
			    if node.tagName == 'settings':
				self.xmlAttributesToConfig(node, self.settings)
			    elif node.tagName == 'titles':
				self.xmlGetTitleNodeRecursive(node)
				
#.........这里部分代码省略.........
开发者ID:FFTEAM,项目名称:enigma2-5,代码行数:103,代码来源:DVDProject.py

示例2: __init__

# 需要导入模块: from Components.config import ConfigSubsection [as 别名]
# 或者: from Components.config.ConfigSubsection import dict [as 别名]
class DVDProject:
	def __init__(self):
		self.titles = [ ]
		self.target = None
		self.settings = ConfigSubsection()
		self.settings.name = ConfigText(fixed_size = False, visible_width = 40)
		self.settings.authormode = ConfigSelection(choices = [("menu_linked", _("Linked titles with a DVD menu")), ("just_linked", _("Direct playback of linked titles without menu")), ("menu_seperate", _("Seperate titles with a main menu")), ("data_ts", _("Dreambox format data DVD (HDTV compatible)"))])
		self.settings.titlesetmode = ConfigSelection(choices = [("single", _("Simple titleset (compatibility for legacy players)")), ("multi", _("Complex (allows mixing audio tracks and aspects)"))], default="multi")
		self.settings.output = ConfigSelection(choices = [("iso", _("Create DVD-ISO")), ("dvd", _("Burn DVD"))])
		self.settings.isopath = ConfigText(fixed_size = False, visible_width = 40)
		self.settings.dataformat = ConfigSelection(choices = [("iso9660_1", ("ISO9660 Level 1")), ("iso9660_4", ("ISO9660 version 2")), ("udf", ("UDF"))])
		self.settings.menutemplate = ConfigFilename()
		self.settings.vmgm = ConfigFilename()
		self.filekeys = ["vmgm", "isopath", "menutemplate"]
		self.menutemplate = MenuTemplate()

	def addService(self, service):
		import DVDTitle
		title = DVDTitle.DVDTitle()
		title.addService(service)
		self.titles.append(title)
		return title

	def saveProject(self, path):
		from Tools.XMLTools import stringToXML
		list = []
		list.append('<?xml version="1.0" encoding="utf-8" ?>\n')
		list.append('<DreamDVDBurnerProject>\n')
		list.append('\t<settings ')
		for key, val in self.settings.dict().iteritems():
			list.append( key + '="' + str(val.getValue()) + '" ' )
		list.append('/>\n')
		list.append('\t<titles>\n')
		for title in self.titles:
			list.append('\t\t<title>\n')
			list.append('\t\t\t<path>')
			list.append(stringToXML(title.source.getPath()))
			list.append('</path>\n')
			list.append('\t\t\t<properties ')
			audiotracks = []
			for key, val in title.properties.dict().iteritems():
				if type(val) is ConfigSubList:
					audiotracks.append('\t\t\t<audiotracks>\n')
					for audiotrack in val:
						audiotracks.append('\t\t\t\t<audiotrack ')
						for subkey, subval in audiotrack.dict().iteritems():
							audiotracks.append( subkey + '="' + str(subval.getValue()) + '" ' )
						audiotracks.append(' />\n')
					audiotracks.append('\t\t\t</audiotracks>\n')
				else:
					list.append( key + '="' + str(val.getValue()) + '" ' )
			list.append('/>\n')
			for line in audiotracks:
				list.append(line)
			list.append('\t\t</title>\n')
		list.append('\t</titles>\n')
		list.append('</DreamDVDBurnerProject>\n')

		name = self.settings.name.getValue()
		i = 0
		filename = path + name + ".ddvdp.xml"
		while fileExists(filename):
			i = i+1
			filename = path + name + str(i).zfill(3) + ".ddvdp.xml"
		try:	
			file = open(filename, "w")
			for x in list:
				file.write(x)
			file.close()
		except:
			return False
		return filename

	def load(self, filename):
		ret = self.loadProject(filename)
		if ret:
			ret = self.menutemplate.loadTemplate(self.settings.menutemplate.getValue())
			self.error += self.menutemplate.error
		return ret

	def loadProject(self, filename):
		import xml.dom.minidom
		try:
			if not fileExists(filename):
				self.error = "xml file not found!"
				raise AttributeError
			else:
				self.error = ""
			file = open(filename, "r")
			data = file.read().decode("utf-8").replace('&',"&amp;").encode("ascii",'xmlcharrefreplace')
			file.close()
			projectfiledom = xml.dom.minidom.parseString(data)
			for project in projectfiledom.childNodes[0].childNodes:
			  if project.nodeType == xml.dom.minidom.Element.nodeType:
			    if project.tagName == 'settings':
				i = 0
				if project.attributes.length < len(self.settings.dict())-1:
					self.error = "project attributes missing"
					raise AttributeError
				while i < project.attributes.length:
#.........这里部分代码省略.........
开发者ID:kakunbsc,项目名称:enigma2.4,代码行数:103,代码来源:DVDProject.py


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