Skip to content

Commit

Permalink
new error messages in Fix Strings tool
Browse files Browse the repository at this point in the history
  • Loading branch information
ethoms-usgs committed Sep 9, 2021
1 parent 45b89a7 commit dfeb5a8
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions Scripts/GeMS_FixStrings_Arc10.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import arcpy, os, os.path, sys
from GeMS_utilityFunctions import *

versionString = 'GeMS_FixStrings_Arc10.py, version of 30 July 2020'
versionString = 'GeMS_FixStrings_Arc10.py, version of 9 September 2021'
rawurl = 'https://raw.githubusercontent.com/usgs/gems-tools-arcmap/master/Scripts/GeMS_FixStrings_Arc10.py'
checkVersion(versionString, rawurl, 'gems-tools-arcmap')

Expand All @@ -20,7 +20,7 @@ def fixTableStrings(fc):
trash = ''
updateRowFlag = False
row1 = [row[0]]
for f in row[1:]:
for f in row[1:]:
updateFieldFlag = False
f0 = f
if f <> None:
Expand All @@ -32,14 +32,12 @@ def fixTableStrings(fc):
updateFieldFlag = True
if updateFieldFlag:
updateRowFlag = True
addMsgAndPrint( ' '+str(row[0])+' **'+ str(f0)+'**')
row1.append(f)
if updateRowFlag:
try:
cursor.updateRow(row1)
except:
addMsgAndPrint('failed to update row '+str(row[0])+'. Perhaps a field is not nullable')
del cursor, row
except Exception as error:
addMsgAndPrint(' Row {}. {}'.format(str(row[0]), error))

#########################

Expand All @@ -50,7 +48,7 @@ def fixTableStrings(fc):

tables = arcpy.ListTables()
for tb in tables:
addMsgAndPrint(' ')
addMsgAndPrint(".........")
addMsgAndPrint(os.path.basename(tb))
fixTableStrings(tb)

Expand All @@ -59,11 +57,9 @@ def fixTableStrings(fc):
for ds in datasets:
for fc in arcpy.ListFeatureClasses(feature_dataset=ds):
path = os.path.join(arcpy.env.workspace, ds, fc)
addMsgAndPrint(' ')
addMsgAndPrint(os.path.basename(fc))
try:
fixTableStrings(path)
except:
addMsgAndPrint(' failed to fix strings')
except Exception as error:
addMsgAndPrint(error)

addMsgAndPrint('DONE')

0 comments on commit dfeb5a8

Please sign in to comment.