66import arcpy , os , os .path , sys
77from GeMS_utilityFunctions import *
88
9- versionString = 'GeMS_FixStrings_Arc10.py, version of 30 July 2020 '
9+ versionString = 'GeMS_FixStrings_Arc10.py, version of 9 September 2021 '
1010rawurl = 'https://raw.githubusercontent.com/usgs/gems-tools-arcmap/master/Scripts/GeMS_FixStrings_Arc10.py'
1111checkVersion (versionString , rawurl , 'gems-tools-arcmap' )
1212
@@ -20,7 +20,7 @@ def fixTableStrings(fc):
2020 trash = ''
2121 updateRowFlag = False
2222 row1 = [row [0 ]]
23- for f in row [1 :]:
23+ for f in row [1 :]:
2424 updateFieldFlag = False
2525 f0 = f
2626 if f <> None :
@@ -32,14 +32,12 @@ def fixTableStrings(fc):
3232 updateFieldFlag = True
3333 if updateFieldFlag :
3434 updateRowFlag = True
35- addMsgAndPrint ( ' ' + str (row [0 ])+ ' **' + str (f0 )+ '**' )
3635 row1 .append (f )
3736 if updateRowFlag :
3837 try :
3938 cursor .updateRow (row1 )
40- except :
41- addMsgAndPrint ('failed to update row ' + str (row [0 ])+ '. Perhaps a field is not nullable' )
42- del cursor , row
39+ except Exception as error :
40+ addMsgAndPrint (' Row {}. {}' .format (str (row [0 ]), error ))
4341
4442#########################
4543
@@ -50,7 +48,7 @@ def fixTableStrings(fc):
5048
5149tables = arcpy .ListTables ()
5250for tb in tables :
53- addMsgAndPrint (' ' )
51+ addMsgAndPrint ("........." )
5452 addMsgAndPrint (os .path .basename (tb ))
5553 fixTableStrings (tb )
5654
@@ -59,11 +57,9 @@ def fixTableStrings(fc):
5957for ds in datasets :
6058 for fc in arcpy .ListFeatureClasses (feature_dataset = ds ):
6159 path = os .path .join (arcpy .env .workspace , ds , fc )
62- addMsgAndPrint (' ' )
63- addMsgAndPrint (os .path .basename (fc ))
6460 try :
6561 fixTableStrings (path )
66- except :
67- addMsgAndPrint (' failed to fix strings' )
62+ except Exception as error :
63+ addMsgAndPrint (error )
6864
6965addMsgAndPrint ('DONE' )
0 commit comments