Skip to content

Commit

Permalink
Merge pull request googleapis#73 from megadevx/patch-2
Browse files Browse the repository at this point in the history
Exception handling (ValueError) in getType()
  • Loading branch information
Narcolapser committed Jan 10, 2018
2 parents 4463ff3 + 43d707c commit a0a1599
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions O365/attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Attachment( object ):
a message, simply append it to the message's attachment list (message.attachments).
these are stored locally in base64 encoded strings. You can pass either a byte string or a
base64 encoded string to the appropriate set function to bring your attachment into the
base64 encoded string tot he appropriate set function to bring your attachment into the
instance, which will of course need to happen before it could be mailed.
Methods:
Expand Down Expand Up @@ -69,7 +69,11 @@ def isType(self,typeString):

def getType(self):
'''returns the file extension'''
return self.json['Name'][self.json['Name'].rindex('.'):]
try:
return self.json['Name'][self.json['Name'].rindex('.'):]
except ValueError:
log.debug('No file extension found on file ', self.json['Name'])
return ""

def save(self,location):
'''Save the attachment locally to disk.
Expand Down

0 comments on commit a0a1599

Please sign in to comment.