ListBrokenDataSources and TableViews

229
3
04-30-2020 06:53 AM
ChrisHolmes
Occasional Contributor III

Hello everyone,

ListBrokenDataSources returns a python list. What's the best way to determine if the item you are dealing with in the list is a TableView?

I'm using .supports('workspacePath') and .supports('dataSource') to deal with shapefiles and geodatabase feature classes.

I'm getting this error message when a TableView is found in the list:

AttributeError: 'TableView' object has no attribute 'supports'

How should I go about getting at the TableView properties to determine that it's a TableView?

Thanks!

Tags (2)
0 Kudos
3 Replies
ChrisHolmes
Occasional Contributor III

Here's what I came up with to identify if I'm dealing with a TableView:

brknItemType = str(type(brknItem))
splitType = brknItemType.split('.')[-1]
itemType = splitType[:-2]
ProcessMessage('itemType = {}'.format(itemType),systemUsed,'N')

This gives me:

There's probably a prettier way to do it, but this should work for my needs.

RandyBurton
MVP Regular Contributor

I think you have the solution.  For a "prettier way", perhaps:

if 'TableView' in str(type(brknItem)):
    # do something‍‍‍‍
JoshuaBixby
MVP Esteemed Contributor

The "is" method is more canonical for checking object identity:

type(brknItem) is arcpy.mapping.TableView

One can also use isinstance():

isinstance(brknItem, arcpy.mapping.TableView)