<s> import os <EOL> import arcpy <EOL> import traceback <EOL> import sys <EOL> inputTDSFeatureDataset = arcpy . GetParameterAsText ( <NUM_LIT:0> ) <EOL> inputMAOTWorkspace = arcpy . GetParameterAsText ( <NUM_LIT:1> ) <EOL> FEATURECLASSES_TO_MERGE = [ "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] <EOL> DEBUG = True <EOL> def GetQualifierName ( inputFD ) : <EOL> '''<STR_LIT>''' <EOL> qfList = os . path . basename ( inputFD ) . split ( "<STR_LIT:.>" ) <EOL> arcpy . AddMessage ( "<STR_LIT>" + str ( qfList ) ) <EOL> if len ( qfList ) != <NUM_LIT:1> : <EOL> qualifierString = str ( qfList [ <NUM_LIT:0> ] + "<STR_LIT:.>" + qfList [ <NUM_LIT:1> ] + "<STR_LIT:.>" ) <EOL> else : <EOL> qualifierString = "<STR_LIT>" <EOL> arcpy . AddMessage ( "<STR_LIT>" + str ( qualifierString ) ) <EOL> return qualifierString <EOL> def FeatureClassesFromWorkspace ( inputTDSFeatureDataset ) : <EOL> '''<STR_LIT>''' <EOL> arcpy . env . workspace = os . path . dirname ( inputTDSFeatureDataset ) <EOL> tdsFeatureClasses = arcpy . ListFeatureClasses ( "<STR_LIT:*>" , "<STR_LIT>" , <EOL> os . path . basename ( inputTDSFeatureDataset ) ) <EOL> return tdsFeatureClasses <EOL> def main ( ) : <EOL> '''<STR_LIT>''' <EOL> try : <EOL> arcpy . AddMessage ( "<STR_LIT>" ) <EOL> qualifierString = GetQualifierName ( inputTDSFeatureDataset ) <EOL> if DEBUG is True : arcpy . AddMessage ( "<STR_LIT>" + qualifierString ) <EOL> fqClassesToMerge = [ str ( qualifierString + i ) for i in FEATURECLASSES_TO_MERGE ] <EOL> if DEBUG is True : arcpy . AddMessage ( "<STR_LIT>" + str ( fqClassesToMerge ) ) <EOL> workspace = os . path . dirname ( inputTDSFeatureDataset ) <EOL> tdsFeatureClasses = FeatureClassesFromWorkspace ( inputTDSFeatureDataset ) <EOL> if DEBUG is True : arcpy . AddMessage ( "<STR_LIT>" + str ( tdsFeatureClasses ) ) <EOL> arcpy . AddMessage ( "<STR_LIT>" ) <EOL> newList = [ str ( os . path . join ( workspace , os . path . basename ( inputTDSFeatureDataset ) , fc ) ) for fc in tdsFeatureClasses if fc in fqClassesToMerge ] <EOL> if DEBUG is True : arcpy . AddMessage ( "<STR_LIT>" + str ( newList ) ) <EOL> target = os . path . join ( inputMAOTWorkspace , "<STR_LIT>" ) <EOL> if DEBUG is True : arcpy . AddMessage ( "<STR_LIT>" + str ( target ) ) <EOL> arcpy . AddMessage ( "<STR_LIT>" ) <EOL> arcpy . Merge_management ( newList , target ) <EOL> arcpy . AddMessage ( "<STR_LIT>" ) <EOL> arcpy . SetParameter ( <NUM_LIT:2> , target ) <EOL> except arcpy . ExecuteError : <EOL> msgs = arcpy . GetMessages ( ) <EOL> arcpy . AddError ( msgs ) <EOL> print ( msgs ) <EOL> except : <EOL> tb = sys . exc_info ( ) [ <NUM_LIT:2> ] <EOL> tbinfo = traceback . format_tb ( tb ) [ <NUM_LIT:0> ] <EOL> pymsg = "<STR_LIT>" + tbinfo + "<STR_LIT>" + str ( sys . exc_info ( ) [ <NUM_LIT:1> ] ) <EOL> msgs = "<STR_LIT>" + arcpy . GetMessages ( ) + "<STR_LIT:\n>" <EOL> arcpy . AddError ( pymsg ) <EOL> arcpy . AddError ( msgs ) <EOL> print ( pymsg + "<STR_LIT:\n>" ) <EOL> print ( msgs ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> main ( ) </s>
