summaryrefslogtreecommitdiff
path: root/anidb
diff options
context:
space:
mode:
authorVegard Storheil Eriksen <zyp@jvnv.net>2010-09-11 19:44:52 +0200
committerVegard Storheil Eriksen <zyp@jvnv.net>2010-09-11 19:46:34 +0200
commitd10da5a150dbc78370eea7c06f331cf59d3d68c6 (patch)
tree864cc011f9b02b13ffc8470473fd3f605e57e52a /anidb
parent0148c3ba5042df191a04dd7443be0d50d27b5498 (diff)
Skipping hidden files and directories while searching recursively.
Diffstat (limited to 'anidb')
-rwxr-xr-xanidb17
1 files changed, 12 insertions, 5 deletions
diff --git a/anidb b/anidb
index 81f6850..079bc07 100755
--- a/anidb
+++ b/anidb
@@ -6,6 +6,7 @@ warnings.filterwarnings('ignore', 'Python C API version mismatch for module _mul
import pyanidb, pyanidb.hash
import ConfigParser, optparse, os, sys, getpass
+from collections import deque
# Colors.
@@ -81,7 +82,9 @@ if options.login:
# Input files.
files = []
-for name in args:
+remaining = deque(args)
+while remaining:
+ name = remaining.popleft()
if not os.access(name, os.R_OK):
print red('Invalid file:'), name
elif os.path.isfile(name):
@@ -90,10 +93,14 @@ for name in args:
if not options.recursive:
print red('Is a directory:'), name
else:
- for root, subdirs, subfiles in os.walk(name):
- subdirs.sort()
- subfiles.sort()
- files += [os.path.join(root, file) for file in subfiles if True in [file.endswith('.' + suffix) for suffix in options.suffix]]
+ for sub in sorted(os.listdir(name)):
+ if sub.startswith('.'):
+ continue
+ sub = os.path.join(name, sub)
+ if os.path.isfile(name) and any(sub.endswith('.' + suffix) for suffix in options.suffix):
+ files.append(sub)
+ elif os.path.isdir(sub):
+ remaining.appendleft(sub)
if not files:
print blue('Nothing to do.')