Package envi :: Module pyzip
[hide private]
[frames] | no frames]

Source Code for Module envi.pyzip

 1  import os 
 2  import sys 
 3  import zipfile 
 4   
 5  ''' 
 6  A utility package (in a central location) for packaging up 
 7  zip files full of source or whatever... 
 8  ''' 
 9   
10 -def callback(z, dname, files):
11 if dname.find('.svn') != -1: 12 return 13 14 for fname in files: 15 if fname.endswith('.py'): 16 fpath = os.path.join(dname, fname) 17 z.write(fpath)
18
19 -def addSource(z, dname):
20 os.path.walk(dname, callback, z)
21
22 -def main():
23 24 zipname = sys.argv[1] 25 pz = zipfile.PyZipFile(zipname, 'w') 26 27 dirnames = sys.argv[2:] 28 if not len(dirnames): 29 dirnames = [ dname for dname in os.listdir('.') if os.path.isdir(dname) and dname != '.svn' ] 30 31 for dirname in dirnames: 32 addSource(pz, dirname) 33 pz.writepy(dirname) 34 35 pz.close()
36 37 if __name__ == '__main__': 38 sys.exit(main()) 39