Commits

ajung committed ea7fe28

preliminary dropbox:// opener added

  • Participants
  • Parent commits f9646df

Comments (0)

Files changed (1)

pp/core/fs_dropbox.py

         return DropboxFSWrapper(fs)
     else:
         raise RuntimeError('Unable to get hold of Dropbox access token')
+
+
+from fs.opener import opener
+from fs.opener import Opener
+from fs.opener import OpenerRegistry
+from fs.opener import _parse_credentials
+
+class DropboxOpener(Opener):
+    names = ['dropbox']
+    desc = """Opens a Dropbox directory """
+
+    @classmethod
+    def get_fs(cls, registry, fs_name, fs_name_params, fs_path, writeable, create_dir):
+        
+        url = fs_path
+        if not '://' in url:
+            url = 'dropbox://' + url
+        scheme, url = url.split('://', 1)
+        username, password = url.split('/', 1)[0].split(':')
+        if username and password:
+            return dropboxfs_factory(app_key, app_secret, username, password)
+        raise RuntimeError('No Dropbox credentials found in {}'.format(url))
+        
+opener.add(DropboxOpener)
+print opener.parse('dropbox://yet@gmx.de:foo/dropbox/foo')