From b9fa8dbe4296b0d515c650e08aa88d159020100b Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 9 May 2018 09:28:38 +0530 Subject: [PATCH] DRYer --- kittens/diff/collect.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kittens/diff/collect.py b/kittens/diff/collect.py index 49cc47adb..3e0f7817e 100644 --- a/kittens/diff/collect.py +++ b/kittens/diff/collect.py @@ -125,10 +125,14 @@ def raw_data_for_path(path): return f.read() +def is_image(path): + return mime_type_for_path(path).startswith('image/') + + @lru_cache(maxsize=1024) def data_for_path(path): ans = raw_data_for_path(path) - if not mime_type_for_path(path).startswith('image/'): + if not is_image(path): try: ans = ans.decode('utf-8') except UnicodeDecodeError: