diff options
author | hut <hut@lavabit.com> | 2012-03-21 02:01:22 +0100 |
---|---|---|
committer | hut <hut@lavabit.com> | 2012-03-21 02:01:22 +0100 |
commit | 34c0d954f221e3541c195027851e471204993177 (patch) | |
tree | 5badd73b1004004893bb99b19dc702847d8b218a | |
parent | ec972cda26cfb1aff7475e21f8476fc97388dedc (diff) | |
download | ranger-34c0d954f221e3541c195027851e471204993177.tar.gz |
ext.rifle: shortened Rifle.execute_file
-rwxr-xr-x | ranger/ext/rifle.py | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index 16b22092..ba10427e 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -208,7 +208,7 @@ class Rifle(object): label and flags are the label and flags specified in the rule. """ self._mimetype = mimetype - count = 0 + count = -1 t = time.time() for cmd, tests in self.rules: self._skip = None @@ -239,27 +239,15 @@ class Rifle(object): For example: if the flag in the rule is "pw" and you specify "Pf", then the "p" flag is negated and the "f" flag is added, resulting in "wf". """ - self._mimetype = mimetype command = None - 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 + for count, cmd, lbl, flags in self.list_commands(files, mimetype): + if label and label == lbl or not label and count == way: + cmd = self.hook_command_preprocessing(cmd) + command = self._build_command(files, cmd, flags) + break + # Execute command if command is None: if count <= 0 or way <= 0: |