* piksemel implementation complete
This commit is contained in:
@@ -1,147 +0,0 @@
|
|||||||
diff -u pxml/autoxml.py zxml/autoxml.py
|
|
||||||
--- pxml/autoxml.py 2006-04-19 11:17:50.000000000 +0300
|
|
||||||
+++ zxml/autoxml.py 2006-04-19 11:13:39.000000000 +0300
|
|
||||||
@@ -11,7 +11,6 @@
|
|
||||||
#
|
|
||||||
#
|
|
||||||
# Authors: Eray Ozkural <eray@pardus.org.tr>
|
|
||||||
-# Gurer Ozen <gurer@pardus.org.tr>
|
|
||||||
# Bahadir Kandemir <bahadir@haftalik.net>
|
|
||||||
# Baris Metin <baris@pardus.org.tr>
|
|
||||||
|
|
||||||
@@ -32,8 +31,6 @@
|
|
||||||
import formatter
|
|
||||||
import sys
|
|
||||||
from StringIO import StringIO
|
|
||||||
-#import xml.dom.minidom as mdom
|
|
||||||
-#from xml.parsers.expat import ExpatError
|
|
||||||
|
|
||||||
import gettext
|
|
||||||
__trans = gettext.translation('pisi', fallback=True)
|
|
||||||
@@ -41,9 +38,9 @@
|
|
||||||
|
|
||||||
# PiSi
|
|
||||||
import pisi
|
|
||||||
-# TODO: find the appropriate xmlext implementation and import from there
|
|
||||||
-from pisi.pxml.xmlext import *
|
|
||||||
+import piksemel as iks
|
|
||||||
from pisi.pxml.xmlfile import XmlFile
|
|
||||||
+from pisi.pxml.xmlextpiks import *
|
|
||||||
import pisi.context as ctx
|
|
||||||
import pisi.util as util
|
|
||||||
import pisi.oo as oo
|
|
||||||
@@ -51,6 +48,7 @@
|
|
||||||
class Error(pisi.Error):
|
|
||||||
pass
|
|
||||||
|
|
||||||
+
|
|
||||||
# requirement specs
|
|
||||||
|
|
||||||
mandatory, optional = range(2) # poor man's enum
|
|
||||||
@@ -88,7 +86,7 @@
|
|
||||||
else:
|
|
||||||
for node in nodes:
|
|
||||||
#lang = getNodeAttribute(node, "xml:lang")
|
|
||||||
- lang = node.getAttributeNS(XML_NS, 'lang')
|
|
||||||
+ lang = node.getAttribute('xml:lang')
|
|
||||||
c = getNodeText(node)
|
|
||||||
if not c:
|
|
||||||
errs.append(where + ': ' + _("'%s' language of tag '%s' is empty") %
|
|
||||||
@@ -101,11 +99,9 @@
|
|
||||||
def encode(self, node, errs):
|
|
||||||
assert self.tag != ''
|
|
||||||
for key in self.iterkeys():
|
|
||||||
- newnode = newNode(node, self.tag)
|
|
||||||
- newnode.setAttributeNS(XML_NS, 'xml:lang', key)
|
|
||||||
- newtext = newTextNode(node, self[key])
|
|
||||||
- newnode.appendChild(newtext)
|
|
||||||
- node.appendChild(newnode)
|
|
||||||
+ tag = node.insertTag(self.tag)
|
|
||||||
+ tag.setAttribute('xml:lang', key)
|
|
||||||
+ tag.insertData(self[key])
|
|
||||||
|
|
||||||
#FIXME: maybe more appropriate for pisi.util
|
|
||||||
@staticmethod
|
|
||||||
@@ -478,10 +474,10 @@
|
|
||||||
tag_type = spec[0]
|
|
||||||
assert type(tag_type) == type(type)
|
|
||||||
def readtext(node, attr):
|
|
||||||
- return getNodeAttribute(node, attr)
|
|
||||||
+ return node.getAttribute(attr)
|
|
||||||
def writetext(node, attr, text):
|
|
||||||
#print 'write attr', attr, text
|
|
||||||
- node.setAttributeNS(XML_NS, attr, text)
|
|
||||||
+ node.setAttribute(attr, text)
|
|
||||||
anonfuns = cls.gen_anon_basic(attr, spec, readtext, writetext)
|
|
||||||
return cls.gen_named_comp(attr, spec, anonfuns)
|
|
||||||
|
|
||||||
@@ -696,9 +692,8 @@
|
|
||||||
if node and obj:
|
|
||||||
try:
|
|
||||||
#FIXME: this doesn't look pretty
|
|
||||||
- classnode = newNode(node, tag)
|
|
||||||
+ classnode = node.insertTag(tag)
|
|
||||||
obj.encode(classnode, errs)
|
|
||||||
- node.appendChild(classnode)
|
|
||||||
except Error:
|
|
||||||
if req == mandatory:
|
|
||||||
# note: we can receive an error if obj has no content
|
|
||||||
@@ -743,15 +738,16 @@
|
|
||||||
errs.append(where + ': ' + _('Mandatory list empty'))
|
|
||||||
ix = 1
|
|
||||||
for node in nodes:
|
|
||||||
- dummy = newNode(node, "Dummy")
|
|
||||||
- dummy.appendChild(node)
|
|
||||||
+ #print "[%s]" % node.toString()
|
|
||||||
+ dummy = iks.newDocument("Dummy")
|
|
||||||
+ dummy.insertNode(node)
|
|
||||||
+ #print "blaah"
|
|
||||||
l.append(decode_item(dummy, errs, where + unicode("[%s]" % ix)))
|
|
||||||
#l.append(decode_item(node, errs, where + unicode("[%s]" % ix)))
|
|
||||||
ix += 1
|
|
||||||
return l
|
|
||||||
|
|
||||||
def encode(node, l, errs):
|
|
||||||
- dom = node.ownerDocument
|
|
||||||
if l and len(l) > 0:
|
|
||||||
for item in l:
|
|
||||||
if list_tagpath:
|
|
||||||
Ortak alt dizinler: pxml/.svn ve zxml/.svn
|
|
||||||
diff -u pxml/xmlext.py zxml/xmlext.py
|
|
||||||
--- pxml/xmlext.py 2006-04-19 11:17:50.000000000 +0300
|
|
||||||
+++ zxml/xmlext.py 2006-04-19 09:30:53.000000000 +0300
|
|
||||||
@@ -12,9 +12,10 @@
|
|
||||||
# Authors: Eray Ozkural <eray@pardus.org.tr>
|
|
||||||
|
|
||||||
try:
|
|
||||||
- zimbabwe # comment out to disable piks
|
|
||||||
from xmlextpiks import *
|
|
||||||
except:
|
|
||||||
+ # to be sure piksemel is used
|
|
||||||
+ raise
|
|
||||||
try:
|
|
||||||
#if pisi.context.use_mdom:
|
|
||||||
# gibidi
|
|
||||||
@@ -26,6 +27,6 @@
|
|
||||||
print 'xmlext: cDomlette/piksemel implementation cannot be loaded, falling back to minidom'
|
|
||||||
from xmlextmdom import *
|
|
||||||
|
|
||||||
-from xml.dom import XHTML_NAMESPACE, XML_NAMESPACE
|
|
||||||
-XHTML_NS = unicode(XHTML_NAMESPACE)
|
|
||||||
-XML_NS = unicode(XML_NAMESPACE)
|
|
||||||
+#from xml.dom import XHTML_NAMESPACE, XML_NAMESPACE
|
|
||||||
+#XHTML_NS = unicode(XHTML_NAMESPACE)
|
|
||||||
+#XML_NS = unicode(XML_NAMESPACE)
|
|
||||||
diff -u pxml/xmlfile.py zxml/xmlfile.py
|
|
||||||
--- pxml/xmlfile.py 2006-04-19 11:17:50.000000000 +0300
|
|
||||||
+++ zxml/xmlfile.py 2006-04-19 09:30:53.000000000 +0300
|
|
||||||
@@ -14,8 +14,7 @@
|
|
||||||
import pisi.context
|
|
||||||
|
|
||||||
try:
|
|
||||||
- horagata # comment out to disable piks
|
|
||||||
- #from xmlfilepiks import *
|
|
||||||
+ from xmlfilepiks import *
|
|
||||||
except:
|
|
||||||
try:
|
|
||||||
#if pisi.context.use_mdom:
|
|
||||||
Reference in New Issue
Block a user