This method looks at the name of a batch file, which should
start with either a location code or a station number. If so,
it sets either self.location or self.station accordingly.
# - - - B a s e C o m p i l e r . p a r s e F i l e L o c a l i t y
def parseFileLocality(self):
'''Find the location or station part of self.fileName.
[ if self.fileName starts with a string that matches
LOCATION_PAT and is a location code defined
in self.stationSet ->
self.location := the Location with that location code
from self.stationSet
return self.fileName past that string
else if self.fileName starts with a string that matches
STA_NO_PAT and is a station number in self.stationSet ->
self.station := the Station with that station number
from self.stationSet
return self.fileName past that string
else ->
Log() +:= error message
raise ValueError ]
'''
First we use the precompiled regular expression LOCATION_PAT to see if self.fileName starts with a location code. See
Section 19.6, “BaseCompiler.checkForLocation()”, which
returns None if the file name doesn't
start with a location code; it returns the remaining file
name if it does start with a location code. See Section 19.6, “BaseCompiler.checkForLocation()”.
#-- 1 --
# [ if (self.fileName starts with LOCATION_PAT) and
# (the matching part is a location code defined in
# self.stationSet) ->
# self.location := the Location from self.stationSet
# with that location code
# return self.fileName past the matching part
# else if (self.fileName starts with LOCATION_PAT) and
# (the matching part is not a location code defined in
# self.stationSet) ->
# Log() +:= error message(s)
# raise ValueError
# else -> I ]
rest = self.checkForLocation()
if rest is not None:
return rest
At this point we're sure that the file name does not look
like it starts with a location code, so it had better
start with a station number. See Section 19.7, “BaseCompiler.checkForStation()”.
#-- 2 -
# [ if (self.fileName starts with STA_NO_PAT) and
# (the matching part is a station number defined in
# self.stationSet) ->
# self.station := the Station from self.stationSet
# with that station number
# rest := self.fileName past the matching part
# else ->
# Log() +:= error message(s)
# raise ValueError ]
rest = self.checkForStation()
#-- 3 --
return rest