'Add a directory recursively to the zip file with an optional prefix.'

def add_dir(self, path, prefix='', simple_filter=(lambda x: False)):

    if prefix:
        self.writestr((prefix + '/'), '', 493)
    cwd = os.path.abspath(os.getcwdu())
    try:
        os.chdir(path)
        fp = (prefix + ('/' if prefix else '')).replace('//', '/')
        for f in os.listdir('.'):
            if simple_filter(f):
                continue
            arcname = (fp + f)
            if os.path.isdir(f):
                self.add_dir(f, prefix=arcname, simple_filter=simple_filter)
            else:
                self.write(f, arcname)
    finally:
        os.chdir(cwd)
