Changeset f1fa0b834bd52deee1f232bd021997a38e9e4d3a
- Timestamp:
- 12/29/07 22:08:49
(1 year ago)
- Author:
- William McBrine <wmcbrine@gmail.com>
- git-committer:
- William McBrine <wmcbrine@gmail.com> 1198987729 -0500
- git-parent:
[65dc233d7ee1dd68556c117a3556ea7944b0337b]
- git-author:
- William McBrine <wmcbrine@gmail.com> 1198987729 -0500
- Message:
Build a true recursive file list when asked, and omit directories (Ticket #59)
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rd421945 |
rf1fa0b8 |
|
| 54 | 54 | |
|---|
| 55 | 55 | def get_files(self, handler, query, filterFunction=None): |
|---|
| | 56 | |
|---|
| | 57 | def build_recursive_list(path, recurse=True): |
|---|
| | 58 | files = [] |
|---|
| | 59 | for file in os.listdir(path): |
|---|
| | 60 | file = os.path.join(path, file) |
|---|
| | 61 | if recurse and os.path.isdir(file): |
|---|
| | 62 | files.extend(build_recursive_list(file)) |
|---|
| | 63 | else: |
|---|
| | 64 | if not filterFunction or filterFunction(file, file_type): |
|---|
| | 65 | files.append(file) |
|---|
| | 66 | return files |
|---|
| | 67 | |
|---|
| 56 | 68 | subcname = query['Container'][0] |
|---|
| 57 | 69 | cname = subcname.split('/')[0] |
|---|
| 58 | 70 | path = self.get_local_path(handler, query) |
|---|
| 59 | 71 | |
|---|
| 60 | | files = [ os.path.join(path, file) for file in os.listdir(path)] |
|---|
| 61 | | if query.get('Recurse',['No'])[0] == 'Yes': |
|---|
| 62 | | for file in files: |
|---|
| 63 | | if os.path.isdir(file): |
|---|
| 64 | | for new_file in os.listdir(file): |
|---|
| 65 | | files.append( os.path.join(file, new_file) ) |
|---|
| | 72 | file_type = query.get('Filter', [''])[0] |
|---|
| 66 | 73 | |
|---|
| 67 | | file_type = query.get('Filter', [''])[0] |
|---|
| 68 | | if filterFunction: |
|---|
| 69 | | files = [file for file in files if filterFunction(file, file_type)] |
|---|
| | 74 | recurse = query.get('Recurse',['No'])[0] == 'Yes' |
|---|
| | 75 | files = build_recursive_list(path, recurse) |
|---|
| 70 | 76 | |
|---|
| 71 | 77 | totalFiles = len(files) |
|---|