def _ValidateString(value, name='unused', max_len=_MAXIMUM_STRING_LENGTH, empty_ok=False, type_exception=TypeError, value_exception=ValueError):
 if ((value is None) and empty_ok):
  return
 if ((value is not None) and (not isinstance(value, basestring))):
  raise type_exception(('%s must be a basestring; got %s:' % (name, value.__class__.__name__)))
 if ((not value) and (not empty_ok)):
  raise value_exception(('%s must not be empty.' % name))
 if (len(value.encode('utf-8')) > max_len):
  raise value_exception(('%s must be under %d bytes.' % (name, max_len)))
 return value

def _ValidateString ( value , name = 'unused' , max_len = _MAXIMUM_STRING_LENGTH , empty_ok = False , type_exception = TypeError , value_exception = ValueError ) : if ( ( value is None ) and empty_ok ) : return if ( ( value is not None ) and ( not isinstance ( value , basestring ) ) ) : raise type_exception ( ( '%s must be a basestring; got %s:' % ( name , value . __class__ . __name__ ) ) ) if ( ( not value ) and ( not empty_ok ) ) : raise value_exception ( ( '%s must not be empty.' % name ) ) if ( len ( value . encode ( 'utf-8' ) ) > max_len ) : raise value_exception ( ( '%s must be under %d bytes.' % ( name , max_len ) ) ) return value
raises an exception if value is not a valid string or a subclass thereof .