From 1183d6f817046a9f2b82a8d61b56046f046afb3f Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Sun, 24 May 2020 02:36:43 +0100 Subject: Move to Python 3 Python 3 was released more than 10 years ago, and support for Python 2 is going away, with many Linux distributions starting to phase it out. This patch migrates git-arr to Python 3. The generated output is almost exactly the same, there are some minor differences such as HTML characters being quoted more aggresively, and handling of paths with non-utf8 values. --- utils.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'utils.py') diff --git a/utils.py b/utils.py index ada9c7e..4e12b0d 100644 --- a/utils.py +++ b/utils.py @@ -108,15 +108,17 @@ def markdown_blob(s): def embed_image_blob(fname, image_data): mimetype = mimetypes.guess_type(fname)[0] + b64img = base64.b64encode(image_data).decode("ascii") return ''.format( \ - mimetype, base64.b64encode(image_data)) + mimetype, b64img) def is_binary(s): # Git considers a blob binary if NUL in first ~8KB, so do the same. - return '\0' in s[:8192] + return b'\0' in s[:8192] def hexdump(s): graph = string.ascii_letters + string.digits + string.punctuation + ' ' + s = s.decode("latin1") offset = 0 while s: t = s[:16] -- cgit v1.2.3