def get_fd_trash_dir(path): """Returns the right trash directory for the given path.""" path = abspath(path) mount = find_mount_point(path) xdg_data_home = xdg_get_data_home() xdg_mount = find_mount_point(xdg_data_home) if mount == xdg_mount: trash_home = join(xdg_data_home, "Trash") return trash_home else: root = join(mount, ".Trash") uid = str(os.getuid()) if isdir(root) and not islink(root) and is_sticky(root): root = join(root, uid) else: root = join(mount, ".Trash-" + uid) return root
def test_data_home(self): os.environ["XDG_DATA_HOME"] = "/xyz" self.failUnlessEqual(util.xdg_get_data_home(), "/xyz") del os.environ["XDG_DATA_HOME"] should = os.path.join(os.path.expanduser("~"), ".local", "share") self.failUnlessEqual(util.xdg_get_data_home(), should)