def unzip_file(filename, location, flatten=True):
if not os.path.exists(location):<EOL><INDENT>os.makedirs(location)<EOL><DEDENT>zipfp = open(filename, '<STR_LIT:rb>')<EOL>try:<EOL><INDENT>zip = zipfile.ZipFile(zipfp)<EOL>leading = has_leading_dir(zip.namelist()) and flatten<EOL>for name in zip.namelist():<EOL><INDENT>data = zip.read(name)<EOL>fn = name<EOL>if leading:<EOL><INDENT>fn = split_leading_dir(name)[<NUM_LIT:1>]<EOL><DEDENT>fn = os.path.join(location, fn)<EOL>dir = os.path.dirname(fn)<EOL>if not os.path.exists(dir):<EOL><INDENT>os.makedirs(dir)<EOL><DEDENT>if fn.endswith('<STR_LIT:/>') or fn.endswith('<STR_LIT:\\>'):<EOL><INDENT>if not os.path.exists(fn):<EOL><INDENT>os.makedirs(fn)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>fp = open(fn, '<STR_LIT:wb>')<EOL>try:<EOL><INDENT>fp.write(data)<EOL><DEDENT>finally:<EOL><INDENT>fp.close()<EOL><DEDENT><DEDENT><DEDENT><DEDENT>finally:<EOL><INDENT>zipfp.close()<EOL><DEDENT>
Unzip the file (zip file located at filename) to the destination
    location