Panda3D
Public Member Functions | Static Public Attributes

_ElementInterface Class Reference

Internal element class. More...

List of all members.

Public Member Functions

def __init__
def __delitem__
 Deletes the given subelement.
def __delslice__
 Deletes a number of subelements.
def __getitem__
 Returns the given subelement.
def __getslice__
 Returns a list containing subelements in the given range.
def __len__
 Returns the number of subelements.
def __repr__
def __setitem__
 Replaces the given subelement.
def __setslice__
 Replaces a number of subelements with elements from a sequence.
def append
 Adds a subelement to the end of this element.
def clear
 Resets an element.
def find
 Finds the first matching subelement, by tag name or path.
def findall
 Finds all matching subelements, by tag name or path.
def findtext
 Finds text for the first matching subelement, by tag name or path.
def get
 Gets an element attribute.
def getchildren
 Returns all subelements.
def getiterator
 Creates a tree iterator.
def insert
 Inserts a subelement at the given position in this element.
def items
 Gets element attributes, as a sequence.
def keys
 Gets a list of attribute names.
def makeelement
 Creates a new element object of the same type as this element.
def remove
 Removes a matching subelement.
def set
 Sets an element attribute.

Static Public Attributes

 attrib = None
 (Attribute) Element attribute dictionary.
 tag = None
 (Attribute) Element tag.
 tail = None
 (Attribute) Text after this element's end tag, but before the next sibling element's start tag.
 text = None
 (Attribute) Text before first subelement.

Detailed Description

Internal element class.

This class defines the Element interface, and provides a reference implementation of this interface.

You should not create instances of this class directly. Use the appropriate factory functions instead, such as Element and SubElement.

See also:
Element
SubElement
Comment
ProcessingInstruction

Constructor & Destructor Documentation

def __init__ (   self,
  tag,
  attrib 
)

Member Function Documentation

def __delitem__ (   self,
  index 
)

Deletes the given subelement.

Parameters:
indexWhat subelement to delete.
Exceptions:
IndexErrorIf the given element does not exist.
def __delslice__ (   self,
  start,
  stop 
)

Deletes a number of subelements.

Parameters:
startThe first subelement to delete.
stopThe first subelement to leave in there.
def __getitem__ (   self,
  index 
)

Returns the given subelement.

Parameters:
indexWhat subelement to return.
Returns:
The given subelement.
Exceptions:
IndexErrorIf the given element does not exist.
def __getslice__ (   self,
  start,
  stop 
)

Returns a list containing subelements in the given range.

Parameters:
startThe first subelement to return.
stopThe first subelement that shouldn't be returned.
Returns:
A sequence object containing subelements.
def __len__ (   self)

Returns the number of subelements.

Returns:
The number of subelements.
def __repr__ (   self)
def __setitem__ (   self,
  index,
  element 
)

Replaces the given subelement.

Parameters:
indexWhat subelement to replace.
elementThe new element value.
Exceptions:
IndexErrorIf the given element does not exist.
AssertionErrorIf element is not a valid object.
def __setslice__ (   self,
  start,
  stop,
  elements 
)

Replaces a number of subelements with elements from a sequence.

Parameters:
startThe first subelement to replace.
stopThe first subelement that shouldn't be replaced.
elementsA sequence object with zero or more elements.
Exceptions:
AssertionErrorIf a sequence member is not a valid object.
def append (   self,
  element 
)

Adds a subelement to the end of this element.

Parameters:
elementThe element to add.
Exceptions:
AssertionErrorIf a sequence member is not a valid object.
def clear (   self)

Resets an element.

This function removes all subelements, clears all attributes, and sets the text and tail attributes to None.

def find (   self,
  path 
)

Finds the first matching subelement, by tag name or path.

Parameters:
pathWhat element to look for.
Returns:
The first matching element, or None if no element was found. Element or None
def findall (   self,
  path 
)

Finds all matching subelements, by tag name or path.

Parameters:
pathWhat element to look for.
Returns:
A list or iterator containing all matching elements, in document order. list of Element instances
def findtext (   self,
  path,
  default = None 
)

Finds text for the first matching subelement, by tag name or path.

Parameters:
pathWhat element to look for.
defaultWhat to return if the element was not found.
Returns:
The text content of the first matching element, or the default value no element was found. Note that if the element has is found, but has no text content, this method returns an empty string. string
def get (   self,
  key,
  default = None 
)

Gets an element attribute.

Parameters:
keyWhat attribute to look for.
defaultWhat to return if the attribute was not found.
Returns:
The attribute value, or the default value, if the attribute was not found. string or None
def getchildren (   self)

Returns all subelements.

The elements are returned in document order.

Returns:
A list of subelements. list of Element instances
def getiterator (   self,
  tag = None 
)

Creates a tree iterator.

The iterator loops over this element and all subelements, in document order, and returns all elements with a matching tag.

If the tree structure is modified during iteration, the result is undefined.

Parameters:
tagWhat tags to look for (default is to return all elements).
Returns:
A list or iterator containing all the matching elements. list or iterator
def insert (   self,
  index,
  element 
)

Inserts a subelement at the given position in this element.

Parameters:
indexWhere to insert the new subelement.
Exceptions:
AssertionErrorIf the element is not a valid object.
def items (   self)

Gets element attributes, as a sequence.

The attributes are returned in an arbitrary order.

Returns:
A list of (name, value) tuples for all attributes. list of (string, string) tuples
def keys (   self)

Gets a list of attribute names.

The names are returned in an arbitrary order (just like for an ordinary Python dictionary).

Returns:
A list of element attribute names. list of strings
def makeelement (   self,
  tag,
  attrib 
)

Creates a new element object of the same type as this element.

Parameters:
tagElement tag.
attribElement attributes, given as a dictionary.
Returns:
A new element instance.
def remove (   self,
  element 
)

Removes a matching subelement.

Unlike the find methods, this method compares elements based on identity, not on tag value or contents.

Parameters:
elementWhat element to remove.
Exceptions:
ValueErrorIf a matching element could not be found.
AssertionErrorIf the element is not a valid object.
def set (   self,
  key,
  value 
)

Sets an element attribute.

Parameters:
keyWhat attribute to set.
valueThe attribute value.

Member Data Documentation

attrib = None [static]

(Attribute) Element attribute dictionary.

Where possible, use _ElementInterface.get, _ElementInterface.set, _ElementInterface.keys, and _ElementInterface.items to access element attributes.

tag = None [static]

(Attribute) Element tag.

tail = None [static]

(Attribute) Text after this element's end tag, but before the next sibling element's start tag.

This is either a string or the value None, if there was no text.

text = None [static]

(Attribute) Text before first subelement.

This is either a string or the value None, if there was no text.

 All Classes Namespaces Functions Variables Properties