about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2021-08-27 20:20:16 +0200
committertoonn <toonn@toonn.io>2021-08-27 20:23:26 +0200
commit4b66f510daeb5d6914a0e1cd1dd0cad16057df9d (patch)
tree6adfe17361bbceb7bece08e30f02ee7613442f66 /ranger
parent0fb602aadace2d15717ac50c6a92f7275123267a (diff)
downloadranger-4b66f510daeb5d6914a0e1cd1dd0cad16057df9d.tar.gz
config.commands: Switch to open23, forcing UTF-8
Diffstat (limited to 'ranger')
-rwxr-xr-xranger/config/commands.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py
index 2076dea3..327be5d1 100755
--- a/ranger/config/commands.py
+++ b/ranger/config/commands.py
@@ -882,11 +882,12 @@ class load_copy_buffer(Command):
 
     def execute(self):
         from ranger.container.file import File
+        from ranger.ext.open23 import open23
         from os.path import exists
         fname = self.fm.datapath(self.copy_buffer_filename)
         unreadable = OSError if PY3 else IOError
         try:
-            with open(fname, "r") as fobj:
+            with open23(fname, "r") as fobj:
                 self.fm.copy_buffer = set(
                     File(g) for g in fobj.read().split("\n") if exists(g)
                 )
@@ -906,11 +907,12 @@ class save_copy_buffer(Command):
     copy_buffer_filename = 'copy_buffer'
 
     def execute(self):
+        from ranger.ext.open23 import open23
         fname = None
         fname = self.fm.datapath(self.copy_buffer_filename)
         unwritable = OSError if PY3 else IOError
         try:
-            with open(fname, "w") as fobj:
+            with open23(fname, "w") as fobj:
                 fobj.write("\n".join(fobj.path for fobj in self.fm.copy_buffer))
         except unwritable:
             return self.fm.notify("Cannot open %s" %
@@ -956,13 +958,14 @@ class touch(Command):
     def execute(self):
         from os.path import join, expanduser, lexists, dirname
         from os import makedirs
+        from ranger.ext.open23 import open23
 
         fname = join(self.fm.thisdir.path, expanduser(self.rest(1)))
         dirname = dirname(fname)
         if not lexists(fname):
             if not lexists(dirname):
                 makedirs(dirname)
-            with open(fname, 'a'):
+            with open23(fname, 'a'):
                 pass  # Just create the file
         else:
             self.fm.notify("file/directory exists!", bad=True)
@@ -1888,7 +1891,7 @@ class meta(prompt_metadata):
 
     def execute(self):
         key = self.arg(1)
-        update_dict = dict()
+        update_dict = {}
         update_dict[key] = self.rest(2)
         selection = self.fm.thistab.get_selection()
         for fobj in selection: