#NEWLINE# def _toset( thing ) : #NEWLINE# #INDENT# 'helper to convert various things to a set\n\n    This enables flexibility in what users provide as the list of LDAP\n    entry attribute values.  Note that the LDAP spec prohibits\n    duplicate values in an attribute and that the order is\n    unspecified, so a set is good for automatically removing\n    duplicates.\n\n    None becomes an empty set.  Iterables except for strings have\n    their elements added to a new set.  Non-None scalars (strings,\n    numbers, non-iterable objects, etc.) are added as the only member\n    of a new set.\n\n    ' #NEWLINE# if ( thing is None ) : #NEWLINE# #INDENT# return set ( ) #NEWLINE# #UNINDENT# if isinstance ( thing , six . string_types ) : #NEWLINE# #INDENT# return set ( ( thing , ) ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# return set ( ( str ( x ) for x in thing ) ) #NEWLINE# #UNINDENT# except TypeError : #NEWLINE# #INDENT# return set ( ( str ( thing ) , ) )