Modified format gconf (Gnome applications)

master
Самоукин Алексей 14 years ago
parent 2336bda8f7
commit 4c18e3f297

@ -6017,7 +6017,6 @@ Valid values attribute 'action': \
self.setError(textError) self.setError(textError)
return False return False
if xmlOldNode.parentNode: if xmlOldNode.parentNode:
findStr = u"child::%s"%path
strAttr = [attrName, attrType] strAttr = [attrName, attrType]
findAttr = filter(lambda x: x, strAttr) findAttr = filter(lambda x: x, strAttr)
findAttrStr = '' findAttrStr = ''
@ -6256,7 +6255,6 @@ Valid values attribute 'action': \
self.setError(textError) self.setError(textError)
return False return False
if xmlOldNode.parentNode: if xmlOldNode.parentNode:
findStr = u"child::%s"%path
findAttrStr = "" findAttrStr = ""
if attrName: if attrName:
findAttrStr = "[%s]"%attrName findAttrStr = "[%s]"%attrName
@ -6506,7 +6504,8 @@ class xml_gconf(xml_xfce):
"""Сравнение содержимого двух списков XML нод""" """Сравнение содержимого двух списков XML нод"""
getTextsNodes = lambda y: map(lambda x:\ getTextsNodes = lambda y: map(lambda x:\
x.toxml().replace(" ","").replace("\t","").replace("\n",""), x.toxml().replace(" ","").replace("\t","").replace("\n",""),
map(lambda x: x.removeAttribute("mtime") or x, map(lambda x: x.hasAttribute("mtime") and\
x.removeAttribute("mtime") or x,
map(lambda x: x.cloneNode(True), map(lambda x: x.cloneNode(True),
filter(lambda x: x.nodeType==x.ELEMENT_NODE, y)))) filter(lambda x: x.nodeType==x.ELEMENT_NODE, y))))
if set(getTextsNodes(listXmlA))==set(getTextsNodes(listXmlB)): if set(getTextsNodes(listXmlA))==set(getTextsNodes(listXmlB)):
@ -6528,13 +6527,16 @@ class xml_gconf(xml_xfce):
nName = u'' nName = u''
nType = u'' nType = u''
nValue = u'' nValue = u''
nSchema = u''
attrName = '' attrName = ''
attrType = ''
if flagRootNode: if flagRootNode:
if not tagName == "gconf": if not tagName == "gconf":
self.setError(_("The text is not a valid gconf-XML format \ self.setError(_("The text is not a valid gconf-XML format \
(not found '<gconf>...</gconf>')")) (not found '<gconf>...</gconf>')"))
return False return False
flagType = False
flagValue = False
flagSchema = False
else: else:
if not tagName == "entry": if not tagName == "entry":
self.setError(_("The text is not a valid gconf-XML format \ self.setError(_("The text is not a valid gconf-XML format \
@ -6543,20 +6545,27 @@ class xml_gconf(xml_xfce):
if not n.hasAttribute("name"): if not n.hasAttribute("name"):
self.setError(_('Not found arrtibute "name" in tag entry')) self.setError(_('Not found arrtibute "name" in tag entry'))
return False return False
if not n.hasAttribute("type"): flagType = n.hasAttribute("type")
flagValue = False
flagSchema = n.hasAttribute("schema")
if flagSchema:
nSchema = n.getAttribute("schema")
if not flagType and not flagSchema:
self.setError(_('Not found arrtibute "type" in tag entry')) self.setError(_('Not found arrtibute "type" in tag entry'))
return False return False
nName = n.getAttribute("name") nName = n.getAttribute("name")
attrName = u"attribute::name='%s'"%nName attrName = u"attribute::name='%s'"%nName
nType = n.getAttribute("type") if flagType:
# Проверка правильности аттрибута type flagValue = n.hasAttribute("value")
if not nType in self.supportEntryTypes: nType = n.getAttribute("type")
self.setError(\ # Проверка правильности аттрибута type
_('Incorrect arrtibute "type" - <entry type="%s"/>')%nType) if not nType in self.supportEntryTypes:
return False self.setError(\
attrType = u"attribute::type='%s'"%nType _('Incorrect arrtibute "type" - <entry type="%s"/>')\
if n.hasAttribute("value"): %nType)
nValue = n.getAttribute("value") return False
if flagValue:
nValue = n.getAttribute("value")
if n.hasAttribute("action"): if n.hasAttribute("action"):
nAction = n.getAttribute("action") nAction = n.getAttribute("action")
if not nAction in ("join","replace","drop"): if not nAction in ("join","replace","drop"):
@ -6567,13 +6576,9 @@ Valid values attribute 'action': \
self.setError(textError) self.setError(textError)
return False return False
if xmlOldNode.parentNode: if xmlOldNode.parentNode:
findStr = u"child::%s"%tagName findAttrStr = ""
strAttr = [attrName, attrType] if attrName:
findAttr = filter(lambda x: x, strAttr) findAttrStr = "[%s]"%attrName
findAttrStr = ''
if findAttr:
strAttr = u' and '.join(findAttr)
findAttrStr = "[%s]"%strAttr
findPath = u"child::%s%s"%(tagName,findAttrStr) findPath = u"child::%s%s"%(tagName,findAttrStr)
# Рабочая нода # Рабочая нода
if flagRootNode: if flagRootNode:
@ -6581,16 +6586,19 @@ Valid values attribute 'action': \
else: else:
workNode = xmlOldNode workNode = xmlOldNode
oldNodes = xpath.Evaluate(findPath, workNode) oldNodes = xpath.Evaluate(findPath, workNode)
# Новая нода список # По умолчанию - объединение
flagArray = False
if nType == "list" or nType == "pair":
flagArray = True
flagDrop = False
flagJoin = True flagJoin = True
flagReplace = False flagReplace = False
flagDrop = False
# Замещаем ноду
if nType=="string" or nAction=="replace": if nType=="string" or nAction=="replace":
flagJoin = False flagJoin = False
flagReplace = True flagReplace = True
# Замещаем ноду в случае массива
elif nType == "list" or nType == "pair":
flagJoin = False
flagReplace = True
# Удаляем ноду
elif nAction == "drop": elif nAction == "drop":
flagJoin = False flagJoin = False
flagDrop = True flagDrop = True
@ -6605,29 +6613,34 @@ the same nodes at one level")
self.setError(textError) self.setError(textError)
return False return False
nextOldNode = oldNodes[0] nextOldNode = oldNodes[0]
# Замещаем ноду в случае массива
if flagArray and not flagDrop:
replaceXmlNode = xmlNode.cloneNode(True)
# Сравнение содержимого нод
if not self.cmpListsNodesEntry([replaceXmlNode],
[nextOldNode]):
replaceXmlNode.setAttribute("mtime",
self.currentTime)
if nAction:
replaceXmlNode.removeAttribute("action")
workNode.replaceChild(replaceXmlNode,
nextOldNode)
flagJoin = False
flagReplace = False
childNodes = False
# Объединение нод # Объединение нод
if flagJoin: if flagJoin:
if nextOldNode.hasAttribute("value"): if flagType and flagValue:
oValue = nextOldNode.getAttribute("value") flagChange = False
if nValue != oValue: foundValue = nextOldNode.hasAttribute("value")
if foundValue:
oValue = nextOldNode.getAttribute("value")
if nValue != oValue:
flagChange = True
else:
flagChange = True
if flagChange:
nextOldNode.setAttribute("mtime", nextOldNode.setAttribute("mtime",
self.currentTime) self.currentTime)
nextOldNode.setAttribute("value",nValue) nextOldNode.setAttribute("value",nValue)
elif flagSchema:
flagChange = False
foundValue = nextOldNode.hasAttribute("schema")
if foundValue:
oSchema = nextOldNode.getAttribute("schema")
if nSchema != oSchema:
flagChange = True
else:
flagChange = True
if flagChange:
nextOldNode.setAttribute("mtime",
self.currentTime)
nextOldNode.setAttribute("schema",nSchema)
# Замещение ноды # Замещение ноды
elif flagReplace: elif flagReplace:
replaceXmlNode = xmlNode.cloneNode(True) replaceXmlNode = xmlNode.cloneNode(True)
@ -6677,7 +6690,7 @@ the same nodes at one level")
self.joinDoc(xml_gconfObj.doc) self.joinDoc(xml_gconfObj.doc)
except: except:
self.setError(_("Can not join profile")) self.setError(_("Can not join profile"))
return False return False
return True return True
def getConfig(self): def getConfig(self):

Loading…
Cancel
Save