diff options
author | Alberto Bertogli <albertito@blitiri.com.ar> | 2020-05-24 03:36:43 +0200 |
---|---|---|
committer | Alberto Bertogli <albertito@blitiri.com.ar> | 2020-05-24 05:50:39 +0200 |
commit | 1183d6f817046a9f2b82a8d61b56046f046afb3f (patch) | |
tree | c97cd9382583fb5b7b9ae7c83efdc684ef7b3cf5 /utils.py | |
parent | cbb36e087c1bcf1c81de53e920baf0c681abfd87 (diff) | |
download | git-arr-fork-1183d6f817046a9f2b82a8d61b56046f046afb3f.zip |
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.
Diffstat (limited to 'utils.py')
-rw-r--r-- | utils.py | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -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 '<img style="max-width:100%;" src="data:{0};base64,{1}" />'.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] |