import os, fnmatch # function to find files with wildcard def find(pattern, path): theFiles = [] for path, dirs, files in os.walk(path): for filename in files: if fnmatch.fnmatch(filename, pattern): theFiles.append(os.path.abspath(os.path.join(path, filename))) return sorted(theFiles) class ToolValidator: """Class for validating a tool's parameter values and controlling the behavior of the tool's dialog.""" def __init__(self): """Setup arcpy and the list of tool parameters.""" import arcpy self.params = arcpy.GetParameterInfo() def initializeParameters(self): """Refine the properties of a tool's parameters. This method is called when the tool is opened.""" return def updateParameters(self): """Modify the values and properties of parameters before internal validation is performed. This method is called whenever a parmater has been changed.""" # Path to SQL Databases sde_loc = r'\\arcserver1\SDE' sde_db = find('*.mdf', sde_loc) # drop down lists self.params[0].filter.list = [os.path.basename(s).split('.')[0] for s in sde_db] self.params[2].filter.list = ['DBO.DEFAULT', 'DBO.EDITOR'] return def updateMessages(self): """Modify the messages created by internal validation for each tool parameter. This method is called after internal validation.""" return
Signed in members can post, follow updates, and more. New here? Register a free account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.