(base_name, base_dir, verbose=0, dry_run=0, logger=None)
return zip_filename
Create a zip file from all the files under 'base_dir'.

    The output zip file will be named 'base_name' + ".zip".  Returns the
    name of the output zip file.
Create a zip file from all the files under 'base_dir'.
Create a zip file from all the files under base_dir .
def _make_zipfile(base_name, base_dir, verbose=0, dry_run=0, logger=None):
    """Create a zip file from all the files under 'base_dir'.

    The output zip file will be named 'base_name' + ".zip".  Returns the
    name of the output zip file.
    """
    import zipfile  # late import for breaking circular dependency

    zip_filename = base_name + ".zip"
    archive_dir = os.path.dirname(base_name)

    if archive_dir and not os.path.exists(archive_dir):
        if logger is not None:
            logger.info("creating %s", archive_dir)
        if not dry_run:
            os.makedirs(archive_dir)

    if logger is not None:
        logger.info("creating '%s' and adding '%s' to it",
                    zip_filename, base_dir)

    if not dry_run:
        with zipfile.ZipFile(zip_filename, "w",
                             compression=zipfile.ZIP_DEFLATED) as zf:
            path = os.path.normpath(base_dir)
            if path != os.curdir:
                zf.write(path, path)
                if logger is not None:
                    logger.info("adding '%s'", path)
            for dirpath, dirnames, filenames in os.walk(base_dir):
                for name in sorted(dirnames):
                    path = os.path.normpath(os.path.join(dirpath, name))
                    zf.write(path, path)
                    if logger is not None:
                        logger.info("adding '%s'", path)
                for name in filenames:
                    path = os.path.normpath(os.path.join(dirpath, name))
                    if os.path.isfile(path):
                        zf.write(path, path)
                        if logger is not None:
                            logger.info("adding '%s'", path)

    return zip_filename
def _make_zipfile ( base_name , base_dir , verbose = 0 , dry_run = 0 , logger = None ) : import zipfile # late import for breaking circular dependency zip_filename = base_name + ".zip" archive_dir = os . path . dirname ( base_name ) if archive_dir and not os . path . exists ( archive_dir ) : if logger is not None : logger . info ( "creating %s" , archive_dir ) if not dry_run : os . makedirs ( archive_dir ) if logger is not None : logger . info ( "creating '%s' and adding '%s' to it" , zip_filename , base_dir ) if not dry_run : with zipfile . ZipFile ( zip_filename , "w" , compression = zipfile . ZIP_DEFLATED ) as zf : path = os . path . normpath ( base_dir ) if path != os . curdir : zf . write ( path , path ) if logger is not None : logger . info ( "adding '%s'" , path ) for dirpath , dirnames , filenames in os . walk ( base_dir ) : for name in sorted ( dirnames ) : path = os . path . normpath ( os . path . join ( dirpath , name ) ) zf . write ( path , path ) if logger is not None : logger . info ( "adding '%s'" , path ) for name in filenames : path = os . path . normpath ( os . path . join ( dirpath , name ) ) if os . path . isfile ( path ) : zf . write ( path , path ) if logger is not None : logger . info ( "adding '%s'" , path ) return zip_filename