diff options
author | hut <hut@lavabit.com> | 2012-03-20 22:25:12 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2012-03-20 22:25:12 +0100 |
commit | 456bddd637bfc2a634da26e66b7818ca9b1245e7 (patch) | |
tree | 00a86b18d4c9713c8b82eb5c9d4468d4b87723ad /ranger/ext/rifle.py | |
parent | dbf41d5b59ec92284ece626d5175f590b9445587 (diff) | |
download | ranger-456bddd637bfc2a634da26e66b7818ca9b1245e7.tar.gz |
ext.rifle: added "number" rule
Diffstat (limited to 'ranger/ext/rifle.py')
-rwxr-xr-x | ranger/ext/rifle.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index b98c35d3..50d14c4b 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -139,6 +139,10 @@ class Rifle(object): return argument in get_executables() if function == 'terminal': return _is_terminal() + if function == 'number': + if argument.isdigit(): + self._skip = int(argument) + return True if function == 'label': self._app_label = argument if label: @@ -208,14 +212,18 @@ class Rifle(object): result = [] t = time.time() for cmd, tests in self.rules: + self._skip = None self._app_flags = '' self._app_label = None for test in tests: if not self._eval_condition(test, files, None): break else: + if self._skip is None: + count += 1 + else: + count = self._skip result.append((count, cmd, self._app_label, self._app_flags)) - count += 1 return result def execute(self, files, way=0, label=None, flags=None, mimetype=None): @@ -235,22 +243,25 @@ class Rifle(object): """ self._mimetype = mimetype command = None - count = 0 + count = -1 # Determine command for cmd, tests in self.rules: + self._skip = None self._app_flags = '' self._app_label = None for test in tests: if not self._eval_condition(test, files, label): break else: + if self._skip is None: + count += 1 + else: + count = self._skip if label and label == self._app_label or \ not label and count == way: cmd = self.hook_command_preprocessing(cmd) command = self._build_command(files, cmd, flags) break - else: - count += 1 # Execute command if command is None: if count <= 0 or way <= 0: |