You are on page 1of 1

"""Utilities for InaSAFE """ import os import gettext class VerificationError(RuntimeError): """Exception thrown by verify() """ pass def

verify(statement, message=None): """Verification of logical statement similar to assertions Input statement: expression message: error message in case statement evaluates as False Output None Raises VerificationError in case statement evaluates to False """ if bool(statement) is False: raise VerificationError(message) def ugettext(s): """Translation support """ path = os.path.abspath(os.path.join(os.path.dirname(__file__), '..', 'i18n')) if 'LANG' not in os.environ: return s lang = os.environ['LANG'] filename_prefix = 'inasafe' t = gettext.translation(filename_prefix, path, languages=[lang], fallback=True) return t.ugettext(s)

You might also like