# - - - B i r d N o t e T r e e . _ _ f i n d M o n t h s
def __findMonths ( self, yyyy ):
'''Scan one year directory for month files.
[ (self.rootDir is as invariant) and
(yyyy is a year number as a 4-digit string) ->
if subdirectory (yyyy) of self.rootDir can be read ->
self.__monthList +:= the "YYYY-MM" part of
the names of files in that subdirectory
whose names match YYYY_MM_XML_PAT
else -> raise IOError ]
'''
For the pattern that matches month file names, see Section 4.3, “YYYY_MM_XML_PAT: Month file name
pattern”.
#-- 1 --
# [ subDirPath := path to subdirectory (yyyy) of
# directory (self.rootDir) ]
subDirPath = os.path.join ( self.rootDir, yyyy )
#-- 2 --
# [ if directory (subDirPath) can be read ->
# fileList := list of names in that directory that
# match YYYY_MM_XML_PAT
# else -> raise IOError ]
fileList = [ fileName
for fileName in os.listdir ( subDirPath )
if YYYY_MM_XML_PAT.match ( fileName ) ]
The .__monthList attribute contains only
the " strings.
YYYY-MM"
#-- 3 --
# [ self.__monthList +:= the "YYYY-MM" parts of
# the elements of fileList ]
for fileName in fileList:
self.__monthList.append ( fileName[:7] )