diff options
Diffstat (limited to 'ranger')
-rw-r--r-- | ranger/config/.pylintrc | 2 | ||||
-rw-r--r-- | ranger/container/file.py | 2 | ||||
-rw-r--r-- | ranger/core/loader.py | 2 | ||||
-rwxr-xr-x | ranger/data/scope.sh | 38 | ||||
-rw-r--r-- | ranger/ext/img_display.py | 2 | ||||
-rw-r--r-- | ranger/ext/vcs/vcs.py | 6 |
6 files changed, 29 insertions, 23 deletions
diff --git a/ranger/config/.pylintrc b/ranger/config/.pylintrc index 316bf189..509c6f31 100644 --- a/ranger/config/.pylintrc +++ b/ranger/config/.pylintrc @@ -5,4 +5,4 @@ class-rgx=[a-z][a-z0-9_]{1,30}$ [FORMAT] max-line-length = 99 max-module-lines=3000 -disable=duplicate-code,fixme,import-outside-toplevel,locally-disabled,locally-enabled,missing-docstring,no-else-return,super-with-arguments +disable=consider-using-f-string,duplicate-code,fixme,import-outside-toplevel,locally-disabled,locally-enabled,missing-docstring,no-else-return,super-with-arguments diff --git a/ranger/container/file.py b/ranger/container/file.py index 9477abe7..4cc29887 100644 --- a/ranger/container/file.py +++ b/ranger/container/file.py @@ -86,7 +86,7 @@ class File(FileSystemObject): return True if PREVIEW_BLACKLIST.search(self.basename): return False - if self.path == '/dev/core' or self.path == '/proc/kcore': + if self.path in ('/dev/core', '/proc/kcore'): return False if self.is_binary(): return False diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 5c9e28a5..19611c7b 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -192,7 +192,7 @@ class CommandLoader( # pylint: disable=too-many-instance-attributes try: stdin.write(self.input) except IOError as ex: - if ex.errno != errno.EPIPE and ex.errno != errno.EINVAL: + if ex.errno not in (errno.EPIPE, errno.EINVAL): raise stdin.close() if self.silent and not self.read: # pylint: disable=too-many-nested-blocks diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 36c462c6..2e9983ee 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -140,9 +140,11 @@ handle_image() { local mimetype="${1}" case "${mimetype}" in ## SVG - # image/svg+xml|image/svg) - # convert -- "${FILE_PATH}" "${IMAGE_CACHE_PATH}" && exit 6 - # exit 1;; + image/svg+xml|image/svg) + rsvg-convert --keep-aspect-ratio --width "${DEFAULT_SIZE%x*}" "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}.png" \ + && mv "${IMAGE_CACHE_PATH}.png" "${IMAGE_CACHE_PATH}" \ + && exit 6 + exit 1;; ## DjVu # image/vnd.djvu) @@ -268,19 +270,23 @@ handle_image() { # mv "${TMPPNG}" "${IMAGE_CACHE_PATH}" # } - # case "${FILE_EXTENSION_LOWER}" in - # ## 3D models - # ## OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH} - # ## is hardcoded as jpeg. So we make a tempfile.png and just - # ## move/rename it to jpg. This works because image libraries are - # ## smart enough to handle it. - # csg|scad) - # openscad_image "${FILE_PATH}" && exit 6 - # ;; - # 3mf|amf|dxf|off|stl) - # openscad_image <(echo "import(\"${FILE_PATH}\");") && exit 6 - # ;; - # esac + case "${FILE_EXTENSION_LOWER}" in + ## 3D models + ## OpenSCAD only supports png image output, and ${IMAGE_CACHE_PATH} + ## is hardcoded as jpeg. So we make a tempfile.png and just + ## move/rename it to jpg. This works because image libraries are + ## smart enough to handle it. + # csg|scad) + # openscad_image "${FILE_PATH}" && exit 6 + # ;; + # 3mf|amf|dxf|off|stl) + # openscad_image <(echo "import(\"${FILE_PATH}\");") && exit 6 + # ;; + drawio) + draw.io -x "${FILE_PATH}" -o "${IMAGE_CACHE_PATH}" \ + --width "${DEFAULT_SIZE%x*}" && exit 6 + exit 1;; + esac } handle_mime() { diff --git a/ranger/ext/img_display.py b/ranger/ext/img_display.py index 43e4203d..61e10f96 100644 --- a/ranger/ext/img_display.py +++ b/ranger/ext/img_display.py @@ -643,7 +643,7 @@ class KittyImageDisplayer(ImageDisplayer, FileManagerAware): image = image.resize((int(scale * image.width), int(scale * image.height)), self.backend.LANCZOS) - if image.mode != 'RGB' and image.mode != 'RGBA': + if image.mode not in ('RGB', 'RGBA'): image = image.convert('RGB') # start_x += ((box[0] - image.width) // 2) // self.pix_row # start_y += ((box[1] - image.height) // 2) // self.pix_col diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py index 5619ed19..93fb1d0b 100644 --- a/ranger/ext/vcs/vcs.py +++ b/ranger/ext/vcs/vcs.py @@ -463,10 +463,10 @@ class VcsThread(threading.Thread): # pylint: disable=too-many-instance-attribut self.paused.set() self._advance.wait() self._awoken.wait() - if self.__stop.isSet(): + if self.__stop.is_set(): self.stopped.set() return - if not self._advance.isSet(): + if not self._advance.is_set(): continue self._awoken.clear() self.paused.clear() @@ -491,7 +491,7 @@ class VcsThread(threading.Thread): # pylint: disable=too-many-instance-attribut self._advance.set() self._awoken.set() self.stopped.wait(1) - return self.stopped.isSet() + return self.stopped.is_set() def pause(self): """Pause thread""" |