def ensure_dir_exists(path, mode=493):
 if (not os.path.exists(path)):
  try:
   os.makedirs(path, mode=mode)
  except OSError as e:
   if (e.errno != errno.EEXIST):
    raise
 elif (not os.path.isdir(path)):
  raise IOError(('%r exists but is not a directory' % path))

def ensure_dir_exists ( path , mode = 493 ) : if ( not os . path . exists ( path ) ) : try : os . makedirs ( path , mode = mode ) except OSError as e : if ( e . errno != errno . EEXIST ) : raise elif ( not os . path . isdir ( path ) ) : raise IOError ( ( '%r exists but is not a directory' % path ) )
ensure that a directory exists if it doesnt exist .