Last active
July 11, 2020 05:33
-
-
Save steveoh/e4dd3b0ce0a7d67174592ec3f604fdf7 to your computer and use it in GitHub Desktop.
list usused domains and fields with domain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
import arcpy | |
arcpy.env.workspace = r'stage.sde' | |
output = {} | |
tables = [] | |
for dirpath, dirnames, walked_tables in arcpy.da.Walk(datatype=['FeatureClass', 'Table']): | |
#: filter for tables owned by the user | |
tables += walked_tables | |
domain_names = set([x.name for x in arcpy.da.ListDomains()]) | |
used_domains = set([]) | |
for table in tables: | |
print('inspecting ' + table) | |
domains = {} | |
for field in arcpy.ListFields(table): | |
print(' inspecting ' + field.name) | |
if field.domain: | |
print(' field has domain ' + field.domain) | |
domains[field.name] = field.domain | |
used_domains.add(field.domain) | |
if len(domains.keys()) > 0: | |
output[table] = domains | |
print('unused domains') | |
pprint(domain_names - used_domains) | |
print('fields with domains') | |
pprint(output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment