Next / Previous / Contents / Shipman's homepage

74.3. BaseEncounter.__init__(): Constructor

In this constructor, only a few fields are filled in. The others will be added later depending on the content of the raw encounter record; see Section 74.1, “Design notes for the BaseEncounter class”.

baseclasses.py
# - - -   B a s e E n c o u n t e r . _ _ i n i t _ _   - - -

    def __init__(self, compiler):
        '''Constructor for BaseEncounter.
        '''

First we store the single argument.

baseclasses.py
        #-- 1 --
        self.compiler = compiler

Next we set up the .location or station attributes. If the compiler is working on a multi-station location, we can copy the .location value from the compiler, and the .station will be filled in later from the input record. If it is a single-station set, we also copy the .station value from the compiler.

baseclasses.py
        #-- 2 --
        # [ if compiler.station is None ->
        #     self.location  :=  compiler.location
        #   else ->
        #     self.location  :=  compiler.station.loc
        #     self.station   :=  compiler.station ]

Warning

In previous years, we had to enter sets whose station and/or location were not in the stations authority file. The current design assumes that never happens. If we have to handle this case, one way would be to replace the current .location and .station fields with fields named .locCode and .staNo, and handle only the codes used in the data. The user will still get an error message about the undefined code.

The only other required attribute is .captureCode; that will be filled in during processing of the input record.