Commits

ajung committed ea7fe28

preliminary dropbox:// opener added

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')
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.