def _get_storage_path(path, app_id):
 (_, _, app_id) = app_id.replace(':', '_').rpartition('~')
 if (path is None):
  for path in _generate_storage_paths(app_id):
   try:
    os.mkdir(path, 448)
   except OSError as e:
    if (e.errno == errno.EEXIST):
     if ((sys.platform == 'win32') or (((os.stat(path).st_mode & 511) == 448) and os.path.isdir(path))):
      return path
     else:
      continue
    raise
   else:
    return path
 elif (not os.path.exists(path)):
  os.mkdir(path)
  return path
 elif (not os.path.isdir(path)):
  raise IOError(('the given storage path %r is a file, a directory was expected' % path))
 else:
  return path

def _get_storage_path ( path , app_id ) : ( _ , _ , app_id ) = app_id . replace ( ':' , '_' ) . rpartition ( '~' ) if ( path is None ) : for path in _generate_storage_paths ( app_id ) : try : os . mkdir ( path , 448 ) except OSError as e : if ( e . errno == errno . EEXIST ) : if ( ( sys . platform == 'win32' ) or ( ( ( os . stat ( path ) . st_mode & 511 ) == 448 ) and os . path . isdir ( path ) ) ) : return path else : continue raise else : return path elif ( not os . path . exists ( path ) ) : os . mkdir ( path ) return path elif ( not os . path . isdir ( path ) ) : raise IOError ( ( 'the given storage path %r is a file, a directory was expected' % path ) ) else : return path
returns a path to the directory where stub data can be stored .