blob: af96383f9ca0e3c9849cf1f65f480617328d67ea [file] [log] [blame]
Daniel Veillardd2897fd2002-01-30 16:37:32 +00001import _libxml
2
3class xmlNode:
4 def __init__(self, _obj=None):
5 if _obj != None:
6 self._o = _obj;
7 return
8 self._o = None
9
10# def __getattr__(self, attr):
11# attrs = {
12# 'lower': _gtk.gtk_adjustment_get_lower,
13# 'upper': _gtk.gtk_adjustment_get_upper,
14# 'value': _gtk.gtk_adjustment_get_value,
15# 'step_increment': _gtk.gtk_adjustment_get_step_increment,
16# 'page_increment': _gtk.gtk_adjustment_get_page_increment,
17# 'page_size': _gtk.gtk_adjustment_get_page_size
18# }
19# if attrs.has_key(attr):
20# ret = attrs[attr](self._o)
21# if ret == None:
22# return None
23# return attrs[attr](self._o)
24 def __getattr__(self, attr):
25 if attr == "parent":
26 ret = _libxml.parent(self._o)
27 if ret == None:
28 return None
29 return xmlNode(_obj=ret)
30 elif attr == "properties":
31 ret = _libxml.properties(self._o)
32 if ret == None:
33 return None
34 return xmlNode(_obj=ret)
35 elif attr == "children":
36 ret = _libxml.children(self._o)
37 if ret == None:
38 return None
39 return xmlNode(_obj=ret)
40 elif attr == "last":
41 ret = _libxml.last(self._o)
42 if ret == None:
43 return None
44 return xmlNode(_obj=ret)
45 elif attr == "next":
46 ret = _libxml.next(self._o)
47 if ret == None:
48 return None
49 return xmlNode(_obj=ret)
50 elif attr == "prev":
51 ret = _libxml.prev(self._o)
52 if ret == None:
53 return None
54 return xmlNode(_obj=ret)
55 elif attr == "content":
56 return self.content()
57 elif attr == "name":
58 return _libxml.name(self._o)
59 elif attr == "type":
60 return _libxml.type(self._o)
61 elif attr == "doc":
62 ret = _libxml.doc(self._o)
63 if ret == None:
64 return None
65 return xmlDoc(_doc=ret)
66 raise AttributeError,attr
67
68 #
69 # Those are common attributes to nearly all type of nodes
70 #
71 def get_parent(self):
72 ret = _libxml.parent(self._o)
73 if ret == None:
74 return None
75 return xmlNode(_obj=ret)
76 def get_children(self):
77 ret = _libxml.children(self._o)
78 if ret == None:
79 return None
80 return xmlNode(_obj=ret)
81 def get_last(self):
82 ret = _libxml.last(self._o)
83 if ret == None:
84 return None
85 return xmlNode(_obj=ret)
86 def get_next(self):
87 ret = _libxml.next(self._o)
88 if ret == None:
89 return None
90 return xmlNode(_obj=ret)
91 def get_prev(self):
92 ret = _libxml.prev(self._o)
93 if ret == None:
94 return None
95 return xmlNode(_obj=ret)
96 def get_content(self):
97 return self.content()
98 def get_name(self):
99 return _libxml.name(self._o)
100 def get_type(self):
101 return _libxml.type(self._o)
102 def get_doc(self):
103 ret = _libxml.doc(self._o)
104 if ret == None:
105 return None
106 return xmlDoc(_doc=ret)
107 def free(self):
108 _libxml.freeDoc(self._o)
109
110
111class xmlDoc(xmlNode):
112 def __init__(self, file = None, _doc=None):
113 if _doc == None and file != None:
114 _doc = _libxml.parseFile(file)
115 xmlNode.__init__(self, _obj=_doc)