I'm writing a script where I need to try to apply several parsing method on an email. So if the first one succeeded there's no need to try the other ones. Until now I have only 2 parsing method but it's possible that I'll add many more. If possible I would like to replicate something like a switch case (that don't exist in 2.7). Is there a better than what I'm doing?
try:
found['PhishMe_Informations']=self.parse_phishme(message)
except MalformedPhishMeMailError as e:
self.log.error(e[0])
found['PhishMe_Informations']=e[1]
found['PhishMe_Informations']['Malformed']=True
except Exception:
try:
found['Journaling_Informations']=self.parse_journaling(message)
except MalformedRecordMessageError as e:
self.log.error(e)
except Exception:
pass