From 0fd9b2020f65c63d27a3f06d591a364f66a0cb8d Mon Sep 17 00:00:00 2001 From: rupa Date: Sun, 30 Dec 2007 06:32:10 +0000 Subject: [PATCH] don't crash on files you can't read, el --- el | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/el b/el index 432dc0f..ce25f3b 100755 --- a/el +++ b/el @@ -22,8 +22,7 @@ def buildparser(): return parser def isbin(filename, blocksize=512): - f = open(filename) - f = f.read(blocksize) + f = open(filename).read(blocksize) if f: t = f.translate(_null_trans, text_characters) if "\0" in f or len(t)/len(f) > 0.30: @@ -31,10 +30,10 @@ def isbin(filename, blocksize=512): def getfiles(optall, optbin): for fn in os.listdir('.'): - if (os.path.isfile(fn) and - (optall or not fn.startswith('.')) and - (optbin or not isbin(fn))): - yield fn + if (os.path.isfile(fn) and os.access(fn,os.R_OK) and + (optall or not fn.startswith('.')) and + (optbin or not isbin(fn))): + yield fn def filterfiles(args, optall, optbin): files = [] @@ -58,7 +57,9 @@ def choose(names): return name def main(): - + if not editor: + print "$EDITOR not set" + return parser = buildparser() (opts, args) = parser.parse_args() try: -- 2.11.4.GIT