Commit cda80744 authored by joey's avatar joey

Syntax modification made.

parent 5a584914
...@@ -21,14 +21,12 @@ Oh well. ...@@ -21,14 +21,12 @@ Oh well.
import string import string
from pickle import * from pickle import *
import xmllib
class XYap: class xyap:
start_handlers={} start_handlers={}
end_handlers={} end_handlers={}
def __init__(self, parser): def __init__(self):
parser.__init__(self)
top=[] top=[]
self._stack=_stack=[top] self._stack=_stack=[top]
self.push=_stack.append self.push=_stack.append
...@@ -37,6 +35,13 @@ class XYap: ...@@ -37,6 +35,13 @@ class XYap:
def handle_data(self, data): self.append(data) def handle_data(self, data): self.append(data)
def unknown_starttag(self, tag, attrs): def unknown_starttag(self, tag, attrs):
if type(attrs) is ListType:
x=0
temp={}
while x<len(attrs):
temp[attrs[x]]=attrs[x+1]
x=x+2
attrs=temp
start=self.start_handlers start=self.start_handlers
if start.has_key(tag): tag = start[tag](self, tag, attrs) if start.has_key(tag): tag = start[tag](self, tag, attrs)
else: tag = [tag, attrs] else: tag = [tag, attrs]
...@@ -57,6 +62,7 @@ class NoBlanks: ...@@ -57,6 +62,7 @@ class NoBlanks:
def handle_data(self, data): def handle_data(self, data):
if string.strip(data): self.append(data) if string.strip(data): self.append(data)
import xmllib
def struct(self, tag, data): def struct(self, tag, data):
r={} r={}
...@@ -68,6 +74,13 @@ def name(self, tag, data, join=string.join, strip=string.strip): ...@@ -68,6 +74,13 @@ def name(self, tag, data, join=string.join, strip=string.strip):
def tuplef(self, tag, data): return tuple(data[2:]) def tuplef(self, tag, data): return tuple(data[2:])
class XYap(xyap, xmllib.XMLParser):
def __init__(self):
xmllib.XMLParser.__init__(self)
top=[]
self._stack=_stack=[top]
self.push=_stack.append
self.append=top.append
class xmlrpc(NoBlanks, XYap, xmllib.XMLParser): class xmlrpc(NoBlanks, XYap, xmllib.XMLParser):
end_handlers={ end_handlers={
...@@ -101,6 +114,7 @@ class xmlrpc(NoBlanks, XYap, xmllib.XMLParser): ...@@ -101,6 +114,7 @@ class xmlrpc(NoBlanks, XYap, xmllib.XMLParser):
} }
def test(): def test():
data="""<?xml version="1.0"?> data="""<?xml version="1.0"?>
<methodCall> <methodCall>
<methodName>examples.getStateName <methodName>examples.getStateName
...@@ -138,14 +152,10 @@ def test(): ...@@ -138,14 +152,10 @@ def test():
</methodCall> </methodCall>
""" """
data=string.split(data,'\n') data=string.split(data,'\n')
class xyap(XYap, xmllib.XMLParser): pass
r=[] r=[]
for C in xyap, xmlrpc: for C in XYap, xmlrpc:
p=C(xmllib.XMLParser) p=C()
for l in data: for l in data:
p.feed(l) p.feed(l)
p.close() p.close()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment