本文整理汇总了Python中xml.etree.cElementTree.cet_parse函数的典型用法代码示例。如果您正苦于以下问题:Python cet_parse函数的具体用法?Python cet_parse怎么用?Python cet_parse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cet_parse函数的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: read_timers
def read_timers(self):
configuration = cet_parse(self.__timer_filename).getroot()
timers = []
for timer in configuration.findall("timer"):
timers.append(timer.attrib)
return timers
开发者ID:Haehnchen,项目名称:sharemybox.net-enigma2-client,代码行数:7,代码来源:ShareMyBoxTimer.py
示例2: readConfiguration
def readConfiguration(self):
if not path.exists(CONFIG):
return
mtime = path.getmtime(CONFIG)
if mtime == self.configMtime:
return
self.configMtime = mtime
self.services[0].clear()
self.services[1].clear()
configuration = cet_parse(CONFIG).getroot()
version = configuration.get("version", None)
if version is None:
factor = 60
else:
factor = 1
for service in configuration.findall("service"):
value = service.text
if value:
pos = value.rfind(':')
# don't split alternative service
if pos != -1 and not value.startswith('1:134:'):
value = value[:pos+1]
duration = service.get('duration', None)
duration = duration and int(duration)*factor
self.services[0].add(EPGRefreshService(value, duration))
for bouquet in configuration.findall("bouquet"):
value = bouquet.text
if value:
duration = bouquet.get('duration', None)
duration = duration and int(duration)
self.services[1].add(EPGRefreshService(value, duration))
开发者ID:68foxboris,项目名称:enigma2-plugins,代码行数:31,代码来源:EPGRefresh.py
示例3: getRemotePCPoints
def getRemotePCPoints(self):
self.remotepc = {}
if not os_path.exists(XML_PCTAB):
self.setDummyRecord()
self.writePCsConfig()
tree = cet_parse(XML_PCTAB).getroot()
def getValue(definitions, default):
ret = ""
# How many definitions are present
Len = len(definitions)
return Len > 0 and definitions[Len-1].text or default
# Config is stored in "host" element, read out PC
for pc in tree.findall("host"):
data = { 'name': False, 'ip': False, 'mac': False, 'system': False, 'user': False, 'passwd': False, 'bqdn': False }
try:
data['name'] = getValue(pc.findall("name"), _("PC")).encode("UTF-8")
data['ip'] = getValue(pc.findall("ip"), "192.168.1.0").encode("UTF-8")
data['mac'] = getValue(pc.findall("mac"), "00:00:00:00:00:00").encode("UTF-8")
data['system'] = getValue(pc.findall("system"), "0").encode("UTF-8")
data['user'] = getValue(pc.findall("user"), "administrator").encode("UTF-8")
data['passwd'] = getValue(pc.findall("passwd"), "password").encode("UTF-8")
data['bqdn'] = getValue(pc.findall("bqdn"), "0").encode("UTF-8")
self.remotepc[data['name']] = data
except Exception, e:
print "[xpower] Error reading remotepc:", e
开发者ID:mb1366,项目名称:e2openplugin-XPower,代码行数:28,代码来源:xpowerut.py
示例4: update
def update(self, suggestions):
if suggestions and len(suggestions) > 0:
if not self.shown:
self.show()
suggestions_tree = cet_parse(StringIO(suggestions)).getroot()
if suggestions_tree:
self.list = []
self.suggestlist = []
for suggestion in suggestions_tree.findall("CompleteSuggestion"):
name = None
numresults = None
for subelement in suggestion:
if subelement.attrib.has_key('data'):
name = subelement.attrib['data'].encode("UTF-8")
if subelement.attrib.has_key('int'):
numresults = subelement.attrib['int']
if name and numresults:
self.suggestlist.append((name, numresults ))
if len(self.suggestlist):
self.suggestlist.sort(key=lambda x: int(x[1]))
self.suggestlist.reverse()
for entry in self.suggestlist:
self.list.append((entry[0], entry[1] + _(" Results") ))
self["suggestionslist"].setList(self.list)
self["suggestionslist"].setIndex(0)
else:
self.hide()
开发者ID:Meknes21,项目名称:dvbapp2-gui,代码行数:27,代码来源:MyTubeSearch.py
示例5: load
def load(self):
if not fileExists(XML_CONFIG):
return
try:
config = cet_parse(XML_CONFIG).getroot()
except ParseError as pe:
from time import time
print("[PluginSort] Parse Error occured in configuration, backing it up and starting from scratch!")
try:
copyfile(XML_CONFIG, "/etc/enigma2/pluginsort.xml.%d" % (int(time()),))
except Error as she:
print("[PluginSort] Uh oh, failed to create the backup... I hope you have one anyway :D")
return
for wheresection in config.findall('where'):
where = wheresection.get('type')
whereid = WHEREMAP.get(where, None)
whereplugins = wheresection.findall('plugin')
if whereid is None or not whereplugins:
print("[PluginSort] Ignoring section %s because of invalid id (%s) or no plugins (%s)" % (where, repr(whereid), repr(whereplugins)))
continue
for plugin in whereplugins:
name = plugin.get('name')
try:
weight = int(plugin.get('weight'))
except ValueError as ve:
print("[PluginSort] Invalid weight of %s received for plugin %s, ignoring" % (repr(plugin.get('weight')), repr(name)))
else:
self.plugins.setdefault(whereid, {})[name] = weight
开发者ID:dpuschek,项目名称:enigma2-plugins,代码行数:31,代码来源:plugin.py
示例6: load
def load(self):
if not fileExists(XML_CONFIG):
return
try:
config = cet_parse(XML_CONFIG).getroot()
except ParseError as pe:
from time import time
print("[MenuSort] Parse Error occured in configuration, backing it up and starting from scratch!")
try:
copyfile(XML_CONFIG, "/etc/enigma2/menusort.xml.%d" % (int(time()),))
except Error as she:
print("[MenuSort] Uh oh, failed to create the backup... I hope you have one anyway :D")
return
for node in config.findall('entry'):
text = node.get('text', '').encode("UTF-8")
weight = node.get("weight", None)
hidden = node.get('hidden', False)
hidden = hidden and hidden.lower() == "yes"
try:
weight = int(weight)
except ValueError as ve:
print("[MenuSort] Invalid value for weight on entry %s: %s" % (repr(text), repr(weight)))
continue
if not text or weight is None:
print("[MenuSort] Invalid entry in xml (%s, %s), ignoring" % (repr(text), repr(weight)))
continue
self.weights[text] = (weight, hidden)
开发者ID:digidudeofdw,项目名称:enigma2-plugins,代码行数:29,代码来源:plugin.py
示例7: readXml
def readXml(self):
# Abort if no config found
if not os_path.exists(XML_CONFIG):
doLog("No configuration file present")
return
# Parse if mtime differs from whats saved
mtime = os_path.getmtime(XML_CONFIG)
if mtime == self.configMtime:
doLog("No changes in configuration, won't parse")
return
# Save current mtime
self.configMtime = mtime
# Parse Config
configuration = cet_parse(XML_CONFIG).getroot()
# Empty out timers and reset Ids
del self.timers[:]
self.defaultTimer.clear(-1, True)
parseConfig(
configuration,
self.timers,
configuration.get("version"),
0,
self.defaultTimer
)
self.uniqueTimerId = len(self.timers)
开发者ID:dogfight76,项目名称:enigma2-plugins,代码行数:30,代码来源:AutoTimer.py
示例8: load
def load(self):
if not fileExists(XML_CONFIG):
return
try:
config = cet_parse(XML_CONFIG).getroot()
except ParseError, pe:
from time import time
print "[MenuSort] Parse Error occured in configuration, backing it up and starting from scratch!"
try:
copyfile(XML_CONFIG, "/etc/enigma2/menusort.xml.%d" % (int(time()),))
except Error, she:
print "[MenuSort] Uh oh, failed to create the backup... I hope you have one anyway :D"
开发者ID:Johnny-Dopp,项目名称:enigma2-plugins,代码行数:13,代码来源:plugin.py
示例9: __parse
def __parse(self, file):
print "[Bonjour.__parse] parsing %s%s" %(self.AVAHI_SERVICES_DIR, file)
config = cet_parse(self.AVAHI_SERVICES_DIR + file).getroot()
name = config.find('name').text
service = config.find('service')
type = service.find('type').text
port = service.find('port').text
text = service.findall('txt-record')
textList = []
if text != None:
for txt in text:
textList.append(txt.text)
print textList
service = self.buildServiceFull(file, name, type, port, textList)
self.registerService(service)
开发者ID:IPMAN-online,项目名称:enigma2-plugins,代码行数:17,代码来源:Bonjour.py
示例10: __parse
def __parse(self, file):
print "[Bonjour.__parse] parsing %s%s" %(self.AVAHI_SERVICES_DIR, file)
config = cet_parse(self.AVAHI_SERVICES_DIR + file).getroot()
name = config.find('name').text
service = config.find('service')
type = service.find('type').text
port = service.find('port').text
text = service.get('text-record')
if text is None:
text = ""
else:
text = text.text
service = self.buildServiceFull(file, name, type, port, text)
self.registerService(service)
开发者ID:13K-OMAR,项目名称:enigma2-plugins-sh4,代码行数:17,代码来源:Bonjour.py
示例11: readConfiguration
def readConfiguration(self):
# Check if file exists
if not path.exists(CONFIG):
return
# Check if file did not change
mtime = path.getmtime(CONFIG)
if mtime == self.configMtime:
return
# Keep mtime
self.configMtime = mtime
# Empty out list
self.services[0].clear()
self.services[1].clear()
# Open file
configuration = cet_parse(CONFIG).getroot()
version = configuration.get("version", None)
if version is None:
factor = 60
else: #if version == "1"
factor = 1
# Add References
for service in configuration.findall("service"):
value = service.text
if value:
# strip all after last : (custom name)
pos = value.rfind(':')
# don't split alternative service
if pos != -1 and not value.startswith('1:134:'):
value = value[:pos+1]
duration = service.get('duration', None)
duration = duration and int(duration)*factor
self.services[0].add(EPGRefreshService(value, duration))
for bouquet in configuration.findall("bouquet"):
value = bouquet.text
if value:
duration = bouquet.get('duration', None)
duration = duration and int(duration)
self.services[1].add(EPGRefreshService(value, duration))
开发者ID:Haehnchen,项目名称:enigma2-plugins,代码行数:45,代码来源:EPGRefresh.py
示例12: reload
def reload(self, callback=None):
Log.i()
# Initialize mounts to empty list
self._mounts = {}
self._numActive = 0
if not pathExists(XML_FSTAB):
return
tree = cet_parse(XML_FSTAB).getroot()
self._parse(tree, ['nfs', 'cifs'], [AutoMount.DEFAULT_OPTIONS_NFS, AutoMount.DEFAULT_OPTIONS_CIFS])
if len(self._mounts):
for sharename, sharedata in self._mounts.items():
self._applyShare(sharedata, callback)
self._reloadSystemd(callback=self._onSharesApplied)
else:
Log.i("self._mounts without mounts %s" %(self._mounts,))
if callback is not None:
callback(True)
开发者ID:dpuschek,项目名称:enigma2-plugins,代码行数:19,代码来源:AutoMount.py
示例13: __parse
def __parse(self, file):
print "[Bonjour.__parse] parsing %s%s" %(self.AVAHI_SERVICES_DIR, file)
try:
config = cet_parse(self.AVAHI_SERVICES_DIR + file).getroot()
except ParseError: #parsing failed, skip the file
return
name = config.find('name').text
service = config.find('service')
type = service.find('type').text
port = service.find('port').text
text = service.findall('txt-record')
textList = []
if text is not None:
for txt in text:
textList.append(txt.text)
service = self.buildServiceFull(file, name, type, port, textList)
self.registerService(service)
开发者ID:68foxboris,项目名称:enigma2-plugins,代码行数:20,代码来源:Bonjour.py
示例14: readXml
def readXml(self):
# Abort if no config found
if not os.path.exists(XML_CONFIG):
doLog("[AutoTimer] No configuration file present")
return
# Parse if mtime differs from whats saved
mtime = os.path.getmtime(XML_CONFIG)
if mtime == self.configMtime:
doLog("[AutoTimer] No changes in configuration, won't parse")
return
# Save current mtime
self.configMtime = mtime
# Parse Config
try:
configuration = cet_parse(XML_CONFIG).getroot()
except:
try:
os.rename(XML_CONFIG, XML_CONFIG + "_old")
doLog("[AutoTimer] autotimer.xml is corrupt rename file to /etc/enigma2/autotimer.xml_old")
except:
pass
if Standby.inStandby is None:
AddPopup(_("The autotimer file (/etc/enigma2/autotimer.xml) is corrupt and could not be loaded."), type = MessageBox.TYPE_ERROR, timeout = 0, id = "AutoTimerLoadFailed")
return
# Empty out timers and reset Ids
del self.timers[:]
self.defaultTimer.clear(-1, True)
parseConfig(
configuration,
self.timers,
configuration.get("version"),
0,
self.defaultTimer
)
self.uniqueTimerId = len(self.timers)
开发者ID:OpenPLi,项目名称:enigma2-plugins,代码行数:40,代码来源:AutoTimer.py
示例15: readConfiguration
def readConfiguration(self):
# Check if file exists
if not path.exists(CONFIG):
return
# Check if file did not change
mtime = path.getmtime(CONFIG)
if mtime == self.configMtime:
return
# Keep mtime
self.configMtime = mtime
# Empty out list
self.services[0].clear()
self.services[1].clear()
# Open file
configuration= cet_parse(CONFIG).getroot()
# Add References
for service in configuration.findall("service"):
value = service.text
if value:
# strip all after last : (custom name)
pos = value.rfind(':')
if pos != -1:
value = value[:pos+1]
duration = service.get('duration', None)
duration = duration and int(duration)
self.services[0].add(EPGRefreshService(value, duration))
for bouquet in configuration.findall("bouquet"):
value = bouquet.text
if value:
duration = bouquet.get('duration', None)
duration = duration and int(duration)
self.services[1].add(EPGRefreshService(value, duration))
开发者ID:4doe,项目名称:e2plugins,代码行数:39,代码来源:EPGRefresh.py
示例16: getWebTVStations
def getWebTVStations(self, callback=None):
self.webtv_stations = {}
if not exists(WEBTV_STATIONS):
return
tree = cet_parse(WEBTV_STATIONS).getroot()
def getValue(definitions, default):
Len = len(definitions)
return Len > 0 and definitions[Len-1].text or default
for tvstation in tree.findall("tvstation"):
data = { 'provider': None, 'title': None, 'streamurl': None }
try:
data['provider'] = getValue(tvstation.findall("provider"), False).encode("UTF-8")
data['title'] = getValue(tvstation.findall("title"), False).encode("UTF-8")
data['streamurl'] = getValue(tvstation.findall("streamurl"), False).encode("UTF-8")
print "TVSTATION--->",data
self.webtv_stations[data['title']] = data
except Exception, e:
print "[WebTVStations] Error reading Stations:", e
开发者ID:OpenDMM,项目名称:enigma2-plugins,代码行数:22,代码来源:ServiceXML.py
示例17: getAutoMountPoints
def getAutoMountPoints(self, callback = None):
automounts = []
self.automounts = {}
self.activeMountsCounter = 0
if not os.path.exists(XML_FSTAB):
return
file = open(XML_FSTAB, 'r')
tree = cet_parse(file).getroot()
file.close()
def getValue(definitions, default):
ret = ''
Len = len(definitions)
return Len > 0 and definitions[(Len - 1)].text or default
mountusing = 0
for fstab in tree.findall('fstab'):
mountusing = 1
for nfs in fstab.findall('nfs'):
for mount in nfs.findall('mount'):
data = {'isMounted': False,
'mountusing': False,
'active': False,
'ip': False,
'sharename': False,
'sharedir': False,
'username': False,
'password': False,
'mounttype': False,
'options': False,
'hdd_replacement': False}
try:
data['mountusing'] = 'fstab'.encode('UTF-8')
data['mounttype'] = 'nfs'.encode('UTF-8')
data['active'] = getValue(mount.findall('active'), False).encode('UTF-8')
if data['active'] == 'True' or data['active'] == True:
self.activeMountsCounter += 1
data['hdd_replacement'] = getValue(mount.findall('hdd_replacement'), 'False').encode('UTF-8')
data['ip'] = getValue(mount.findall('ip'), '192.168.0.0').encode('UTF-8')
data['sharedir'] = getValue(mount.findall('sharedir'), '/exports/').encode('UTF-8')
data['sharename'] = getValue(mount.findall('sharename'), 'MEDIA').encode('UTF-8')
data['options'] = getValue(mount.findall('options'), 'rw,nolock,tcp,utf8').encode('UTF-8')
self.automounts[data['sharename']] = data
except Exception as e:
print '[MountManager] Error reading Mounts:',
print e
for cifs in fstab.findall('cifs'):
for mount in cifs.findall('mount'):
data = {'isMounted': False,
'mountusing': False,
'active': False,
'ip': False,
'sharename': False,
'sharedir': False,
'username': False,
'password': False,
'mounttype': False,
'options': False,
'hdd_replacement': False}
try:
data['mountusing'] = 'fstab'.encode('UTF-8')
data['mounttype'] = 'cifs'.encode('UTF-8')
data['active'] = getValue(mount.findall('active'), False).encode('UTF-8')
if data['active'] == 'True' or data['active'] == True:
self.activeMountsCounter += 1
data['hdd_replacement'] = getValue(mount.findall('hdd_replacement'), 'False').encode('UTF-8')
data['ip'] = getValue(mount.findall('ip'), '192.168.0.0').encode('UTF-8')
data['sharedir'] = getValue(mount.findall('sharedir'), '/exports/').encode('UTF-8')
data['sharename'] = getValue(mount.findall('sharename'), 'MEDIA').encode('UTF-8')
data['options'] = getValue(mount.findall('options'), 'rw,utf8').encode('UTF-8')
data['username'] = getValue(mount.findall('username'), 'guest').encode('UTF-8')
data['password'] = getValue(mount.findall('password'), '').encode('UTF-8')
self.automounts[data['sharename']] = data
except Exception as e:
print '[MountManager] Error reading Mounts:',
print e
for enigma2 in tree.findall('enigma2'):
mountusing = 2
for nfs in enigma2.findall('nfs'):
for mount in nfs.findall('mount'):
data = {'isMounted': False,
'mountusing': False,
'active': False,
'ip': False,
'sharename': False,
'sharedir': False,
'username': False,
'password': False,
'mounttype': False,
'options': False,
'hdd_replacement': False}
try:
data['mountusing'] = 'enigma2'.encode('UTF-8')
data['mounttype'] = 'nfs'.encode('UTF-8')
#.........这里部分代码省略.........
开发者ID:OUARGLA86,项目名称:enigma2,代码行数:101,代码来源:AutoMount.py
示例18: __init__
def __init__(self, filename):
# this may raise an exception, it is up to the caller to handle that
self.__dom = cet_parse(filename).getroot()
开发者ID:Johnny-Dopp,项目名称:enigma2-plugins,代码行数:3,代码来源:XMLHelp.py
示例19: readXml
def readXml(self, **kwargs):
if "xml_string" in kwargs:
# reset time
self.configMtime = -1
# Parse Config
configuration = cet_fromstring(kwargs["xml_string"])
# TODO : check config and create backup if wrong
else:
# Abort if no config found
if not os_path.exists(XML_CONFIG):
print("[AutoTimer] No configuration file present")
return
# Parse if mtime differs from whats saved
mtime = os_path.getmtime(XML_CONFIG)
if mtime == self.configMtime:
print("[AutoTimer] No changes in configuration, won't parse")
return
# Save current mtime
self.configMtime = mtime
# Parse Config
try:
configuration = cet_parse(XML_CONFIG).getroot()
except:
try:
if os_path.exists(XML_CONFIG + "_old"):
os_rename(XML_CONFIG + "_old", XML_CONFIG + "_old(1)")
os_rename(XML_CONFIG, XML_CONFIG + "_old")
print("[AutoTimer] autotimer.xml is corrupt rename file to /etc/enigma2/autotimer.xml_old")
except:
pass
if Standby.inStandby is None:
AddPopup(_("The autotimer file (/etc/enigma2/autotimer.xml) is corrupt. A new and empty config was created. A backup of the config can be found here (/etc/enigma2/autotimer.xml_old) "), type = MessageBox.TYPE_ERROR, timeout = 0, id = "AutoTimerLoadFailed")
self.timers = []
self.defaultTimer = preferredAutoTimerComponent(
0, # Id
"", # Name
"", # Match
True # Enabled
)
try:
self.writeXml()
configuration = cet_parse(XML_CONFIG).getroot()
except:
print("[AutoTimer] fatal error, the autotimer.xml cannot create")
return
# Empty out timers and reset Ids
del self.timers[:]
self.defaultTimer.clear(-1, True)
parseConfig(
configuration,
self.timers,
configuration.get("version"),
0,
self.defaultTimer
)
self.uniqueTimerId = len(self.timers)
开发者ID:oe-alliance,项目名称:enigma2-plugins,代码行数:64,代码来源:AutoTimer.py
注:本文中的xml.etree.cElementTree.cet_parse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论