Search name in all directories specified in lookup. First without, then with common extensions. Return first hit.
(cls, name, lookup=[])
| 3236 | |
| 3237 | @classmethod |
| 3238 | def search(cls, name, lookup=[]): |
| 3239 | """ Search name in all directories specified in lookup. |
| 3240 | First without, then with common extensions. Return first hit. """ |
| 3241 | if not lookup: |
| 3242 | depr('The template lookup path list should not be empty.') #0.12 |
| 3243 | lookup = ['.'] |
| 3244 | |
| 3245 | if os.path.isabs(name) and os.path.isfile(name): |
| 3246 | depr('Absolute template path names are deprecated.') #0.12 |
| 3247 | return os.path.abspath(name) |
| 3248 | |
| 3249 | for spath in lookup: |
| 3250 | spath = os.path.abspath(spath) + os.sep |
| 3251 | fname = os.path.abspath(os.path.join(spath, name)) |
| 3252 | if not fname.startswith(spath): continue |
| 3253 | if os.path.isfile(fname): return fname |
| 3254 | for ext in cls.extensions: |
| 3255 | if os.path.isfile('%s.%s' % (fname, ext)): |
| 3256 | return '%s.%s' % (fname, ext) |
| 3257 | |
| 3258 | @classmethod |
| 3259 | def global_config(cls, key, *args): |