Next / Previous / Contents / Shipman's homepage

20.3. BirdNoteTree.genMonths(): Read monthly files
# - - -   B i r d N o t e T r e e . g e n M o n t h s

    def genMonths(self, startDate=None, endDate=None,
                    startSeason=None, endSeason=None):
        '''Generate BirdNoteSet instances from the tree

Attribute self._monthList contains the sorted list of "YYYY-MM" strings for the files that appear to be notes files. There is, of course, no guarantee that we can read them, or that they are valid.
        #-- 1 --
        # [ if all month files corresponding to elements of
        #   self._monthList are readable and valid ->
        #     generate a sequence of BirdNoteSet instances
        #     representing those files in the same order
        #   else ->
        #     generate zero or more BirdNoteSet instances
        #     raise IOError ]
        for monthKey in self._monthList:
            #-- 1 body --
            # [ if the month for monthKey cannot contain any
            #   records in the date interval (startDate, endDate)
            #   or the season interval (startSeason, endSeason) ->
            #     I
            #   else if the month file corresponding to monthKey is
            #   readable and valid ->
            #     yield a BirdNoteSet instances representing
            #     that file
            #   else ->
            #     raise IOError ]
            if self._timeFilter(monthKey, startDate, endDate,
                                   startSeason, endSeason):
                yield self._readMonth(monthKey)