mirror of
				https://github.com/python/cpython.git
				synced 2025-10-31 13:41:24 +00:00 
			
		
		
		
	 ba687d9481
			
		
	
	
		ba687d9481
		
			
		
	
	
	
	
		
			
			* gh-116608: Apply style and compatibility changes from importlib_metadata. * gh-121735: Ensure module-adjacent resources are loadable from a zipfile. * gh-121735: Allow all modules to be processed by the ZipReader. * Add blurb * Remove update-zips script, unneeded. * Remove unnecessary references to removed static fixtures. * Remove zipdata fixtures, unused.
		
			
				
	
	
		
			24 lines
		
	
	
	
		
			573 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
	
		
			573 B
		
	
	
	
		
			Python
		
	
	
		
			Executable file
		
	
	
	
	
| """
 | |
| Generate zip test data files.
 | |
| """
 | |
| 
 | |
| import zipfile
 | |
| 
 | |
| 
 | |
| def make_zip_file(tree, dst):
 | |
|     """
 | |
|     Zip the files in tree into a new zipfile at dst.
 | |
|     """
 | |
|     with zipfile.ZipFile(dst, 'w') as zf:
 | |
|         for name, contents in walk(tree):
 | |
|             zf.writestr(name, contents)
 | |
|         zipfile._path.CompleteDirs.inject(zf)
 | |
|     return dst
 | |
| 
 | |
| 
 | |
| def walk(tree, prefix=''):
 | |
|     for name, contents in tree.items():
 | |
|         if isinstance(contents, dict):
 | |
|             yield from walk(contents, prefix=f'{prefix}{name}/')
 | |
|         else:
 | |
|             yield f'{prefix}{name}', contents
 |