def testLegalChildren():
    dom = Document()
    elem = dom.createElement('element')
    text = dom.createTextNode('text')

    try: dom.appendChild(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    dom.appendChild(elem)
    try: dom.insertBefore(text, elem)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    try: dom.replaceChild(text, elem)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    nodemap = elem.attributes
    try: nodemap.setNamedItem(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "NamedNodeMap.setNamedItem didn't raise HierarchyRequestErr"

    try: nodemap.setNamedItemNS(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "NamedNodeMap.setNamedItemNS didn't raise HierarchyRequestErr"

    elem.appendChild(text)
    dom.unlink()
Esempio n. 2
0
    def add(self, doc):
	#print "$$$$$$$$$$$$$ called add()"
	objs = doc.getElementsByTagName("obj")
	for obj in objs:
	    tu = self.root.createElement("tu")
	    
	    klass = obj.getAttribute("class")
	    name = obj.getAttribute("name")
	    
	    sets = obj.getElementsByTagName("sets")
	    for set in sets:
		tuCommandName = set.getAttribute("attr")
		if set.firstChild.TEXT_NODE:
		    #print "$$$$$$ ok"
		    tuCommand = set.firstChild.data
		    tuCommand = tuCommand.replace("\"","")
		    tuCommand = tuCommand.replace("'","")
		    tuCommand = tuCommand.replace("(","")
		    tuCommand = tuCommand.replace(")","")
		
		    tu.setAttribute("class",klass)
		    tu.setAttribute("who",name)
		    tu.setAttribute("prop",tuCommandName)
		    tu.setAttribute("value",tuCommand)
		
		    newStr = self.root.createTextNode("\n")
		    
		    dom = self.root.getElementsByTagName("root").item(0)
		    
		    dom.appendChild(tu)
		    dom.appendChild(newStr)
		else:
		    print "ОШИБКА в файле "+str(self.fileName)+" (пропущено) "
Esempio n. 3
0
def testLegalChildren():
    dom = Document()
    elem = dom.createElement('element')
    text = dom.createTextNode('text')

    try: dom.appendChild(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    dom.appendChild(elem)
    try: dom.insertBefore(text, elem)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    try: dom.replaceChild(text, elem)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "dom.appendChild didn't raise HierarchyRequestErr"

    nodemap = elem.attributes
    try: nodemap.setNamedItem(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "NamedNodeMap.setNamedItem didn't raise HierarchyRequestErr"

    try: nodemap.setNamedItemNS(text)
    except xml.dom.HierarchyRequestErr: pass
    else:
        print "NamedNodeMap.setNamedItemNS didn't raise HierarchyRequestErr"

    elem.appendChild(text)
    dom.unlink()
Esempio n. 4
0
    def include(self):

	# Записать эти файлы в storyall.xml
	try:
	    doc = FromXmlFile("storyall.xml")
	    #Print (doc)
	    dom = doc.documentElement

	    inc = doc.createElement("include")
	    inc.setAttribute("url", self.toFile)
	    isIncAlready=False
	    incs = dom.getElementsByTagName("include")
	    for i in incs:
		if i.getAttribute("url")==inc.getAttribute("url"):
		    isIncAlready=True
		    break
	    if not isIncAlready:
		dom.appendChild(inc)
		dom.appendChild(doc.createTextNode("\n"))


	    f=open("storyall.xml", 'w')
	    Print(doc, f, "utf-8")

	except Exception, msg:
	    print "Strelka-Canceler::include(): EXCEPTION (while writing to 'storyall.xml'):", msg
Esempio n. 5
0
    def appendStoryallXml(self, xmlFile, templates_path,result_path):
	os.system("cp "+xmlFile+" "+xmlFile+".old")
        doc=FromXmlFile(xmlFile)
	dom=doc.getElementsByTagName("root").item(0)
	for file in os.listdir(templates_path):
	    if re.search("\.template\.xml",file) and not re.search("impulses\.", file):
	        try:
	            ff = open(result_path+"/"+file.replace(".template",""),'r')
	            ff.close()
	            include = doc.createElement("include")
	            include.setAttribute("url",file.replace(".template",""))
	            includes = dom.getElementsByTagName("include")
	            isAppend = True
	            for inc in includes:
	                if inc.getAttribute("url") == file.replace(".template",""):
	                    isAppend = False
	            if isAppend:
	                dom.appendChild(include)
	                newStr=doc.createTextNode("\n")
		        dom.appendChild(newStr)
		        print "В storyall.xml добавлена нода "+str(include)
		    else:
		        print "В storyall.xml уже имеется нода <include url='"+file.replace(".template","")+"' />"
		except:
		    continue
																																												
	file=open(xmlFile,'w')
	Print(doc,file,"utf-8")
	print "Записан файл ", str(xmlFile)
Esempio n. 6
0
    def appendTsXml(self, tsXmlFile):
	os.system("cp "+tsXmlFile+" "+tsXmlFile+".old")
	doc=FromXmlFile(tsXmlFile)
	dom=doc.getElementsByTagName("g").item(0)
	for file in os.listdir(tsXmlFile.replace("/ts.xml","")):
    	    if re.search("impulses\.",file) and re.search("\.xml", file) and not re.search("\.old", file):
		include = doc.createElement("include")
		include.setAttribute("url",file)
	    
		includes = dom.getElementsByTagName("include")
		isAppend = True
		for inc in includes:
		    if inc.getAttribute("url") == file:
			isAppend = False
	    
		if isAppend:
		    dom.appendChild(include)
		    newStr=doc.createTextNode("\n")
		    dom.appendChild(newStr)
		    #Obj.sig(self.out,_("В ts.xml добавлена нода "+str(include)))
		    print _("В ts.xml добавлена нода "+str(include))
		else:
		    #Obj.sig(self.out,_("В ts.xml уже имеется нода <include url='"+file+"' />"))
		    print _("В ts.xml уже имеется нода <include url='"+file+"' />")
	file=open(tsXmlFile,'w')
	Print(doc,file,"utf-8")
	#Obj.sig(self.out,_("Записан файл "+str(tsXmlFile)))
	print "Записан файл ", str(tsXmlFile)
def _testElementReprAndStrUnicode():
    dom = Document()
    el = dom.appendChild(dom.createElement(u"abc"))
    string1 = repr(el)
    string2 = str(el)
    confirm(string1 == string2)
    dom.unlink()
Esempio n. 8
0
def _testElementReprAndStrUnicode():
    dom = Document()
    el = dom.appendChild(dom.createElement(u"abc"))
    string1 = repr(el)
    string2 = str(el)
    confirm(string1 == string2)
    dom.unlink()
Esempio n. 9
0
def _testElementReprAndStrUnicodeNS():
    dom = Document()
    el = dom.appendChild(
        dom.createElementNS(u"http://www.slashdot.org", u"slash:abc"))
    string1 = repr(el)
    string2 = str(el)
    confirm(string1 == string2)
    confirm(string1.find("slash:abc") != -1)
    dom.unlink()
def _testElementReprAndStrUnicodeNS():
    dom = Document()
    el = dom.appendChild(
        dom.createElementNS(u"http://www.slashdot.org", u"slash:abc"))
    string1 = repr(el)
    string2 = str(el)
    confirm(string1 == string2)
    confirm(string1.find("slash:abc") != -1)
    dom.unlink()
def testRemoveAttr():
    dom = Document()
    child = dom.appendChild(dom.createElement("abc"))

    child.setAttribute("def", "ghi")
    confirm(len(child.attributes) == 1)
    child.removeAttribute("def")
    confirm(len(child.attributes) == 0)

    dom.unlink()
def testDeleteAttr():
    dom = Document()
    child = dom.appendChild(dom.createElement("abc"))

    confirm(len(child.attributes) == 0)
    child.setAttribute("def", "ghi")
    confirm(len(child.attributes) == 1)
    del child.attributes["def"]
    confirm(len(child.attributes) == 0)
    dom.unlink()
Esempio n. 13
0
def testDeleteAttr():
    dom = Document()
    child = dom.appendChild(dom.createElement("abc"))

    confirm(len(child.attributes) == 0)
    child.setAttribute("def", "ghi")
    confirm(len(child.attributes) == 1)
    del child.attributes["def"]
    confirm(len(child.attributes) == 0)
    dom.unlink()
Esempio n. 14
0
def testRemoveAttr():
    dom = Document()
    child = dom.appendChild(dom.createElement("abc"))

    child.setAttribute("def", "ghi")
    confirm(len(child.attributes) == 1)
    child.removeAttribute("def")
    confirm(len(child.attributes) == 0)

    dom.unlink()
def testRemoveAttributeNode():
    dom = Document()
    child = dom.appendChild(dom.createElement("foo"))
    child.setAttribute("spam", "jam")
    confirm(len(child.attributes) == 1)
    node = child.getAttributeNode("spam")
    child.removeAttributeNode(node)
    confirm(len(child.attributes) == 0
            and child.getAttributeNode("spam") is None)

    dom.unlink()
Esempio n. 16
0
def testRemoveAttributeNode():
    dom = Document()
    child = dom.appendChild(dom.createElement("foo"))
    child.setAttribute("spam", "jam")
    confirm(len(child.attributes) == 1)
    node = child.getAttributeNode("spam")
    child.removeAttributeNode(node)
    confirm(
        len(child.attributes) == 0 and child.getAttributeNode("spam") is None)

    dom.unlink()
def testRemoveAttrNS():
    dom = Document()
    child = dom.appendChild(
            dom.createElementNS("http://www.python.org", "python:abc"))
    child.setAttributeNS("http://www.w3.org", "xmlns:python",
                                            "http://www.python.org")
    child.setAttributeNS("http://www.python.org", "python:abcattr", "foo")
    confirm(len(child.attributes) == 2)
    child.removeAttributeNS("http://www.python.org", "abcattr")
    confirm(len(child.attributes) == 1)

    dom.unlink()
Esempio n. 18
0
def testRemoveAttrNS():
    dom = Document()
    child = dom.appendChild(
        dom.createElementNS("http://www.python.org", "python:abc"))
    child.setAttributeNS("http://www.w3.org", "xmlns:python",
                         "http://www.python.org")
    child.setAttributeNS("http://www.python.org", "python:abcattr", "foo")
    confirm(len(child.attributes) == 2)
    child.removeAttributeNS("http://www.python.org", "abcattr")
    confirm(len(child.attributes) == 1)

    dom.unlink()
def testAddAttr():
    dom = Document()
    child = dom.appendChild(dom.createElement("abc"))

    child.setAttribute("def", "ghi")
    confirm(child.getAttribute("def") == "ghi")
    confirm(child.attributes["def"].value == "ghi")

    child.setAttribute("jkl", "mno")
    confirm(child.getAttribute("jkl") == "mno")
    confirm(child.attributes["jkl"].value == "mno")

    confirm(len(child.attributes) == 2)

    child.setAttribute("def", "newval")
    confirm(child.getAttribute("def") == "newval")
    confirm(child.attributes["def"].value == "newval")

    confirm(len(child.attributes) == 2)
    dom.unlink()
Esempio n. 20
0
def testAddAttr():
    dom = Document()
    child = dom.appendChild(dom.createElement("abc"))

    child.setAttribute("def", "ghi")
    confirm(child.getAttribute("def") == "ghi")
    confirm(child.attributes["def"].value == "ghi")

    child.setAttribute("jkl", "mno")
    confirm(child.getAttribute("jkl") == "mno")
    confirm(child.attributes["jkl"].value == "mno")

    confirm(len(child.attributes) == 2)

    child.setAttribute("def", "newval")
    confirm(child.getAttribute("def") == "newval")
    confirm(child.attributes["def"].value == "newval")

    confirm(len(child.attributes) == 2)
    dom.unlink()
def testNonZero():
    dom = parse(tstfile)
    confirm(dom)# should not be zero
    dom.appendChild(dom.createComment("foo"))
    confirm(not dom.childNodes[-1].childNodes)
    dom.unlink()
def testElement():
    dom = Document()
    dom.appendChild(dom.createElement("abc"))
    confirm(dom.documentElement)
    dom.unlink()
Esempio n. 23
0
def testElement():
    dom = Document()
    dom.appendChild(dom.createElement("abc"))
    confirm(dom.documentElement)
    dom.unlink()
Esempio n. 24
0
def testNonZero():
    dom = parse(tstfile)
    confirm(dom)  # should not be zero
    dom.appendChild(dom.createComment("foo"))
    confirm(not dom.childNodes[-1].childNodes)
    dom.unlink()
Esempio n. 25
0
    def saveAll(self):

	open(self.resultsPath+"/impulses.diag.xml", 'w').write(self.impCont)
	
	open(self.resultsPath+"/diag.xml", 'w').write(self.diagCont)

	diagButtons=open(self.templatePath+"/diag.buttons.xml", 'r').read()
	open(self.resultsPath+"/diag.buttons.xml", 'w').write(diagButtons)

	open(self.resultsPath+"/diag-tests.xml", 'w').write(self.umvTestsCont)

	open(self.resultsPath+"/impulses.diag-tests.xml", 'w').write(self.umvTestsImpCont)
	
	self.background()	
	
	file=open("../svg/diag/"+self.resultsPath+"/full.svg", 'w')
	Print(self.fullDoc, file, "utf-8")
	file.close()
	    
	


	# Записать эти файлы в storyall.xml
	try:
	    doc = FromXmlFile(self.resultsPath+"/storyall.xml")
	    Print (doc)
	    dom = doc.documentElement
	    
	    inc = doc.createElement("include")
	    inc.setAttribute("url", "diag-tests.xml")
	    isIncAlready=False
	    incs = dom.getElementsByTagName("include")
	    for i in incs:
		if i.getAttribute("url")==inc.getAttribute("url"):
		    isIncAlready=True
		    break
	    if not isIncAlready:
		dom.appendChild(inc)	
		dom.appendChild(doc.createTextNode("\n"))
	
	    inc = doc.createElement("include")
	    inc.setAttribute("url", "diag.xml")
	    isIncAlready=False
	    incs = dom.getElementsByTagName("include")
	    for i in incs:
		if i.getAttribute("url")==inc.getAttribute("url"):
		    isIncAlready=True
		    break
	    if not isIncAlready:
		dom.appendChild(inc)	
		dom.appendChild(doc.createTextNode("\n"))
	    	
	    inc = doc.createElement("include")
	    inc.setAttribute("url", "diag.buttons.xml")
	    isIncAlready=False
	    incs = dom.getElementsByTagName("include")
	    for i in incs:
		if i.getAttribute("url")==inc.getAttribute("url"):
		    isIncAlready=True
		    break
	    if not isIncAlready:
		dom.appendChild(inc)	
		dom.appendChild(doc.createTextNode("\n"))
	
	    f=open(self.resultsPath+"/storyall.xml", 'w')
	    Print(doc, f, "utf-8")
	
	except Exception, msg:
	    print "Diag::saveAll(): EXCEPTION (while writing to 'storyall.xml'):", msg
def testAttributeRepr():
    dom = Document()
    el = dom.appendChild(dom.createElement(u"abc"))
    node = el.setAttribute("abc", "def")
    confirm(str(node) == repr(node))
    dom.unlink()
Esempio n. 27
0
	
	for obj in objs:
	    temp=string.split(obj.getAttribute("url"), "/")
    	    inc_file_simple=temp[len(temp)-1]
	    
	    temp1=string.split(self.svgFile, "/")
	    real_path=""
	    for i in range (0, len(temp1)-1):
		real_path+="/"+temp1[i]
	    #print "real_path="+real_path
	    inc_file=str(real_path)+"/"+str(inc_file_simple)
	    try:
		doc1=FromXmlFile(inc_file)
		dom1=doc1.documentElement
		includedNode=doc.importNode(dom1,1)
		dom.appendChild(includedNode)
	    except Exception, msg:
		print "MultipleSVG() WARNING: невозможно обработать файл ", inc_file, "[", msg, "]"

	    print "HEREEEEEEEEEEE234324"    
	    
	    
	    # скопировать подинклуживаемые файлы в новый проект
	    try:
		
		f1=open(self.resultPath+"/svg/"+inc_file_simple, 'w')
		Print (doc1, f1, 'utf-8')
		f1.close()
	    except Exception, e:
		print "ERROR. generator.py::MultipleSVG(): Ошибка во время попытки записи файла "+self.resultPath+"/svg/"+inc_file_simple
	
Esempio n. 28
0
def testAttributeRepr():
    dom = Document()
    el = dom.appendChild(dom.createElement(u"abc"))
    node = el.setAttribute("abc", "def")
    confirm(str(node) == repr(node))
    dom.unlink()
Esempio n. 29
0
	# Записать эти файлы в ts.xml
	try:
	    doc = FromXmlFile("ts.xml")
	    Print (doc)
	    dom = doc.documentElement

	    inc = doc.createElement("include")
	    inc.setAttribute("url", "impulses.maket.xml")
	    isIncAlready=False
	    incs = dom.getElementsByTagName("include")
	    for i in incs:
		if i.getAttribute("url")==inc.getAttribute("url"):
		    isIncAlready=True
		    break
	    if not isIncAlready:
		dom.appendChild(inc)
		dom.appendChild(doc.createTextNode("\n"))

	    f=open("ts.xml", 'w')
	    Print(doc, f, "utf-8")

	except Exception, msg:
	    print "Maket::include(): EXCEPTION (while writing to 'ts.xml'):", msg





    def saveFiles(self):
    
	TSseller = seller.TSandTUseller(self.maxImpulses, ".last.ts")