Each instance of a Taxon object
represents one taxon. These objects make up the tree
representing the taxonomic arrangement.
See Section 9.1, “Class Txny: the complete system” for various ways to obtain
Taxon objects corresponding to a
given scientific name, bird code, or taxonomic key number.
Attributes of a Taxon object:
.txny
A pointer back to the Txny object in
which this taxon is located.
.parent
For the root taxon, this attribute is None. For the other taxa in the
tree, it points to the taxon that has this taxon as
a child.
.abbr
The standard bird code, if this taxon has one. Higher ranks such as families and orders may not have a standard code.
.rank
The rank of this taxon, as a Rank
object.
.sci
The scientific name of the taxon, as a string.
.status
The status code for this taxon. For the values of
status codes, see Section 5.2.2, “
Species records in the .std
file
”.
.txKey
The taxonomic key number for this taxon.
These methods are available on Taxon objects:
.contains(t2)
If t2 is another
Taxon object in the same
Txny, this predicate tests
whether self contains
t2.
.nearestAncestor(t2)
If t2 is another
Taxon object in the same
Txny, this method returns
the nearest ancestor of self and t2 as a Taxon object.
.childContaining(desc)
If desc is a Taxon
descended from self, this method
returns the child of self that
contains desc.
If desc is not a descendant of self, the method raises ValueError.
.__cmp__(self, other)
This method implements the cmp()
function for comparing two Taxon
objects. The comparison is in phylogenetic order, that is,
the taxon with the lower .txKey
attribute will compare lower.
.__getitem__(self, n)
If 0 <= n < len(self), returns the nth child
of self; otherwise it raises KeyError. This method is called when
a Taxon object t is indexed as “t[n]”.
.__iter__(self)
Defines the iter()
function on a Taxon
element. In constructs such as “for child in taxon”, this
function returns an iterator that visits each child
in order, 0, 1, ....
.__len__(self)
Returns the number of child taxa.
.eng
The English name of the taxon, as a string. If some
words are scientific names, this attribute will not
include any indication that those words should be
italicized. For example, for code "BRANTH", this attribute will be "Brant (hrota)", even though the species name hrota should be rendered in italics.
.engComma
The English name of the taxon, as a string, but with
multi-word names inverted as “last,
first”, e.g., "Owl, Great Gray"
instead of "Great Gray Owl".
.tex
In most case this attribute's value is the same as the
.eng attribute. However, if some words
are scientific names that should be rendered in italics,
this attribute will mark up those words using
TEX/LaTEX markup conventions.
For example, for code "BRANTH", this
attribute will be "Brant ({\it hrota\/})".
.texComma
Like .tex, but the English name is
inverted. Example: "Redpoll, ({\it rostrata\/})
Common".
.engHtmlSubelt(node, cssClass=None)
This method works with the pylxml package to render the English name
as HTML content. The node argument is an
HTML element as an instance of the etree.Element class. The English name is added
as content of node.
If the English name has words that should be italicized,
it will mark them up in HTML. If the cssClass argument is omitted, it will use the
deprecated HTML “i” element
for italics. If the Web page you are building is styled
with a CSS stylesheet, it will wrap italicized words in
an element of the form “<span
class="”, where C">...</span> is your CcssClass argument.
For example, for code "ROCRED" with the
default cssClass=None, the rendered HTML
might look like this.
(<i>rostrata</i>) Common Redpoll
The same example with cssClass="ital":
(<span class='ital'>rostrata</span>) Common Redpoll
.engHtmlSubeltComma(node, cssClass=none)
Same as .engHtmlSubelt, but the English
name is presented in inverted order. Example of a
return value for code "ROCRED":
Redpoll, (<i>rostrata</i>) Common
The same example with cssClass="ital":
Redpoll, (<span class='ital'>rostrata</span>) Common