INNER CODE UNIT · Python
unzip
TheAssemblyArmada/Vanilla-Conquer · scripts/tgautil.py:116
def unzip(args):
if not os.path.isfile(args.archive):
print >> sys.stderr, '\'{}\' does not exist or is not a file\n'.format(args.archive)
sys.exit(1)
out_dir = os.path.normpath(os.path.splitext(args.archive)[0])
if os.path.exists(out_dir):
if not os.path.isdir(out_dir):
print >> sys.stderr, '\'{}\' already exists and is not a directory\n'.format(out_dir)
sys.exit(1)
if len(os.listdir(out_dir)) > 0:
if not args.yes and not overwrite_prompt('\'{}\' is not empty, overwrite?'.format(out_dir)):
sys.exit(0)
else:
os.mkdir(out_dir)
files = {}
with zipfile.ZipFile(args.archive, 'r', zipfile.ZIP_DEFLATED) as zip:
for filename in zip.namelist():
fileparts = os.path.splitext(filename)