1 |
Author: zmedico |
2 |
Date: 2009-04-08 03:11:01 +0000 (Wed, 08 Apr 2009) |
3 |
New Revision: 13298 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/env/loaders.py |
7 |
Log: |
8 |
Make RecursiveFileLoader skip hidden directories, and only use a single stat |
9 |
call to check for existence and file type. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/portage/env/loaders.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/portage/env/loaders.py 2009-04-08 02:51:33 UTC (rev 13297) |
15 |
+++ main/trunk/pym/portage/env/loaders.py 2009-04-08 03:11:01 UTC (rev 13298) |
16 |
@@ -4,6 +4,7 @@ |
17 |
# $Id$ |
18 |
|
19 |
import os |
20 |
+import stat |
21 |
|
22 |
class LoaderError(Exception): |
23 |
|
24 |
@@ -36,14 +37,18 @@ |
25 |
@rtype: list |
26 |
@returns: List of files to process |
27 |
""" |
28 |
- if not os.path.exists(filename): |
29 |
+ try: |
30 |
+ st = os.stat(filename) |
31 |
+ except OSError: |
32 |
return |
33 |
- elif os.path.isdir(filename): |
34 |
+ if stat.S_ISDIR(st.st_mode): |
35 |
for root, dirs, files in os.walk(filename): |
36 |
- if 'CVS' in dirs: |
37 |
- dirs.remove('CVS') |
38 |
- files = [f for f in files if not f.startswith('.') and not f.endswith('~')] |
39 |
+ for d in list(dirs): |
40 |
+ if d[:1] == '.' or d == 'CVS': |
41 |
+ dirs.remove(d) |
42 |
for f in files: |
43 |
+ if f[:1] == '.' or f[-1:] == '~': |
44 |
+ continue |
45 |
yield os.path.join(root, f) |
46 |
else: |
47 |
yield filename |