python - Recursively unzip archives, store (filename, extracted-contents) in dictionary -


could please me write function returning:

dict("file1.txt": list(<contents of file1>),      "file2.txt": list(<contents of file2>),      "file3.txt": list(<contents of file3>),      "file4.txt": list(<contents of file4>)) 

on input:

    file.zip:         outer\         outer\inner1.zip:                 file1.txt                 file2.txt         outer\inner2.zip:                 file3.txt                 file4.txt 

my attempts (with exceptions below):

finally worked out... bit of from: extracting zipfile memory?;

from zipfile import zipfile, is_zipfile  def extract_zip(input_zip):     input_zip=zipfile(input_zip)     return {name: input_zip.read(name) name in input_zip.namelist()}  def extract_all(input_zip):      return {entry: extract_zip(entry) entry in zipfile(input_zip).namelist() if is_zipfile(entry)} 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -