Skip to content

Commit

Permalink
ranger 1.9.4
Browse files Browse the repository at this point in the history
Signed-off-by: Rui Chen <[email protected]>

autobump: add ranger

Signed-off-by: Rui Chen <[email protected]>
  • Loading branch information
chenrui333 committed Nov 5, 2024
1 parent 6468736 commit 2350a77
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 54 deletions.
1 change: 1 addition & 0 deletions .github/autobump.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2393,6 +2393,7 @@ rage
railway
rakudo-star
rancher-cli
ranger
rapidfuzz-cpp
ratchet
rattler-build
Expand Down
56 changes: 2 additions & 54 deletions Formula/r/ranger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,11 @@ class Ranger < Formula

desc "File browser"
homepage "https://ranger.github.io"
url "https://github.com/ranger/ranger/archive/refs/tags/v1.9.4.tar.gz"
sha256 "7ad75e0d1b29087335fbb1691b05a800f777f4ec9cba84faa19355075d7f0f89"
license "GPL-3.0-or-later"
revision 2
head "https://github.com/ranger/ranger.git", branch: "master"

stable do
url "https://ranger.github.io/ranger-1.9.3.tar.gz"
sha256 "ce088a04c91c25263a9675dc5c43514b7ec1b38c8ea43d9a9d00923ff6cdd251"

# Drop `imghdr` for python 3.13
# Backport of https://github.com/ranger/ranger/commit/9c0d3ba3495bac80142fad518e29b9061be94cc6
patch :DATA
end

bottle do
rebuild 4
sha256 cellar: :any_skip_relocation, arm64_sequoia: "29f94668e81c45db4b87f46d183450c306196f58315d34c948090d87552d81a0"
Expand Down Expand Up @@ -43,47 +35,3 @@ def install
assert_equal "Hello World!\n", shell_output("#{bin}/rifle -p 2 test.py")
end
end

__END__
diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py
index ffaa4c0..a7e027e 100644
--- a/ranger/ext/img_display.py
+++ b/ranger/ext/img_display.py
@@ -15,7 +15,6 @@ import base64
import curses
import errno
import fcntl
-import imghdr
import os
import struct
import sys
@@ -341,12 +340,28 @@ class ITerm2ImageDisplayer(ImageDisplayer, FileManagerAware):
with open(path, 'rb') as fobj:
return base64.b64encode(fobj.read()).decode('utf-8')

+ @staticmethod
+ def imghdr_what(path):
+ """Replacement for the deprecated imghdr module"""
+ with open(path, "rb") as img_file:
+ header = img_file.read(32)
+ if header[6:10] in (b'JFIF', b'Exif'):
+ return 'jpeg'
+ elif header[:4] == b'\xff\xd8\xff\xdb':
+ return 'jpeg'
+ elif header.startswith(b'\211PNG\r\n\032\n'):
+ return 'png'
+ if header[:6] in (b'GIF87a', b'GIF89a'):
+ return 'gif'
+ else:
+ return None
+
@staticmethod
def _get_image_dimensions(path):
"""Determine image size using imghdr"""
file_handle = open(path, 'rb')
file_header = file_handle.read(24)
- image_type = imghdr.what(path)
+ image_type = ITerm2ImageDisplayer.imghdr_what(path)
if len(file_header) != 24:
file_handle.close()
return 0, 0

0 comments on commit 2350a77

Please sign in to comment.