1 |
Author: zmedico |
2 |
Date: 2009-04-30 07:00:12 +0000 (Thu, 30 Apr 2009) |
3 |
New Revision: 13469 |
4 |
|
5 |
Modified: |
6 |
main/branches/2.1.6/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. (trunk r13298) |
10 |
|
11 |
Modified: main/branches/2.1.6/pym/portage/env/loaders.py |
12 |
=================================================================== |
13 |
--- main/branches/2.1.6/pym/portage/env/loaders.py 2009-04-30 06:59:53 UTC (rev 13468) |
14 |
+++ main/branches/2.1.6/pym/portage/env/loaders.py 2009-04-30 07:00:12 UTC (rev 13469) |
15 |
@@ -4,6 +4,7 @@ |
16 |
# $Id$ |
17 |
|
18 |
import os |
19 |
+import stat |
20 |
|
21 |
class LoaderError(Exception): |
22 |
|
23 |
@@ -36,14 +37,18 @@ |
24 |
@rtype: list |
25 |
@returns: List of files to process |
26 |
""" |
27 |
- if not os.path.exists(filename): |
28 |
+ try: |
29 |
+ st = os.stat(filename) |
30 |
+ except OSError: |
31 |
return |
32 |
- elif os.path.isdir(filename): |
33 |
+ if stat.S_ISDIR(st.st_mode): |
34 |
for root, dirs, files in os.walk(filename): |
35 |
- if 'CVS' in dirs: |
36 |
- dirs.remove('CVS') |
37 |
- files = [f for f in files if not f.startswith('.') and not f.endswith('~')] |
38 |
+ for d in list(dirs): |
39 |
+ if d[:1] == '.' or d == 'CVS': |
40 |
+ dirs.remove(d) |
41 |
for f in files: |
42 |
+ if f[:1] == '.' or f[-1:] == '~': |
43 |
+ continue |
44 |
yield os.path.join(root, f) |
45 |
else: |
46 |
yield filename |