X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=bin%2Funzip.py;h=dd0a79f5931503e1bf358006ec2719a9eac61075;hb=7bc97fc1d57dbae21c1feab20ce112e3be78c634;hp=a5d3cf35e20ab4f41d670fd4965233388d388897;hpb=05cfb307e205fea010f32eda0c3944ffc40b6775;p=dotfiles.git diff --git a/bin/unzip.py b/bin/unzip.py index a5d3cf3..dd0a79f 100755 --- a/bin/unzip.py +++ b/bin/unzip.py @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Unzip with encoded filenames - Written by Oleg Broytman. Copyright (C) 2009, 2010 PhiloSoft Design. + Written by Oleg Broytman. Copyright (C) 2009-2023 PhiloSoft Design. """ import sys, os, time @@ -26,15 +26,16 @@ out = '.' for zinfo in zf.infolist(): path = zinfo.filename - if not isinstance(path, unicode): + if isinstance(path, bytes): path = path.decode('cp866') - recoded_path = path.encode(default_encoding) - print recoded_path + recoded_path = path.encode(default_encoding) + else: + recoded_path = path.encode('cp437').decode('cp866') + print(recoded_path) if path.startswith('./'): - tgt = os.path.join(out, recoded_path[2:]) - else: - tgt = os.path.join(out, recoded_path) + recoded_path = recoded_path[2:] + tgt = os.path.join(out, recoded_path) tgtdir = os.path.dirname(tgt) if not os.path.exists(tgtdir):