Add facets to file resources using the `facet` definition of facets. Each entry in the `facet` sequence is a string as in :
(self, codebase, facet=(), **kwargs)
| 129 | return bool(facet) |
| 130 | |
| 131 | def process_codebase(self, codebase, facet=(), **kwargs): |
| 132 | """ |
| 133 | Add facets to file resources using the `facet` definition of facets. |
| 134 | Each entry in the `facet` sequence is a string as in <facet>:<pattern> |
| 135 | """ |
| 136 | |
| 137 | if not facet: |
| 138 | return |
| 139 | |
| 140 | facet_definitions, _invalid_facet_definitions = build_facets(facet) |
| 141 | |
| 142 | if TRACE: |
| 143 | logger_debug('facet_definitions:', facet_definitions) |
| 144 | |
| 145 | # Walk the codebase and set the facets for each file (and only files) |
| 146 | for resource in codebase.walk(topdown=True): |
| 147 | if not resource.is_file: |
| 148 | continue |
| 149 | facets = compute_path_facets(resource.path, facet_definitions) |
| 150 | if facets: |
| 151 | resource.facets = facets |
| 152 | else: |
| 153 | resource.facets = [FACET_CORE] |
| 154 | resource.save(codebase) |
| 155 | |
| 156 | |
| 157 | def compute_path_facets(path, facet_definitions): |