#NEWLINE# def is_permission_in_set( perm , perm_set ) : #NEWLINE# #INDENT# 'Test if a permission is in the given set.\n\n    :param perm: The permission object to check for.\n    :param perm_set: The set to check in. If a ``str``, the permission is\n        checked for equality. If a container, the permission is looked for in\n        the set. If a function, the permission is passed to the "set".\n\n    ' #NEWLINE# if isinstance ( perm_set , basestring ) : #NEWLINE# #INDENT# return ( perm == perm_set ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( perm_set , Container ) : #NEWLINE# #INDENT# return ( perm in perm ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isinstance ( perm_set , Callable ) : #NEWLINE# #INDENT# return perm_set ( perm ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# raise TypeError ( 'permission set must be a string, container, or callable' )