def walk_zip(self, filename, fileobj=None):
        """Identify the type of each item in the zip 
           @param fileobj.  If fileobj is not provided, open 
           @param filename.
           Call self.handle_matches instead of returning a value.
        """
        # IN 2.7+: with zipfile.ZipFile((fileobj if fileobj != None else filename), 'r') as stream:
        import zipfile, tempfile
        try:
            zipstream = None
            zipstream = zipfile.ZipFile((fileobj if fileobj != None else filename), 'r')    
            for item in zipstream.infolist():
                if item.file_size == 0:
                    continue           #TODO: Find a better test for isdir
                t0 = time.clock()
                # with zipstream.open(item) as f:
                f = None
                try:
                    f = zipstream.open(item)
                    item_name = filename + '!' + item.filename
                    self.current_file = item_name
                    self.current_filesize = item.file_size
                    if self.current_filesize == 0:
                        sys.stderr.write("FIDO: Zero byte file (empty): Path is: {0}\n".format(item_name))
                    bofbuffer, eofbuffer = self.get_buffers(f, item.file_size)
                finally:
                    if f != None: f.close()
                matches = self.match_formats(bofbuffer, eofbuffer)
                if len(matches) > 0 and self.current_filesize > 0:
                    self.handle_matches(item_name, matches, time.clock() - t0, "signature")
                elif len(matches) == 0 or self.current_filesize == 0:
                    matches = self.match_extensions(item_name)
                    self.handle_matches(item_name, matches, time.clock() - t0, "extension")
                if self.container_type(matches):
                        target = tempfile.SpooledTemporaryFile(prefix='Fido')
                        #with zipstream.open(item) as source:
                        try:
                            source = zipstream.open(item)
                            self.copy_stream(source, target)
                            #target.seek(0)
                            self.identify_contents(item_name, target, self.container_type(matches))
                        finally:
                            source.close()
        except __HOLE__:
            sys.stderr.write("FIDO: ZipError {0}\n".format(filename))
        except zipfile.BadZipfile:
            sys.stderr.write("FIDO: ZipError {0}\n".format(filename))
            
        finally:
            if zipstream != None: zipstream.close()
dataset/ETHPy150Open openpreserve/fido/fido/fido.py/Fido.walk_zip