| 107 | |
| 108 | == .tracignore == |
| 109 | * [trac:ticket:8348 project index shows hidden folders like ".svn"] |
| 110 | |
| 111 | * tar.gz>trac/web/main.py |
| 112 | {{{ |
| 113 | #!python |
| 114 | def get_tracignore_patterns(env_parent_dir): |
| 115 | """Return the list of patterns from env_parent_dir/.tracignore or a |
| 116 | default pattern of `".*"` if the file doesn't exist. |
| 117 | """ |
| 118 | path = os.path.join(env_parent_dir, '.tracignore') |
| 119 | try: |
| 120 | lines = [line.strip() for line in read_file(path).splitlines()] |
| 121 | except IOError: |
| 122 | return ['.*'] |
| 123 | return [line for line in lines if line and not line.startswith('#')] |
| 124 | |
| 125 | |
| 126 | def get_environments(environ, warn=False): |
| 127 | """Retrieve canonical environment name to path mapping. |
| 128 | |
| 129 | The environments may not be all valid environments, but they are good |
| 130 | candidates. |
| 131 | """ |
| 132 | (snip) |
| 133 | # Filter paths that match the .tracignore patterns |
| 134 | ignore_patterns = get_tracignore_patterns(env_parent_dir) |
| 135 | paths = [path[:-1] for path in paths if path[-1] == '/' |
| 136 | and not any(fnmatch.fnmatch(path[:-1], pattern) |
| 137 | for pattern in ignore_patterns)] |
| 138 | env_paths.extend(os.path.join(env_parent_dir, project) \ |
| 139 | for project in paths) |
| 140 | }}} |