author | ThomasE |
Tue, 29 Sep 2009 12:49:58 +0100 | |
changeset 532 | 082968cf2c9e |
parent 351 | a4c764727769 |
child 964 | e06b37cce80d |
permissions | -rw-r--r-- |
351
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
1 |
# Copyright (c) 2009 Symbian Foundation Ltd |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
2 |
# This component and the accompanying materials are made available |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
3 |
# under the terms of the License "Eclipse Public License v1.0" |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
4 |
# which accompanies this distribution, and is available |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
5 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
6 |
# |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
7 |
# Initial Contributors: |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
8 |
# Symbian Foundation Ltd - initial contribution. |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
9 |
# |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
10 |
# Contributors: |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
11 |
# mattd <mattd@symbian.org> |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
12 |
# |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
13 |
# Description: |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
14 |
# listdir.py - Lists a directory contents. |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
15 |
# listdir.py <directory> (<exclude_directory>) |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
16 |
|
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
17 |
import os |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
18 |
import re |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
19 |
import sys |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
20 |
import string |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
21 |
from os.path import join, isfile |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
22 |
|
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
23 |
def main(): |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
24 |
directory = sys.argv[1] |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
25 |
exclude_dirs = [] |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
26 |
if(len(sys.argv)>2): |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
27 |
x_dirs = string.lower(sys.argv[2]) |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
28 |
exclude_dirs = re.split(',', x_dirs) |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
29 |
scandir(directory, exclude_dirs) |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
30 |
|
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
31 |
def scandir(top, exclude_dirs): |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
32 |
fixpath = re.compile('\\\\') |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
33 |
fixroot = re.compile('^%s\\\\' % top) |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
34 |
for root, dirs, files in os.walk(top, topdown=True): |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
35 |
for dirname in dirs: |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
36 |
if(string.lower(fixpath.sub('/',os.path.join(root,dirname))) in exclude_dirs): |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
37 |
dirs.remove(dirname) |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
38 |
for name in files: |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
39 |
filename = os.path.join(root, name) |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
40 |
fn = string.lower(fixpath.sub('/',fixroot.sub('',filename))) |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
41 |
print fn |
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
42 |
|
a4c764727769
sf-list-dir - added new tool 'listdir.py' which can exclude a directory and changed the behaviour of sf-list-dir to stop scanning epoc32/build to speed things up.
MattD <mattd@symbian.org>
parents:
diff
changeset
|
43 |
main() |