Scripts/CreateGems.pyt
def execute(self, parameters, messages):
        """The source code of the tool."""
        #First, get list of problem fields from source gdb for use later
        pFs = collectProblemFields(parameters[0].valueAsText, messages)
        for field in pFs:
            messages.addMessage("feature class = " + field['featureClass'] + ", field = " + field['field'])

        '''
        #Temp? Create enterprise gdb
        arcpy.CreateEnterpriseGeodatabase_management(
            "POSTGRESQL",
            "127.0.0.1",
            "gems03",
            "DATABASE_AUTH",
            "postgres",
            "password", 
            "",
            "sde",
            "password",
            "", 
            "C:\keycodes.ecp")
        '''
        '''
        #Next, create xml from source gdb
        messages.addMessage("creating tmp xml file");
        arcpy.ExportXMLWorkspaceDocument_management(
            parameters[0].valueAsText,
            path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"),
            "SCHEMA_ONLY"
        )
        
        #Next, import xml to target gdb
        messages.addMessage("importing tmp xml file");
        messages.addMessage("target = " + parameters[1].valueAsText);
        arcpy.ImportXMLWorkspaceDocument_management(
            parameters[1].valueAsText, 
            path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"), 
            "SCHEMA_ONLY"
        )

        #Next, remove the xml file
        messages.addMessage("deleting tmp xml file");
        os.remove(path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"))
        '''
        #Finally, fix all problem fields in target gdb
        messages.addMessage("fixing fields");
        for field in pFs:
            messages.addMessage(
                "Altering type for feature class = " +
                path.join(parameters[1].valueAsText, path.basename(field['featureClass'])) +
                ", field = " + field['field']
            )
            arcpy.AlterField_management(
                path.join(parameters[1].valueAsText, path.basename(field['featureClass'])),
                field['field'],
                field_type="Float"
            ) 
       
        #messages.addMessage("path dirname = " + path.dirname(parameters[0].valueAsText))
        #messages.addMessage("path basename= " + path.basename(parameters[0].valueAsText))
        return
The source code of the tool.
The source code of the tool.
The source code of the tool .
def execute(self, parameters, messages):
        pFs = collectProblemFields(parameters[0].valueAsText, messages)
        for field in pFs:
            messages.addMessage("feature class = " + field['featureClass'] + ", field = " + field['field'])
        messages.addMessage("fixing fields");
        for field in pFs:
            messages.addMessage(
                "Altering type for feature class = " +
                path.join(parameters[1].valueAsText, path.basename(field['featureClass'])) +
                ", field = " + field['field']
            )
            arcpy.AlterField_management(
                path.join(parameters[1].valueAsText, path.basename(field['featureClass'])),
                field['field'],
                field_type="Float"
            ) 
        return
def execute ( self , parameters , messages ) : pFs = collectProblemFields ( parameters [ 0 ] . valueAsText , messages ) for field in pFs : messages . addMessage ( "feature class = " + field [ 'featureClass' ] + ", field = " + field [ 'field' ] ) '''
        #Temp? Create enterprise gdb
        arcpy.CreateEnterpriseGeodatabase_management(
            "POSTGRESQL",
            "127.0.0.1",
            "gems03",
            "DATABASE_AUTH",
            "postgres",
            "password", 
            "",
            "sde",
            "password",
            "", 
            "C:\keycodes.ecp")
        ''' '''
        #Next, create xml from source gdb
        messages.addMessage("creating tmp xml file");
        arcpy.ExportXMLWorkspaceDocument_management(
            parameters[0].valueAsText,
            path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"),
            "SCHEMA_ONLY"
        )
        
        #Next, import xml to target gdb
        messages.addMessage("importing tmp xml file");
        messages.addMessage("target = " + parameters[1].valueAsText);
        arcpy.ImportXMLWorkspaceDocument_management(
            parameters[1].valueAsText, 
            path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"), 
            "SCHEMA_ONLY"
        )

        #Next, remove the xml file
        messages.addMessage("deleting tmp xml file");
        os.remove(path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"))
        ''' messages . addMessage ( "fixing fields" ) ; for field in pFs : messages . addMessage ( "Altering type for feature class = " + path . join ( parameters [ 1 ] . valueAsText , path . basename ( field [ 'featureClass' ] ) ) + ", field = " + field [ 'field' ] ) arcpy . AlterField_management ( path . join ( parameters [ 1 ] . valueAsText , path . basename ( field [ 'featureClass' ] ) ) , field [ 'field' ] , field_type = "Float" ) return
The source code of the tool.
The source code of the tool .
"""The source code of the tool.""" #First, get list of problem fields from source gdb for use later '''
        #Temp? Create enterprise gdb
        arcpy.CreateEnterpriseGeodatabase_management(
            "POSTGRESQL",
            "127.0.0.1",
            "gems03",
            "DATABASE_AUTH",
            "postgres",
            "password", 
            "",
            "sde",
            "password",
            "", 
            "C:\keycodes.ecp")
        ''' '''
        #Next, create xml from source gdb
        messages.addMessage("creating tmp xml file");
        arcpy.ExportXMLWorkspaceDocument_management(
            parameters[0].valueAsText,
            path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"),
            "SCHEMA_ONLY"
        )
        
        #Next, import xml to target gdb
        messages.addMessage("importing tmp xml file");
        messages.addMessage("target = " + parameters[1].valueAsText);
        arcpy.ImportXMLWorkspaceDocument_management(
            parameters[1].valueAsText, 
            path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"), 
            "SCHEMA_ONLY"
        )

        #Next, remove the xml file
        messages.addMessage("deleting tmp xml file");
        os.remove(path.join(path.dirname(parameters[0].valueAsText), "tmp.xml"))
        ''' #Finally, fix all problem fields in target gdb #messages.addMessage("path dirname = " + path.dirname(parameters[0].valueAsText)) #messages.addMessage("path basename= " + path.basename(parameters[0].valueAsText))
self
parameters
messages