I have an ArcGIS Pro document with a number of layers in and have created three scripts to; copy the layers to a new FGDB, create a datasource lookup table where the user can then enter a new target name if the copied feature class was renamed, and update the data sources using the csv lookup table.
Everything works great apart from feature classes found in feature datasets, which aren't repathed. I'm using the dictionary approach and layer.updateConnectionProperties(). Should the feature dataset name be part of the workspace ('database:') or possibly in with the feature class name ('dataset:')?
e.g. r"C:\GIS\Test.gdb\Fields\Oil"
Should the find dictionary database be r"C:\GIS\Test.gdb\Fields" and the dataset "Oil" or..
the find dictionary database be r"C:\GIS\Test.gdb" and the dataset "Fields\Oil" ?
# if the layer datasource matches the datasource in the LU table (row[6])
# row[4] is the source workspace path (FGDB)
# row[5] is the feature class name
# row[7] is the target workspace path (FGDB)
# row[8] is the target feature class name
if layer.dataSource == row[6]:
find_dict = {'connection_info': {'database': row[4]},
'dataset': row[5],
'workspace_factory': 'File Geodatabase'}
replace_dict = {'connection_info': {'database': row[7]},
'dataset': row[8],
'workspace_factory': 'File Geodatabase'}
layer.updateConnectionProperties(find_dict, replace_dict)