From 52ba33919967827deb3042e70940239194b5b6e6 Mon Sep 17 00:00:00 2001 From: hut Date: Thu, 26 Apr 2012 20:08:01 +0200 Subject: ext.rifle: Added "match", "file" and "directory" functions Conflicts: ranger/ext/rifle.py --- ranger/defaults/rifle.conf | 19 +++++++++++-------- ranger/ext/rifle.py | 6 ++++++ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ranger/defaults/rifle.conf b/ranger/defaults/rifle.conf index 15a00dae..9ee15b25 100644 --- a/ranger/defaults/rifle.conf +++ b/ranger/defaults/rifle.conf @@ -13,14 +13,17 @@ # # Prefixing a condition with "!" will negate its result. # These conditions are currently supported: -# ext | The regexp matches the extension of $1 -# mime | The regexp matches the mime type of $1 -# name | The regexp matches the basename of $1 -# path | The regexp matches the absolute path of $1 -# has | The program is installed (i.e. located in $PATH) -# number | change the number of this command to n -# terminal | stdin, stderr and stdout are connected to a terminal -# X | $DISPLAY is not empty (i.e. Xorg runs) +# match | The regexp matches $1 +# ext | The regexp matches the extension of $1 +# mime | The regexp matches the mime type of $1 +# name | The regexp matches the basename of $1 +# path | The regexp matches the absolute path of $1 +# has | The program is installed (i.e. located in $PATH) +# file | $1 is a file +# directory | $1 is a directory +# number | change the number of this command to n +# terminal | stdin, stderr and stdout are connected to a terminal +# X | $DISPLAY is not empty (i.e. Xorg runs) # # There are also pseudo-conditions which have a "side effect": # flag | Change how the program is run. See below. diff --git a/ranger/ext/rifle.py b/ranger/ext/rifle.py index aef6c54b..1080ecec 100755 --- a/ranger/ext/rifle.py +++ b/ranger/ext/rifle.py @@ -169,6 +169,12 @@ class Rifle(object): return bool(re.search('^(' + argument + ')$', extension)) elif function == 'name': return bool(re.search(argument, os.path.basename(files[0]))) + elif function == 'match': + return bool(re.search(argument, files[0])) + elif function == 'file': + return os.path.isfile(files[0]) + elif function == 'directory': + return os.path.isdir(files[0]) elif function == 'path': return bool(re.search(argument, os.path.abspath(files[0]))) elif function == 'mime': -- cgit 1.4.1-2-gfad0