MCPcopy Index your code
hub / github.com/fluentpython/example-code-2e / search

Method search

21-async/mojifinder/bottle.py:3238–3256  ·  view source on GitHub ↗

Search name in all directories specified in lookup. First without, then with common extensions. Return first hit.

(cls, name, lookup=[])

Source from the content-addressed store, hash-verified

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):

Callers 8

__init__Method · 0.95
searchFunction · 0.45
searchFunction · 0.45
loaderMethod · 0.45
translateMethod · 0.45
read_codeMethod · 0.45
searchFunction · 0.45
expandFunction · 0.45

Calls 1

deprFunction · 0.85

Tested by

no test coverage detected