aboutsummaryrefslogtreecommitdiffstats
path: root/tools/indexcap.py
diff options
context:
space:
mode:
authorKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-25 17:47:25 +0000
committerKovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>2009-09-25 17:47:25 +0000
commit8ff8f868c15ef09fb058b8dc5d68ffb5776e2988 (patch)
tree822a1d64fce1bb4bf693bab3703dcd836733ad9a /tools/indexcap.py
parent8bd432e9405d53b84da5906e917a3808cce13d7d (diff)
Refactoring: add find_capture_files()
svn path=/trunk/; revision=30150
Diffstat (limited to 'tools/indexcap.py')
-rw-r--r--tools/indexcap.py21
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/indexcap.py b/tools/indexcap.py
index 842c3a2ef8..4b67e7c0b0 100644
--- a/tools/indexcap.py
+++ b/tools/indexcap.py
@@ -71,6 +71,17 @@ def list_files(cap_hash):
def index_file_action(options):
return options.list_proto or options.list_files
+def find_capture_files(paths, cap_hash):
+ cap_files = []
+ for path in paths:
+ if os.path.isdir(path):
+ path = os.path.normpath(path)
+ for root, dirs, files in os.walk(path):
+ cap_files += [os.path.join(root, name) for name in files if os.path.join(root, name) not in cap_hash]
+ elif path not in cap_hash:
+ cap_files.append(path)
+ return cap_files
+
def main():
parser = OptionParser(usage="usage: %prog [options] index_file [file_1|dir_1 [.. file_n|dir_n]]")
parser.add_option("-n", "--no-append", dest="append", default=True, action="store_false", help="Do not append to existing cache file")
@@ -115,15 +126,7 @@ def main():
exit(1)
paths = args
- cap_files = []
- for path in paths:
- if os.path.isdir(path):
- path = os.path.normpath(path)
- for root, dirs, files in os.walk(path):
- cap_files += [os.path.join(root, name) for name in files if os.path.join(root, name) not in cap_hash]
- elif path not in cap_hash:
- cap_files.append(path)
-
+ cap_files = find_capture_files(paths, cap_hash)
cap_files.sort()
print len(cap_files), "total files,",
cap_files = cap_files[:options.max_files]