Create GSSHAPY Mapping Table ORM Objects Method

def _createGsshaPyObjects(self, mapTables, indexMaps, replaceParamFile, directory, session, spatial, spatialReferenceID):
        """
        Create GSSHAPY Mapping Table ORM Objects Method
        """
        for mt in mapTables:
            # Create GSSHAPY MapTable object
            try:
                # Make sure the index map name listed with the map table is in the list of
                # index maps read from the top of the mapping table file (Note that the index maps for the sediment
                # and contaminant tables will have names of None, so we skip these cases.
                if mt['indexMapName'] is not None:
                    indexMaps[mt['indexMapName']]

                mapTable = MapTable(name=mt['name'],
                                    numIDs=mt['numVars']['NUM_IDS'],
                                    maxNumCells=mt['numVars']['MAX_NUMBER_CELLS'],
                                    numSed=mt['numVars'].get('NUM_SED'),
                                    numContam=mt['numVars'].get('NUM_CONTAM'),
                                    maxSoilID=mt['numVars'].get('MAX_SOIL_ID'))

                # Associate MapTable with this MapTableFile and IndexMaps
                mapTable.mapTableFile = self

                ## NOTE: Index maps are associated wth contaminants for CONTAMINANT_TRANSPORT map
                ## tables. The SEDIMENTS map table are associated with index maps via the
                ## SOIL_EROSION_PROPS map table.
                if mt['indexMapName']:
                    mapTable.indexMap = indexMaps[mt['indexMapName']]


                # CONTAMINANT_TRANSPORT map table handler
                if mt['name'] == 'CONTAMINANT_TRANSPORT':
                    for contam in mt['contaminants']:
                        # Preprocess the contaminant output paths to be relative
                        outputBaseFilename = self._preprocessContaminantOutFilePath(contam['outPath'])

                        # Initialize GSSHAPY MTContaminant object
                        contaminant = MTContaminant(name=contam['name'],
                                                    outputFilename=outputBaseFilename,
                                                    precipConc=vrp(contam['contamVars']['PRECIP_CONC'], replaceParamFile),
                                                    partition=vrp(contam['contamVars']['PARTITION'], replaceParamFile),
                                                    numIDs=contam['contamVars']['NUM_IDS'])

                        # Associate MTContaminant with appropriate IndexMap
                        indexMap = indexMaps[contam['indexMapName']]
                        contaminant.indexMap = indexMap

                        self._createValueObjects(contam['valueList'], contam['varList'], mapTable, indexMap,
                                                 contaminant, replaceParamFile)

                        # Read any output files if they are present
                        self._readContaminantOutputFiles(directory, outputBaseFilename, session, spatial, spatialReferenceID)

                # SEDIMENTS map table handler
                elif mt['name'] == 'SEDIMENTS':
                    for line in mt['valueList']:
                        # Create GSSHAPY MTSediment object
                        sediment = MTSediment(description=line[0],
                                              specificGravity=vrp(line[1], replaceParamFile),
                                              particleDiameter=vrp(line[2], replaceParamFile),
                                              outputFilename=line[3])

                        # Associate the MTSediment with the MapTable
                        sediment.mapTable = mapTable

                # All other map table handler
                else:
                    indexMap = indexMaps[mt['indexMapName']]

                    # Create MTValue and MTIndex objects
                    self._createValueObjects(mt['valueList'], mt['varList'], mapTable, indexMap, None, replaceParamFile)

            except KeyError:
                log.info(('Index Map "%s" for Mapping Table "%s" not found in list of index maps in the mapping '
                          'table file. The Mapping Table was not read into the database.') % (
                          mt['indexMapName'], mt['name']))