Restructure the packages, change importing style to from ... import.

This commit is contained in:
Mike Auty
2013-05-04 15:44:59 +01:00
parent e654391e86
commit dc65c356fc
11 changed files with 219 additions and 109 deletions
+21
View File
@@ -0,0 +1,21 @@
'''
Created on 4 May 2013
@author: mike
'''
class ValidityRoutines(object):
"""Class to hold all validation routines, such as type checking"""
def type_check(self, value, valid_type):
"""Checks that value is an instance of valid_type, and returns value if it is, or throws a TypeError otherwise"""
if not isinstance(value, valid_type):
raise TypeError(self.__class__.__name__ + " expected " + valid_type.__class__.__name__ + ", not " + type(value))
return value
def confirm(self, assertion, error):
"""Acts like an assertion, but will not be disabled when __debug__ is disabled"""
if not assertion:
if error is None:
error = "An unspecified Assertion was not met"
raise AssertionError(error)