def ensureAllColumns(layerObj, theType=''): if theType == '': return if layerObj is None: return if 'STATIO' in theType.upper(): ensureTableLayerHasFields(layerObj, Station.getRequiredFieldsTuples()) elif 'GAGE' in theType.upper(): ensureTableLayerHasFields(layerObj, Gage.getRequiredFieldsTuples())
def initializeTables(mxd): lyrDict = getLayersDict(mxd) lyrStations = lyrDict[lyrStationsName] workingGdb = os.path.dirname(lyrStations.dataSource) try: fieldNamesRequired = Station.getRequiredFieldsTuples() ensureTableLayerHasFields(lyrStations, fieldNamesRequired) except: pass try: fullPath = os.path.join(workingGdb, tblGages) ensureTableLayerHasFields(fullPath, Gage.getRequiredFieldsTuples()) except: pass print 'tables initialized'