X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=bin%2Fzip.py;h=35bf0e69f00da71c92c80ef55c09767c904e0120;hb=3fdf2f7baaa3a67880de95948d6ee76bc698fbc9;hp=e99c9a8283ed6829e824388994eee5a043a51652;hpb=f0344023aa21ede3b47d77559af54b97c37f328b;p=dotfiles.git diff --git a/bin/zip.py b/bin/zip.py index e99c9a8..35bf0e6 100755 --- a/bin/zip.py +++ b/bin/zip.py @@ -1,7 +1,7 @@ -#! /usr/bin/env python +#! /usr/bin/env python3 """Zip (zip -r9) 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 @@ -23,7 +23,10 @@ if len(arguments) < 2: def addToZip(zf, path): if os.path.isfile(path): print(path) - recoded_path = path.decode(default_encoding).encode('cp866') + if isinstance(path, bytes): + recoded_path = path.decode(default_encoding).encode('cp866') + else: + recoded_path = path zf.write(path, recoded_path, ZIP_DEFLATED) elif os.path.isdir(path): for nm in os.listdir(path):