From: Ralf Jung Date: Sat, 8 Nov 2014 21:47:54 +0000 (+0100) Subject: use exceptions rather than assertions X-Git-Url: https://git.ralfj.de/zonemaker.git/commitdiff_plain/81b4573994bcaef18aae462cfbf7c5cf542db0ca?ds=sidebyside;hp=45fc3211b0ff4b451d379b89d45f4dc7e070f446 use exceptions rather than assertions --- diff --git a/zonemaker/zone.py b/zonemaker/zone.py index 8e87f6e..435b039 100644 --- a/zonemaker/zone.py +++ b/zonemaker/zone.py @@ -48,9 +48,9 @@ class Zone: NX_TTL = None, A_TTL = None, other_TTL = None, domains = []): self._name = hostname(name) - assert mail.endswith('.'), "Mail must be absolute, end with a dot" + if not mail.endswith('.'): raise Exception("Mail must be absolute, end with a dot") atpos = mail.find('@') - assert atpos >= 0 and atpos < mail.find('.'), "Mail must contain an @ before the first dot" + if atpos < 0 or atpos > mail.find('.'): raise Exception("Mail must contain an @ before the first dot") self._mail = hostname(mail.replace('@', '.', 1)) self._NS = list(map(hostname, NS))