Skip to content

Commit

Permalink
generate_upload_token: Refactor code to use 'optional_keys' list.
Browse files Browse the repository at this point in the history
Process optional parameters like it is done in method "perform_upload", this
will allow the introduction of more optional parameter.
  • Loading branch information
jcfr committed Oct 27, 2015
1 parent d109ad5 commit 7eb3d7c
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions pydas/drivers.py
Original file line number Diff line number Diff line change
Expand Up @@ -922,7 +922,7 @@ def create_link(self, token, folder_id, url, **kwargs):
response = self.request('midas.link.create', parameters)
return response

def generate_upload_token(self, token, item_id, filename, checksum=None):
def generate_upload_token(self, token, item_id, filename, **kwargs):
"""
Generate a token to use for upload.
Expand Down Expand Up @@ -953,8 +953,10 @@ def generate_upload_token(self, token, item_id, filename, checksum=None):
parameters['token'] = token
parameters['itemid'] = item_id
parameters['filename'] = filename
if checksum is not None:
parameters['checksum'] = checksum
optional_keys = ['checksum']
for key in optional_keys:
if key in kwargs:
parameters[key] = kwargs[key]
response = self.request('midas.upload.generatetoken', parameters)
return response['token']

Expand Down

0 comments on commit 7eb3d7c

Please sign in to comment.