# Copyright (c) 2024 Riverbank Computing Limited <info@riverbankcomputing.com>
# 
# This file is part of PyQt6.
# 
# This software is licensed for use under the terms of the Riverbank Commercial
# License.  See the file LICENSE for more details.  It is supplied WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.


class UserException(Exception):
    """ Encapsulate an exception ultimate caused by the user. """

    pass


class User:
    """ A mixin that provides methods for communicating with the user. """

    def __init__(self, verbose, **kwargs):
        """ Initialise the object. """

        super().__init__(**kwargs)

        self._verbose = verbose

    @staticmethod
    def pretty(text):
        """ Returns a pretty-fied version of some text suitable for displaying
        to the user.
        """

        return text.replace('\n', '\\n')

    def progress(self, message):
        """ Display a progress message. """

        if self._verbose:
            print(message)
