"""
A quick script to clean up & standardize text fields in a geodatabase
feature class. Intended to be used as an ArcCatalog Script Tool: to implement
create toolbox with script tool taking single Feature Class as input.
"""

import arcpy

fc = arcpy.GetParameterAsText(0)
rows = arcpy.UpdateCursor(fc)
fields = arcpy.ListFields(fc)

arcpy.AddWarning(('############################################\n
                   Converting text fields to all-caps, eliminating extra/trailing spaces\n'))
for row in rows:
    for field in fields:
        # check all text fields that don't contain NULL (NoneType) values
        if field.type == 'String' and row.getValue(field.name):
            val = ((row.getValue(field.name)).strip()).upper()
            if val in ["NONE","NULL"]: # yes really
                row.setValue(None, val)
            else:
                row.setValue(field.name, val)
    rows.updateRow(row)
arcpy.AddWarning('Attribute check complete.
                  \n############################################')
