MCPcopy Index your code
hub / github.com/hyperopt/hyperopt / get_closest_dir

Function get_closest_dir

hyperopt/utils.py:229–242  ·  view source on GitHub ↗

returns the topmost already-existing directory in the given path erasing work-dirs should never progress above this file. Also returns the name of first non-existing dir for use as filename.

(workdir)

Source from the content-addressed store, hash-verified

227
228
229def get_closest_dir(workdir):
230 """
231 returns the topmost already-existing directory in the given path
232 erasing work-dirs should never progress above this file.
233 Also returns the name of first non-existing dir for use as filename.
234 """
235 closest_dir = ""
236 for wdi in path_split_all(workdir):
237 if os.path.isdir(os.path.join(closest_dir, wdi)):
238 closest_dir = os.path.join(closest_dir, wdi)
239 else:
240 break
241 assert closest_dir != workdir
242 return closest_dir, wdi
243
244
245@contextmanager

Callers 2

test_temp_dir_sentinelFunction · 0.90
temp_dirFunction · 0.85

Calls 1

path_split_allFunction · 0.85

Tested by 1

test_temp_dir_sentinelFunction · 0.72