+ def __init__(self, url):
+ """Initializes a new storage backend.
+
+ Params:
+ url: The parsed (by urlsplit) URL that specifies the storage
+ location.
+ """
+ pass
+
+ # TODO: Implement context manager.
+
+ def list(self, path):
+ raise NotImplementedError
+
+ def get(self, path):
+ raise NotImplementedError
+
+ def put(self, path, fp):
+ raise NotImplementedError
+
+ def delete(self, path):
+ raise NotImplementedError
+
+ def stat(self, path):
+ raise NotImplementedError
+
+ def scan(self, path):
+ """Cache file information stored in this backend.
+
+ This might make subsequent list or stat calls more efficient, but this
+ function is intended purely as a performance optimization."""
+
+ pass
+
+ def close(self):
+ """Tear down the connection explicitly if needed
+
+ Currently needed for sftp to be able to end the program."""
+
+ pass
+
+ def __del__(self):
+ self.close()
+
+def open(url):
+ """Parse a storage url, then locate and initialize a backend for it."""
+ parsed_url = urlparse.urlsplit(url)