def ref_url_to_path(self, ref_url): """Convert a refUrl to a path, by stripping the share prefix. Used to calculate the <path> from a storage key by inverting get_ref_url(). """ print("/" + compat.unquote(util.lstripstr( ref_url, self.share_path)).lstrip("/")) return "/" + compat.unquote(util.lstripstr( ref_url, self.share_path)).lstrip("/")
def testBasics(self): """Test basic tool functions.""" assert join_uri("/a/b", "c") == "/a/b/c" assert join_uri("/a/b/", "c") == "/a/b/c" assert join_uri("/a/b", "c", "d") == "/a/b/c/d" assert join_uri("a/b", "c", "d") == "a/b/c/d" assert join_uri("/", "c") == "/c" assert join_uri("", "c") == "/c" assert not is_child_uri("/a/b", "/a/") assert not is_child_uri("/a/b", "/a/b") assert not is_child_uri("/a/b", "/a/b/") assert not is_child_uri("/a/b", "/a/bc") assert not is_child_uri("/a/b", "/a/bc/") assert is_child_uri("/a/b", "/a/b/c") assert is_child_uri("/a/b", "/a/b/c") assert not is_equal_or_child_uri("/a/b", "/a/") assert is_equal_or_child_uri("/a/b", "/a/b") assert is_equal_or_child_uri("/a/b", "/a/b/") assert not is_equal_or_child_uri("/a/b", "/a/bc") assert not is_equal_or_child_uri("/a/b", "/a/bc/") assert is_equal_or_child_uri("/a/b", "/a/b/c") assert is_equal_or_child_uri("/a/b", "/a/b/c") assert lstripstr("/dav/a/b", "/dav") == "/a/b" assert lstripstr("/dav/a/b", "/DAV") == "/dav/a/b" assert lstripstr("/dav/a/b", "/DAV", True) == "/a/b" assert pop_path("/a/b/c") == ("a", "/b/c") assert pop_path("/a/b/") == ("a", "/b/") assert pop_path("/a/") == ("a", "/") assert pop_path("/a") == ("a", "/") assert pop_path("/") == ("", "") assert pop_path("") == ("", "") self.assertEqual(shift_path("", "/a/b/c"), ("a", "/a", "/b/c")) self.assertEqual(shift_path("/a", "/b/c"), ("b", "/a/b", "/c")) self.assertEqual(shift_path("/a/b", "/c"), ("c", "/a/b/c", "")) self.assertEqual(shift_path("/a/b/c", "/"), ("", "/a/b/c", "")) self.assertEqual(shift_path("/a/b/c", ""), ("", "/a/b/c", ""))