Skip to content

Commit

Permalink
Merge pull request O365#465 from l-kotzur/convert_to_pdf_patch
Browse files Browse the repository at this point in the history
Improve convert_to_pdf integration
  • Loading branch information
Alejandro Casanovas authored Jun 5, 2020
2 parents 79c4aec + 2e71909 commit c9b90a6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions O365/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,11 @@ def download(self, to_path=None, name=None, chunk_size='auto',
"or any integer number representing bytes")

params = {}
if convert_to_pdf and Path(name).suffix in ALLOWED_PDF_EXTENSIONS:
params['format'] = 'pdf'
if convert_to_pdf:
if Path(self.name).suffix in ALLOWED_PDF_EXTENSIONS:
params['format'] = 'pdf'
else:
raise ValueError("File is not included in 'ALLOWED_PDF_EXTENSIONS'")

with self.con.get(url, stream=stream, params=params) as response:
if not response:
Expand Down

0 comments on commit c9b90a6

Please sign in to comment.