gssapi/oids.py
def singleton_set(cls, single_oid):
        """
        Factory function to create a new :class:`OIDSet` with a single member.

        :param single_oid: the OID to use as a member of the new set
        :type single_oid: :class:`OID`
        :returns: an OID set with the OID passed in as the only member
        :rtype: :class:`OIDSet`
        """
        new_set = cls()
        oid_ptr = None
        if isinstance(single_oid, OID):
            oid_ptr = ffi.addressof(single_oid._oid)
        elif isinstance(single_oid, ffi.CData):
            if ffi.typeof(single_oid) == ffi.typeof('gss_OID_desc'):
                oid_ptr = ffi.addressof(single_oid)
            elif ffi.typeof(single_oid) == ffi.typeof('gss_OID'):
                oid_ptr = single_oid
        if oid_ptr is None:
            raise TypeError("Expected a gssapi.oids.OID, got " + str(type(single_oid)))

        minor_status = ffi.new('OM_uint32[1]')
        retval = C.gss_add_oid_set_member(minor_status, oid_ptr, new_set._oid_set)
        if GSS_ERROR(retval):
            raise _exception_for_status(retval, minor_status[0])
        return new_set
def singleton_set(cls, single_oid):
        """
        Factory function to create a new :class:`OIDSet` with a single member.

        :param single_oid: the OID to use as a member of the new set
        :type single_oid: :class:`OID`
        :returns: an OID set with the OID passed in as the only member
        :rtype: :class:`OIDSet`
        """
        new_set = cls()
        oid_ptr = None
        if isinstance(single_oid, OID):
            oid_ptr = ffi.addressof(single_oid._oid)
        elif isinstance(single_oid, ffi.CData):
            if ffi.typeof(single_oid) == ffi.typeof('gss_OID_desc'):
                oid_ptr = ffi.addressof(single_oid)
            elif ffi.typeof(single_oid) == ffi.typeof('gss_OID'):
                oid_ptr = single_oid
        if oid_ptr is None:
            raise TypeError("Expected a gssapi.oids.OID, got " + str(type(single_oid)))

        minor_status = ffi.new('OM_uint32[1]')
        retval = C.gss_add_oid_set_member(minor_status, oid_ptr, new_set._oid_set)
        if GSS_ERROR(retval):
            raise _exception_for_status(retval, minor_status[0])
        return new_set
Factory function to create a new :class:`OIDSet` with a single member.

        :param single_oid: the OID to use as a member of the new set
        :type single_oid: :class:`OID`
        :returns: an OID set with the OID passed in as the only member
        :rtype: :class:`OIDSet`