for lyr in updateMap.listLayers():
A script opens an ArcGIS Pro project file, goes through the list of layers within a map, checks to see if each layer supports the 'DataSource' property before giving me a message with that datasource
The script fails as it reaches a layer which doesn't support the 'DataSource' property....
Can someone explain this non-sensical behaviour to me?
ArcGIS Pro 2.8.2
I have no idea why this happens, but to not let it fail your script, you can do it in a try-catch block:
for lyr in updateMap.listLayers(): try: arcpy.AddMessage(lyr.dataSource) except NameError: pass
could it be your layer source?
Returns the complete path for the layer's data source. It includes the full workspace path and name of the dataset. For enterprise geodatabase layers, a string containing the layer's connection information is returned.
Enterprise geodatabase layers in an ArcGIS Pro project do not retain the path to the database connection file (.sde) that was used to create the layer.
Possible (and I'll check) but not likely as all the layers that I check (using a query on the list layers) are in the same location (default.gdb)...but even then, the whole point of 'supports' is that this type of error doesn't occur.