From bd1135278486acf9dd011249153e0587ced39f65 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 30 Apr 2009 07:00:12 +0000 Subject: [PATCH] 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 --- pym/portage/env/loaders.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) 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 -- 2.26.2