MCPcopy
hub / github.com/tensorlayer/TensorLayer / exists_or_mkdir

Function exists_or_mkdir

tensorlayer/files/utils.py:2374–2403  ·  view source on GitHub ↗

Check a folder by given name, if not exist, create the folder and return False, if directory exists, return True. Parameters ---------- path : str A folder path. verbose : boolean If True (default), prints results. Returns -------- boolean Tr

(path, verbose=True)

Source from the content-addressed store, hash-verified

2372
2373
2374def exists_or_mkdir(path, verbose=True):
2375 """Check a folder by given name, if not exist, create the folder and return False,
2376 if directory exists, return True.
2377
2378 Parameters
2379 ----------
2380 path : str
2381 A folder path.
2382 verbose : boolean
2383 If True (default), prints results.
2384
2385 Returns
2386 --------
2387 boolean
2388 True if folder already exist, otherwise, returns False and create the folder.
2389
2390 Examples
2391 --------
2392 >>> tl.files.exists_or_mkdir("checkpoints/train")
2393
2394 """
2395 if not os.path.exists(path):
2396 if verbose:
2397 logging.info("[*] creates %s ..." % path)
2398 os.makedirs(path)
2399 return False
2400 else:
2401 if verbose:
2402 logging.info("[!] %s exists ..." % path)
2403 return True
2404
2405
2406def maybe_download_and_extract(filename, working_directory, url_source, extract=False, expected_bytes=None):

Callers 3

load_celebA_datasetFunction · 0.90
load_celebA_datasetFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…