diff --git a/gramps/gen/test/user_test.py b/gramps/gen/test/user_test.py deleted file mode 100644 index 5e31fca84..000000000 --- a/gramps/gen/test/user_test.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# -# Gramps - a GTK+/GNOME based genealogy program -# -# Copyright (C) 2013 Vassilii Khachaturov -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -""" Unittest for user.py """ - -import unittest -from .. import user - -class TestUser: - TITLE = "Testing prompt" - MSG = "Choices are hard. Nevertheless, please choose!" - ACCEPT = "To be" - REJECT = "Not to be" - -class TestUser_prompt(unittest.TestCase): - def setUp(self): - self.user = user.User() - - def test_not_implemented(self): - self.assertRaises(NotImplementedError, self.user.prompt, - TestUser.TITLE, - TestUser.MSG, - TestUser.ACCEPT, - TestUser.REJECT) - -if __name__ == "__main__": - unittest.main() diff --git a/gramps/gen/user.py b/gramps/gen/user.py index 2f6ca2baf..c582ec4e7 100644 --- a/gramps/gen/user.py +++ b/gramps/gen/user.py @@ -23,9 +23,10 @@ The User class provides basic interaction with the user. """ import sys +from abc import ABCMeta, abstractmethod from contextlib import contextmanager -class User: +class User(metaclass=ABCMeta): """ This class provides a means to interact with the user in an abstract way. This class should be overridden by each respective user interface to @@ -39,6 +40,7 @@ class User: self.uistate = uistate self.dbstate = dbstate + @abstractmethod def begin_progress(self, title, message, steps): """ Start showing a progress indicator to the user. @@ -55,15 +57,14 @@ class User: :type steps: int :returns: none """ - raise NotImplementedError + @abstractmethod def step_progress(self): """ Advance the progress meter. Don't use this method directly, use progress instead. """ - raise NotImplementedError def callback(self, percentage, text=None): """ @@ -83,13 +84,13 @@ class User: else: self._fileout.write("\r%02d%% %s" % (percentage, text)) + @abstractmethod def end_progress(self): """ Stop showing the progress indicator to the user. Don't use this method directly, use progress instead. """ - raise NotImplementedError # Context-manager wrapper of the begin/step/end_progress above @contextmanager @@ -115,6 +116,7 @@ class User: finally: self.end_progress() + @abstractmethod def prompt(self, title, message, accept_label, reject_label, parent=None, default_label=None): """ @@ -135,8 +137,8 @@ class User: :returns: the user's answer to the question :rtype: bool """ - raise NotImplementedError + @abstractmethod def warn(self, title, warning=""): """ Warn the user. @@ -147,8 +149,8 @@ class User: :type warning: str :returns: none """ - raise NotImplementedError + @abstractmethod def notify_error(self, title, error=""): """ Notify the user of an error. @@ -159,8 +161,8 @@ class User: :type error: str :returns: none """ - raise NotImplementedError + @abstractmethod def notify_db_error(self, error): """ Notify the user of a DB error. @@ -169,10 +171,9 @@ class User: :type error: str :returns: none """ - raise NotImplementedError + @abstractmethod def info(self, msg1, infotext, parent=None, monospaced=False): """ Displays information to the user """ - raise NotImplementedError diff --git a/po/POTFILES.skip b/po/POTFILES.skip index 7e05c5b41..230b70194 100644 --- a/po/POTFILES.skip +++ b/po/POTFILES.skip @@ -20,7 +20,6 @@ gramps/gen/__init__.py gramps/gen/sort.py gramps/gen/soundex.py gramps/gen/updatecallback.py -gramps/gen/user.py gramps/gen/ggettext.py # # gen.datehandler package