diff options
-rw-r--r-- | ranger/config/commands.py | 4 | ||||
-rw-r--r-- | ranger/config/rc.conf | 6 | ||||
-rw-r--r-- | ranger/core/loader.py | 13 | ||||
-rw-r--r-- | ranger/core/runner.py | 2 | ||||
-rwxr-xr-x | ranger/data/scope.sh | 4 | ||||
-rw-r--r-- | ranger/ext/shutil_generatorized.py | 33 |
6 files changed, 36 insertions, 26 deletions
diff --git a/ranger/config/commands.py b/ranger/config/commands.py index acc98457..9f0481ce 100644 --- a/ranger/config/commands.py +++ b/ranger/config/commands.py @@ -651,6 +651,8 @@ class touch(Command): Creates a file with the name <fname>. """ + resolve_macros = False + def execute(self): from os.path import join, expanduser, lexists @@ -726,6 +728,8 @@ class rename(Command): Changes the name of the currently highlighted file to <newname> """ + resolve_macros = False + def execute(self): from ranger.container.file import File from os import access diff --git a/ranger/config/rc.conf b/ranger/config/rc.conf index bb9af151..b2965cdc 100644 --- a/ranger/config/rc.conf +++ b/ranger/config/rc.conf @@ -330,9 +330,9 @@ map g? cd /usr/share/doc/ranger map E edit map du shell -p du --max-depth=1 -h --apparent-size map dU shell -p du --max-depth=1 -h --apparent-size | sort -rh -map yp shell -f echo -n %d/%f | xsel -i; xsel -o | xsel -i -b -map yd shell -f echo -n %d | xsel -i; xsel -o | xsel -i -b -map yn shell -f echo -n %f | xsel -i; xsel -o | xsel -i -b +map yp shell -f echo -n %%d/%%f | xsel -i; xsel -o | xsel -i -b +map yd shell -f echo -n %%d | xsel -i; xsel -o | xsel -i -b +map yn shell -f echo -n %%f | xsel -i; xsel -o | xsel -i -b # Filesystem Operations map = chmod diff --git a/ranger/core/loader.py b/ranger/core/loader.py index 1f9ec9cf..e672bbed 100644 --- a/ranger/core/loader.py +++ b/ranger/core/loader.py @@ -77,7 +77,6 @@ class CopyLoader(Loadable, FileManagerAware): # TODO: Don't calculate size when renaming (needs detection) bytes_per_tick = shutil_g.BLOCK_SIZE size = max(1, self._calculate_size(bytes_per_tick)) - bar_tick = 100.0 / (float(size) / bytes_per_tick) if self.do_cut: self.original_copy_buffer.clear() if len(self.copy_buffer) == 1: @@ -92,10 +91,10 @@ class CopyLoader(Loadable, FileManagerAware): self.fm.tags.tags[tf.replace(f.path, self.original_path \ + '/' + f.basename)] = tag self.fm.tags.dump() - for _ in shutil_g.move(src=f.path, + for done in shutil_g.move(src=f.path, dst=self.original_path, overwrite=self.overwrite): - self.percent += bar_tick + self.percent = float(done) / size * 100. yield else: if len(self.copy_buffer) == 1: @@ -104,17 +103,17 @@ class CopyLoader(Loadable, FileManagerAware): self.description = "copying files from: " + self.one_file.dirname for f in self.copy_buffer: if os.path.isdir(f.path) and not os.path.islink(f.path): - for _ in shutil_g.copytree(src=f.path, + for done in shutil_g.copytree(src=f.path, dst=os.path.join(self.original_path, f.basename), symlinks=True, overwrite=self.overwrite): - self.percent += bar_tick + self.percent = float(done) / size * 100. yield else: - for _ in shutil_g.copy2(f.path, self.original_path, + for done in shutil_g.copy2(f.path, self.original_path, symlinks=True, overwrite=self.overwrite): - self.percent += bar_tick + self.percent = float(done) / size * 100. yield cwd = self.fm.get_directory(self.original_path) cwd.load_content() diff --git a/ranger/core/runner.py b/ranger/core/runner.py index 0e5d9fa3..0ae227a6 100644 --- a/ranger/core/runner.py +++ b/ranger/core/runner.py @@ -146,7 +146,7 @@ class Runner(object): # Set default shell for Popen if popen_kws['shell']: # This doesn't work with fish, see #300 - if os.environ['SHELL'] != 'fish': + if not 'fish' in os.environ['SHELL']: popen_kws['executable'] = os.environ['SHELL'] if 'stdout' not in popen_kws: diff --git a/ranger/data/scope.sh b/ranger/data/scope.sh index 97844073..19404019 100755 --- a/ranger/data/scope.sh +++ b/ranger/data/scope.sh @@ -30,7 +30,7 @@ maxln=200 # Stop after $maxln lines. Can be used like ls | head -n $maxln # Find out something about the file: mimetype=$(file --mime-type -Lb "$path") -extension=$(/bin/echo -E "${path##*.}" | tr "[:upper:]" "[:lower:]") +extension=$(/bin/echo "${path##*.}" | tr "[:upper:]" "[:lower:]") # Functions: # runs a command and saves its output into $output. Useful if you need @@ -38,7 +38,7 @@ extension=$(/bin/echo -E "${path##*.}" | tr "[:upper:]" "[:lower:]") try() { output=$(eval '"$@"'); } # writes the output of the previously used "try" command -dump() { /bin/echo -E "$output"; } +dump() { /bin/echo "$output"; } # a common post-processing function used after most commands trim() { head -n "$maxln"; } diff --git a/ranger/ext/shutil_generatorized.py b/ranger/ext/shutil_generatorized.py index b20d5cef..7515b491 100644 --- a/ranger/ext/shutil_generatorized.py +++ b/ranger/ext/shutil_generatorized.py @@ -30,12 +30,14 @@ except NameError: def copyfileobj(fsrc, fdst, length=BLOCK_SIZE): """copy data from file-like object fsrc to file-like object fdst""" + total = 0 while 1: buf = fsrc.read(length) if not buf: break fdst.write(buf) - yield + total += len(buf) + yield total def _samefile(src, dst): # Macintosh, Unix. @@ -69,8 +71,8 @@ def copyfile(src, dst): try: fsrc = open(src, 'rb') fdst = open(dst, 'wb') - for _ in copyfileobj(fsrc, fdst): - yield + for done in copyfileobj(fsrc, fdst): + yield done finally: if fdst: fdst.close() @@ -107,8 +109,8 @@ def copy2(src, dst, overwrite=False, symlinks=False): os.unlink(dst) os.symlink(linkto, dst) else: - for _ in copyfile(src, dst): - yield + for done in copyfile(src, dst): + yield done copystat(src, dst) def get_safe_path(dst): @@ -165,6 +167,7 @@ def copytree(src, dst, symlinks=False, ignore=None, overwrite=False): if not overwrite: dst = get_safe_path(dst) os.makedirs(dst) + total = 0 for name in names: if name in ignored_names: continue @@ -178,14 +181,18 @@ def copytree(src, dst, symlinks=False, ignore=None, overwrite=False): os.symlink(linkto, dstname) copystat(srcname, dstname) elif os.path.isdir(srcname): - for _ in copytree(srcname, dstname, symlinks, + done = 0 + for done in copytree(srcname, dstname, symlinks, ignore, overwrite): - yield + yield total + done + total += done else: # Will raise a SpecialFileError for unsupported file types - for _ in copy2(srcname, dstname, + done = 0 + for done in copy2(srcname, dstname, overwrite=overwrite, symlinks=symlinks): - yield + yield total + done + total += done # catch the Error from the recursive copytree so that we can # continue with other files except Error as err: @@ -283,12 +290,12 @@ def move(src, dst, overwrite=False): if os.path.isdir(src): if _destinsrc(src, dst): raise Error("Cannot move a directory '%s' into itself '%s'." % (src, dst)) - for _ in copytree(src, real_dst, symlinks=True, overwrite=overwrite): - yield + for done in copytree(src, real_dst, symlinks=True, overwrite=overwrite): + yield done rmtree(src) else: - for _ in copy2(src, real_dst, symlinks=True, overwrite=overwrite): - yield + for done in copy2(src, real_dst, symlinks=True, overwrite=overwrite): + yield done os.unlink(src) def _destinsrc(src, dst): |