Changeset 11 for trunk/python/Rappture/library.py
- Timestamp:
- May 30, 2005 9:33:49 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/python/Rappture/library.py
r6 r11 40 40 41 41 # ------------------------------------------------------------------ 42 def element(self, path="", flavor="object"):42 def element(self, path="", as="object"): 43 43 """ 44 44 Clients use this to query a particular element within the … … 51 51 By default, this method returns an object representing the 52 52 DOM node referenced by the path. This is changed by setting 53 the " flavor" argument to "id" (for name of the tail element),53 the "as" argument to "id" (for name of the tail element), 54 54 to "type" (for the type of the tail element), to "component" 55 55 (for the component name "type(id)"), or to "object" … … 61 61 return None 62 62 63 if flavor== 'object':63 if as == 'object': 64 64 return library(node) 65 elif flavor== 'component':65 elif as == 'component': 66 66 return self._node2comp(node) 67 elif flavor== 'id':67 elif as == 'id': 68 68 return self._node2name(node) 69 elif flavor== 'type':69 elif as == 'type': 70 70 return node.tagName 71 71 72 raise ValueError, "bad flavor '%s': should be object, id, type" % flavor73 74 # ------------------------------------------------------------------ 75 def children(self, path="", flavor="object", type=None):72 raise ValueError, "bad as value '%s': should be component, id, object, type" % as 73 74 # ------------------------------------------------------------------ 75 def children(self, path="", as="object", type=None): 76 76 """ 77 77 Clients use this to query the children of a particular element … … 83 83 84 84 By default, this method returns a list of objects representing 85 the children. This is changed by setting the " flavor" argument85 the children. This is changed by setting the "as" argument 86 86 to "id" (for tail names of all children), to "type" (for the 87 87 types of all children), to "component" (for the path component … … 99 99 nlist = [n for n in nlist if n.nodeName == type] 100 100 101 if flavor== 'object':101 if as == 'object': 102 102 return [library(n) for n in nlist] 103 elif flavor== 'component':103 elif as == 'component': 104 104 return [self._node2comp(n) for n in nlist] 105 elif flavor== 'id':105 elif as == 'id': 106 106 return [self._node2name(n) for n in nlist] 107 elif flavor== 'type':107 elif as == 'type': 108 108 return [n.tagName for n in nlist] 109 110 raise ValueError, "bad as value '%s': should be component, id, object, type" % as 109 111 110 112 # ------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.