+ """Parse a storage url, then locate and initialize a backend for it."""
+ parsed_url = urlparse.urlsplit(url)
+
+ # If there is no scheme, fall back to treating the string as local path and
+ # construct a file:/// URL.
+ if not parsed_url.scheme:
+ parsed_url = urlparse.SplitResult("file", "", quote(url), "", "")
+
+ try:
+ # TODO: Support a registry for schemes that don't map to a module.
+ if re.match(r"^\w+$", parsed_url.scheme):
+ handler = importlib.import_module("cumulus.store.%s" %
+ parsed_url.scheme)
+ obj = handler.Store(parsed_url)
+ return obj
+ except ImportError:
+ # Fall through to error below
+ pass
+
+ raise NotImplementedError("Scheme %s not implemented" % scheme)