4 from xml.etree.cElementTree import ElementTree, tostring, parse
8 from PluginModules import PluginModules
11 def indent(elem, level=0):
14 if not elem.text or not elem.text.strip():
16 if not elem.tail or not elem.tail.strip():
20 if not elem.tail or not elem.tail.strip():
23 if level and (not elem.tail or not elem.tail.strip()):
27 class PushServiceConfigFile(object):
34 def __setPath(self, path):
40 def readXML(self, path):
43 # Abort if no config found
44 if not os.path.exists(path):
45 print _("[PushService] No configuration file present")
48 # Parse if mtime differs from whats saved
49 mtime = os.path.getmtime(path)
50 if mtime == self.mtime:
51 # No changes in configuration, won't read again
56 etree = parse(path).getroot()
58 print _("[PushService] Exception in readXML: ") + str(e)
62 # Save time and cache file content
67 def writeXML(self, etree, path):
71 data = tostring(etree, 'utf-8')
79 print _("[PushService] Exception in writeXML: ") + str(e)
84 # Save time and cache file content
85 self.mtime = os.path.getmtime( path )