-
Notifications
You must be signed in to change notification settings - Fork 76
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
[SVCS-528] Look for mfr
query param from mfr in v1 provider
#290
Changes from 1 commit
705f866
8947b8f
99cc7d7
96a4eee
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -234,9 +234,16 @@ async def download(self, # type: ignore | |
|
||
metadata = await self.metadata(path, revision=revision) | ||
|
||
if 'mfr' in kwargs and kwargs['mfr'] and kwargs['mfr'].lower() == 'true': | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For dictionaries, we can use the mfr_only = kwargs.get('mfr', None)
if mfr_only and mfr_only.lower() == 'true':
... |
||
download_url = metadata.raw.get('downloadUrl') or drive_utils.get_alt_export_link(metadata.raw), # type: ignore | ||
export_name = metadata.alt_export_name | ||
else: | ||
download_url = metadata.raw.get('downloadUrl') or drive_utils.get_export_link(metadata.raw), # type: ignore | ||
export_name = metadata.export_name # type: ignore | ||
|
||
download_resp = await self.make_request( | ||
'GET', | ||
metadata.raw.get('downloadUrl') or drive_utils.get_export_link(metadata.raw), # type: ignore | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On |
||
*download_url, | ||
range=range, | ||
expects=(200, 206), | ||
throws=exceptions.DownloadError, | ||
|
@@ -251,7 +258,7 @@ async def download(self, # type: ignore | |
if download_resp.headers.get('Content-Type'): | ||
# TODO: Add these properties to base class officially, instead of as one-off | ||
stream.content_type = download_resp.headers['Content-Type'] # type: ignore | ||
stream.name = metadata.export_name # type: ignore | ||
stream.name = export_name # type: ignore | ||
return stream | ||
|
||
async def upload(self, stream, path: wb_path.WaterButlerPath, *args, **kwargs) \ | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ | |
'ext': '.gdoc', | ||
'download_ext': '.docx', | ||
'type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', | ||
'alt_download_ext': '.pdf', | ||
'alt_type': 'application/pdf', | ||
}, | ||
{ | ||
'mime_type': 'application/vnd.google-apps.drawing', | ||
|
@@ -59,6 +61,22 @@ def get_download_extension(metadata): | |
return format['download_ext'] | ||
|
||
|
||
def get_alt_download_extension(metadata): | ||
format = get_format(metadata) | ||
try: | ||
return format['alt_download_ext'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about the following? Please note that metadata_format = get_format(metadata)
return metadata_format.get('alt_download_ext', None) or metadata_format.get('download_ext', None) |
||
except: | ||
return format['download_ext'] | ||
|
||
|
||
def get_alt_export_link(metadata): | ||
format = get_format(metadata) | ||
try: | ||
return metadata['exportLinks'][format['alt_type']] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here is my example, but it looks more complicated than yours. I can't use metadata_format = get_format(metadata)
format_type = metadata_format.get('alt_type', None) or metadata_format.get('type', None)
export_links = metadata.get('exportLinks', None)
if format_type and export_links:
return export_links.get('format_type', None)
return None |
||
except: | ||
return metadata['exportLinks'][format['type']] | ||
|
||
|
||
def get_export_link(metadata): | ||
format = get_format(metadata) | ||
return metadata['exportLinks'][format['type']] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to make this more specific (both method name and the test inside). What is this test trying to do?