I have a script was working fine in ArcGIS Pro 2.3.3. I am looping through all the layers in a map looking for a specific layer. I am matching on the data source (specifically os.path.basename(lyr.dataSource)). I don't want to look for what the layer is called in the map as this needs to run for multiple people in different projects and people may rename the layer to anything.
The code below is what I have. This line:
if os.path.basename(lyr.dataSource) == planSummaryLayer
is now returning:
Server=brcsvgissql01,Instance=test,Database Platform=SQL Server,Version=dbo.DEFAULT,Authentication Type=Operating System Authentication,Dataset=test.DBO.EP_PlanSummary_v8
rather than just:
as it was with ArcGIS Pro 2.3.3
How do I now just get the basename of the data source from the layer in a map?
I'm not too great with python so please let me know if you need any more information.
Thanks for your help.
import sys, string, os, arcpy
aprx = arcpy.mp.ArcGISProject('CURRENT')
activeMap = aprx.activeMap
planSummaryLayer = 'test.DBO.EP_PlanSummary_v8'
layers = activeMap.listLayers()
for lyr in layers:
if lyr.isBasemapLayer == False and lyr.isGroupLayer == False:
if os.path.basename(lyr.dataSource) == planSummaryLayer:
desc = arcpy.Describe(lyr)