common/tools/listdir.py
author Simon Howkins <simonh@symbian.org>
Thu, 10 Dec 2009 12:01:59 +0000
changeset 825 1de547e13d13
parent 351 a4c764727769
child 964 e06b37cce80d
permissions -rw-r--r--
Updates to make the build environment check more reasonable: Mercurial v1.3 permitted The Java compiler is not a showstopping issue 7-zip can be installed in any location Update to Helium 5 Helium can be installed in PDT 1.*, not necessarily 1.0 Raptor installation path not significant Update to Raptor 2.9.* The Raptor patch to update the bundled version of python is no longer relevant BRAG calculations updated to ignore items not being in the system path, as this just doesn't matter. Overall effect is that the build environment check should pass on a machine that is able to do a build!

# Copyright (c) 2009 Symbian Foundation Ltd
# This component and the accompanying materials are made available
# under the terms of the License "Eclipse Public License v1.0"
# which accompanies this distribution, and is available
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
#
# Initial Contributors:
# Symbian Foundation Ltd - initial contribution.
#
# Contributors:
# mattd <mattd@symbian.org>
#
# Description:
# listdir.py - Lists a directory contents.
# listdir.py <directory> (<exclude_directory>)

import os
import re
import sys
import string
from os.path import join, isfile

def main():
  directory = sys.argv[1]
  exclude_dirs = []
  if(len(sys.argv)>2):
    x_dirs = string.lower(sys.argv[2])
    exclude_dirs = re.split(',', x_dirs)
  scandir(directory, exclude_dirs)

def scandir(top, exclude_dirs):
    fixpath = re.compile('\\\\')    
    fixroot = re.compile('^%s\\\\' % top)
    for root, dirs, files in os.walk(top, topdown=True):
        for dirname in dirs:
            if(string.lower(fixpath.sub('/',os.path.join(root,dirname))) in exclude_dirs):
              dirs.remove(dirname)
        for name in files:
            filename = os.path.join(root, name)
            fn = string.lower(fixpath.sub('/',fixroot.sub('',filename)))
            print fn

main()