def _derive_scope_and_key(key, user, scope=None):
    """
    :param user: Name of the user.
    :type user: ``str``
    """
    if user and not isinstance(user, six.string_types):
        raise TypeError('"user" needs to be a string')

    if scope is not None:
        return scope, key

    if key.startswith("system."):
        return FULL_SYSTEM_SCOPE, key[key.index(".") + 1 :]

    return FULL_USER_SCOPE, "%s:%s" % (user, key)

    :param user: Name of the user.
    :type user: ``str``
    
st2common/st2common/util/keyvalue.py