All pastes #178467 Raw Edit

Untitled

public python v1 · immutable
#178467 ·published 2006-09-21 09:54 UTC
rendered paste body
class Checker:#{{{	'''		Superclass for validating attributes passed to methods		Status: TESTED	'''	def _check_type(self, attribute, attribute_type):#{{{		'''			Validation method			Input:			attribute - (unknown) attribute to validate			attribute_type - (unknown) correct type			Status: TESTED		'''		if attribute == None:			return		if not isinstance(attribute, attribute_type):			_correct = repr(attribute_type.__name__)			if type(attribute) == types.InstanceType:				_passed = 'Instance of \'%s\'' % (attribute.__class__.__name__)			else:				_passed = repr(type(attribute))			if type(attribute_type) == types.ClassType:				_correct = 'instance of %s' % ( _correct)			_reason = '%s passed instead of %s' %\				(_passed, _correct)			raise InvalidArgumentTypeException(_reason)	#}}}#}}}