Unverified Commit 3827ccb5 by hlu1 Committed by GitHub

[Python] Replace os.path.exists with try...except...else (#4784)

parent 9c383f64
......@@ -40,8 +40,12 @@ class Cache(object):
cache_by_key = {}
def __init__(self, key, save_at_exit):
cache_dir = ".pkl_memoize_py{0}".format(sys.version_info[0])
if not os.path.exists(cache_dir):
try:
os.mkdir(cache_dir)
except FileExistsError:
pass
else:
self.cache = {}
self.path = os.path.join(cache_dir, key)
if os.path.exists(self.path):
try:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment