From: Zac Medico Date: Thu, 30 Apr 2009 07:00:12 +0000 (-0000) Subject: Make RecursiveFileLoader skip hidden directories, and only use a single stat X-Git-Tag: v2.1.6.12~104 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=bd1135278486acf9dd011249153e0587ced39f65;p=portage.git Make RecursiveFileLoader skip hidden directories, and only use a single stat call to check for existence and file type. (trunk r13298) svn path=/main/branches/2.1.6/; revision=13469 --- diff --git a/pym/portage/env/loaders.py b/pym/portage/env/loaders.py index e031ed60f..400797c0c 100644 --- a/pym/portage/env/loaders.py +++ b/pym/portage/env/loaders.py @@ -4,6 +4,7 @@ # $Id$ import os +import stat class LoaderError(Exception): @@ -36,14 +37,18 @@ def RecursiveFileLoader(filename): @rtype: list @returns: List of files to process """ - if not os.path.exists(filename): + try: + st = os.stat(filename) + except OSError: return - elif os.path.isdir(filename): + if stat.S_ISDIR(st.st_mode): for root, dirs, files in os.walk(filename): - if 'CVS' in dirs: - dirs.remove('CVS') - files = [f for f in files if not f.startswith('.') and not f.endswith('~')] + for d in list(dirs): + if d[:1] == '.' or d == 'CVS': + dirs.remove(d) for f in files: + if f[:1] == '.' or f[-1:] == '~': + continue yield os.path.join(root, f) else: yield filename