AnsweredAssumed Answered

Unzip with python - Using ToolValidator

Question asked by krank42 on Sep 24, 2012
Latest reply on Sep 24, 2012 by krank42

I want to unzip a file to a directory, and show all the files from the zipped-file in the tool-parameters on self.params[2]. I think this should work with the ToolValidator.

So I write in the Validator the following script.
 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."""     if self.params[0].value:       list = []       zip = zipfile.ZipFile(self.params[0].value, "r")       for zfile in zip.namelist():         list.append(       self.params[2].filter.list = list

My problem now is that I get the following error:

updateParameters Execution Error: Runtime error : global name 'zipfile' is not defined

I have already imported zipfile in def __init__(self)

Can someone help me?

Thanks a lot for your help!!