Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Dropbox root_namespace_id for Team Spaces #3316

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions luigi/contrib/dropbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@
Dropbox client for authentication, designed to be used by the :py:class:`DropboxTarget` class.
"""

def __init__(self, token, user_agent="Luigi"):
def __init__(self, token, user_agent="Luigi", root_namespace_id=None):

Check warning on line 71 in luigi/contrib/dropbox.py

View check run for this annotation

Codecov / codecov/patch

luigi/contrib/dropbox.py#L71

Added line #L71 was not covered by tests
"""
:param str token: Dropbox Oauth2 Token. See :class:`DropboxTarget` for more information about generating a token
:param str root_namespace_id: Root namespace ID for interacting with Team Spaces
"""
if not token:
raise ValueError("The token parameter must contain a valid Dropbox Oauth2 Token")
Expand All @@ -80,6 +81,9 @@
except Exception as e:
raise Exception("Cannot connect to Dropbox. Check your Internet connection and the token. \n" + repr(e))

if root_namespace_id:
conn = conn.with_path_root(dropbox.common.PathRoot.root(root_namespace_id))

Check warning on line 85 in luigi/contrib/dropbox.py

View check run for this annotation

Codecov / codecov/patch

luigi/contrib/dropbox.py#L84-L85

Added lines #L84 - L85 were not covered by tests

self.token = token
self.conn = conn

Expand Down Expand Up @@ -257,7 +261,7 @@
A Dropbox filesystem target.
"""

def __init__(self, path, token, format=None, user_agent="Luigi"):
def __init__(self, path, token, format=None, user_agent="Luigi", root_namespace_id=None):

Check warning on line 264 in luigi/contrib/dropbox.py

View check run for this annotation

Codecov / codecov/patch

luigi/contrib/dropbox.py#L264

Added line #L264 was not covered by tests
"""
Create an Dropbox Target for storing data in a dropbox.com account

Expand Down Expand Up @@ -285,6 +289,7 @@
:param str path: Remote path in Dropbox (starting with '/').
:param str token: a valid OAuth2 Dropbox token.
:param luigi.Format format: the luigi format to use (e.g. `luigi.format.Nop`)
:param str root_namespace_id: Root namespace ID for interacting with Team Spaces


"""
Expand All @@ -295,7 +300,7 @@

self.path = path
self.token = token
self.client = DropboxClient(token, user_agent)
self.client = DropboxClient(token, user_agent, root_namespace_id)

Check warning on line 303 in luigi/contrib/dropbox.py

View check run for this annotation

Codecov / codecov/patch

luigi/contrib/dropbox.py#L303

Added line #L303 was not covered by tests
self.format = format or luigi.format.get_default_format()

def __str__(self):
Expand Down
Loading