Next / Previous / Contents / Shipman's homepage

7.10. DayNotes.readForm(): Process one contained form

This method translates a form element into a BirdForm instance, and adds it to self.

birdnotes.py
# - - -   D a y N o t e s . r e a d F o r m

    def readForm ( self, txny, formNode ):
        """Translate a form node to a FormNode instance.

          [ (txny is a Txny instance) and
            (formNode is an et.Element) ->
              if formNode roots a valid rnc.FORM_N subtree
              in the context of txny ->
                self  :=  self with a BirdForm object added
                          representing formNode
              else -> raise IOError ]            
        """

First we call the static method Section 11.7, “BirdForm.readNode() (static method)” to convert the formNode into a BirdForm instance.

birdnotes.py
        #-- 1 --
        # [ if formNode is a valid rnc.FORM_N element ->
        #     birdForm  :=  a BirdForm instance representing that
        #                   element
        #   else -> raise IOError ]
        birdForm  =  BirdForm.readNode ( txny, self, formNode )

Then, if all goes well, we add it to self. See Section 7.4, “DayNotes.addForm(): Add a form to one day's notes”.

birdnotes.py
        #-- 2 --
        # [ self  :=  self with birdForm added ]
        self.addForm ( birdForm )