Package sword2 :: Module atom_objects :: Class Category
[hide private]
[frames] | no frames]

Class Category

source code


Convenience class to aid in the intepreting of atom:category elements in XML. Currently, this is read-only.

Usage:

>>> from sword2 import Category

... # `Category` expects an etree.SubElement node (`c_node` in this example) referencing an <atom:category> element: <atom:category term="...." scheme="...." label="....."> .... </atom:category>

# Load a `Category` instance: >>> c = Category(dom = c_node)

# Overrides `__str__` to provide a simple means to view the content >>> print c "Category scheme:http://purl.org/net/sword/terms/ term:http://purl.org/net/sword/terms/originalDeposit label:Orignal Deposit text:'None'"

# Element attributes appear as object attibutes: >>> c.scheme 'http://purl.org/net/sword/terms/'

# Element text will be in the text attribute, if text is present >>> c.text None

Instance Methods [hide private]
 
__init__(self, term=None, scheme=None, label=None, text=None, dom=None)
Init a `Category` class - 99% of the time, this will be done by setting the dom parameter.
source code
 
_from_element(self, e)
Load the `Category`'s internal attributes using the information within an `etree.SubElement`
source code
 
__str__(self)
Rudimentary way to display the data held, in a way amenable to stdout.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

__init__(self, term=None, scheme=None, label=None, text=None, dom=None)
(Constructor)

source code 

Init a `Category` class - 99% of the time, this will be done by setting the dom parameter.

However, if (for testing) there is a need to 'fake' a `Category`, all the attributes can be set in the constructor.

Overrides: object.__init__

__str__(self)
(Informal representation operator)

source code 

Rudimentary way to display the data held, in a way amenable to stdout.

Overrides: object.__str__