Skip to content

Commit

Permalink
fix speedtest
Browse files Browse the repository at this point in the history
  • Loading branch information
stdavis committed Jun 13, 2017
1 parent 9645f22 commit 63ab7ce
Show file tree
Hide file tree
Showing 19 changed files with 12 additions and 24 deletions.
Binary file modified speedtest/data/SourceData.gdb/a00000005.CatItemTypesByName.atx
Binary file not shown.
Binary file not shown.
Binary file modified speedtest/data/SourceData.gdb/a00000005.CatItemTypesByUUID.atx
Binary file not shown.
Binary file modified speedtest/data/SourceData.gdb/a00000005.gdbtable
Binary file not shown.
Binary file modified speedtest/data/SourceData.gdb/a00000005.gdbtablx
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified speedtest/data/SourceData.gdb/a00000007.CatRelTypesByName.atx
Binary file not shown.
Binary file not shown.
Binary file modified speedtest/data/SourceData.gdb/a00000007.CatRelTypesByUUID.atx
Binary file not shown.
Binary file modified speedtest/data/SourceData.gdb/a00000007.gdbtable
Binary file not shown.
Binary file modified speedtest/data/SourceData.gdb/a00000007.gdbtablx
Binary file not shown.
Binary file modified speedtest/data/SourceData.gdb/timestamps
Binary file not shown.
36 changes: 12 additions & 24 deletions src/forklift/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,41 +292,29 @@ def _format_dictionary(pallet_reports):
def _change_data(data_path):
import arcpy

field_changers = {'UTAddPtID': lambda value: value[:-1] + 'X' if value else 'X'}
def field_changer(value):
return value[:-1] + 'X' if value else 'X'

change_field = 'FieldToChange'
fields = list(field_changers.keys()) + [change_field]
value_field = 'UTAddPtID'

with arcpy.da.UpdateCursor(data_path, fields) as cursor:
with arcpy.da.UpdateCursor(data_path, [value_field, change_field]) as cursor:
for row in cursor:
field_to_change = row[fields.index(change_field)]
if field_to_change in field_changers:
field_index = fields.index(field_to_change)
value = row[field_index]
row[field_index] = field_changers[field_to_change](value)
cursor.updateRow(row)
else:
if field_to_change == 'DeleteRow':
cursor.deleteRow()
elif field_to_change == 'UnchangedRow' or field_to_change is None:
continue
else:
print('Unknown field to change: {}'.format(field_to_change))
row[1] = field_changer(row[0])
cursor.updateRow(row)


def _prep_change_data(data_path):
import arcpy
change_field = 'FieldToChange'
value_field = 'UTAddPtID'
layer_name = 'CalcLayer'

arcpy.AddField_management(data_path, change_field, 'TEXT', field_length=50)
arcpy.AddField_management(data_path, change_field, 'TEXT', field_length=150)
where = 'OBJECTID >= 879389 and OBJECTID <= 899388'
layer = arcpy.MakeFeatureLayer_management(data_path, layer_name, where)
arcpy.CalculateField_management(layer_name,
change_field,
"'{}'".format(value_field),
'PYTHON')
arcpy.Delete_management(layer)
with arcpy.da.UpdateCursor(data_path, [value_field, change_field], where) as update_cursor:
for row in update_cursor:
row[1] = row[0]
update_cursor.updateRow(row)


def speedtest(pallet_location):
Expand Down
Binary file modified tests/data/CopyData.gdb/a00000004.freelist
Binary file not shown.
Binary file modified tests/data/CopyData.gdb/a00000004.gdbtable
Binary file not shown.
Binary file modified tests/data/CopyData.gdb/a00000004.gdbtablx
Binary file not shown.
Binary file modified tests/data/CopyData.gdb/timestamps
Binary file not shown.

0 comments on commit 63ab7ce

Please sign in to comment.