Abstract
This document describes the internals of a Python-language module to represent birdwatching field notes in XML.
This publication is available in Web form and also as a PDF document. Please
forward any comments to john@nmt.edu.
Table of Contents
.readNode() and .writeNode()class BirdNoteSet: One file's worth of
notesBirdNoteSet.__init__(): ConstructorBirdNoteSet.addDay(): Add one day listBirdNoteSet.genDays(): Generate days
in selfBirdNoteSet.readFile(): Add a file's
contentBirdNoteSet._fileTime(): Update the
most recent modification timeBirdNoteSet._validate(): Open and
validate the fileBirdNoteSet.writeFile(): Translate to
XMLclass DayNotes: Notes from one date and
stateDayNotes.title(): Daily full
titleDayNotes.defaultLoc(): Return the
default locationDayNotes.addLoc()DayNotes.lookupLoc(): Look up a location
codeDayNotes.addForm(): Add a form to one
day's notesDayNotes.lookupForm()DayNotes._phyloKey()DayNotes.genForms(): Generate forms
in phylogenetic orderDayNotes.genFormsSeq(): Generate
forms in the order they were addedDayNotes.__init__(): ConstructorDayNotes.writeNode(): Internal form
to XMLDayNotes.readNode(): XML to internal
formclass DaySummary: Daily summaryDaySummary.__init__()DaySummary.defaultLoc(): Return the
default locationDaySummary.addLoc(): Add a location
definitionDaySummary.lookupLoc(): Find a
location by its codeDaySummary.genLocs(): Generate all
locationsDaySummary.readNode(): Convert from
XML (static method)DaySummary.dayAnnotation(): Process
day-annotation contentDaySummary.writeNode(): Translate to
XMLclass Loc: Locality code definitionclass Gps: GPS waypointclass BirdForm: Notes for one kind of
birdBirdForm.__len__(): Number of
sightingsBirdForm.__getitem__(): Index functionBirdForm.addSighting()BirdForm.genSightings()BirdForm.__init__()BirdForm.getLocGroup(): Find the
effective localityBirdForm.readNode() (static
method)BirdForm.getTaxonGroup() (static
method)BirdForm.singleSighting(): Read a
single sightingBirdForm.multiSighting(): Read the
multi-sighting caseBirdForm.readFloc(): Read one floc elementBirdForm.writeNode(): Translate to
XMLBirdForm._writeTaxonGroup()BirdForm.writeSingle(): Create
single-sighting XMLBirdForm.writeMulti(): Create multi-sighting
XMLclass Sighting: Sighting groupclass LocGroup: Sighting's localityclass AgeSexGroup: Sighting core dataclass SightNotes: Optional notesclass Photo: Photo linkclass Narrative: Narrative elementsNarrative.__init__(): ConstructorNarrative.addPara(): Add a
paragraphNarrative.__len__(): How many
paragraphs?Narrative.__getitem__(): Get one
paragraphNarrative.genParas(): Generate self's
contained paragraphsNarrative.writeNode(): Write as XMLNarrative.readNode(): Read XML (static
method)Narrative.readChild() (static
method)class Paragraph: One paragraph of mixed
textParagraph.__init__(): ConstructorParagraph.addContent()Paragraph.genContent(): Generate the
contentParagraph.writeNode(): Write as
XMLParagraph.writeContent(): Write the
content of a paragraphParagraph._writeParaChild()Paragraph.readNode(): Process a para element (static method)Paragraph.addPhrase(): Add one phrase to the
paragraphclass BirdNoteTreeclass FlatSighting: Complete sighting
recordA system for encoding bird field notes describes an XML schema for encoding birdwatching field notes, along with a Python module that reads and writes XML files conforming to that schema. This document contains the actual code for the module, in literate programming style. For more information, see the author's literate programming page.
The birdnotes.py module reads and writes XML using techniques
described in Python XML processing with lxml. The reader should be familiar with Python and
XML.
Files referred to in this document:
The module itself, birdnotes.py.
The DocBook source for this document, birdnotespy.xml.
The module exports a number of classes. Each represents an XML element. As an entity-relationship diagram:

This diagram does not show the Narrative class,
which appears at multiple places, and can have zero or more
Paragraph children.
class BirdNoteSet represents the
contents of one XML file conforming to birdnotes.rnc.
See Section 7, “class BirdNoteSet: One file's worth of
notes”.