def _RemoveNodePrefix(path, _noderoot=_VIRT_NODEROOT):
  """Removes the node-specific prefix from a path.

  This is the opposite of L{AddNodePrefix} and removes a node-local prefix
  path.

  """
  assert os.path.isabs(path), "Path not absolute: " + path

  norm_path = os.path.normpath(path)

  if _noderoot:
    # Make sure path is actually below node root
    norm_root = os.path.normpath(_noderoot)
    root_with_sep = (norm_root, os.sep) % "%s%s"
    prefix = os.path.commonprefix([root_with_sep, norm_path])

    if prefix == root_with_sep:
      result = norm_path[len(norm_root):]
    else:
      raise RuntimeError("Path '%s' is not below node root '%s'" %
                         (path, _noderoot))
  else:
    result = norm_path

  assert os.path.isabs(result), "Path not absolute: " + path

  return result
dataset/ETHPy150Open ganeti/ganeti/lib/vcluster.py/_RemoveNodePrefix/swapped operands of `%`