zipup.py

This function is used to create simple deflated zip files.

'''
This script assumes you are using the MyGlobals class to create the
global variables object and that you have configuration files in a list
you would like to add to your zip file.
'''
def zipup():
    import zipfile,os
    z = zipfile.PyZipFile(g['zfile'],'w')
    conf_files = []
    for i in cfg.keys(): # here we loadup our conf_files list from a config file
        conf_files.append(i)
    
    for filename in conf_files: # iterate through the conf files
       if filename: # if the variable filename has a value do the following...
           if filename.find('files') == -1: # here we check to see if the key is one from the 'files' section of the conf file.
               continue # if this isn't a configfile key the skip it
           if filename.find('outfile') != -1:
               cfg[filename] = g['outfile'] # lets grab the actual file location from the global variables object
           z.write(cfg[filename], os.path.basename(cfg[filename]),zipfile.ZIP_DEFLATED)
    z.write(g['config_file'],os.path.basename(g['config_file']), zipfile.ZIP_DEFLATED)
    z.close()