diff options
Diffstat (limited to 'portato/db/database.py')
-rw-r--r-- | portato/db/database.py | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/portato/db/database.py b/portato/db/database.py index 7a23e5e..c679d06 100644 --- a/portato/db/database.py +++ b/portato/db/database.py @@ -3,7 +3,7 @@ # File: portato/db/database.py # This file is part of the Portato-Project, a graphical portage-frontend. # -# Copyright (C) 2006-2009 René 'Necoro' Neumann +# Copyright (C) 2006-2010 René 'Necoro' Neumann # This is free software. You may redistribute copies of it under the terms of # the GNU General Public License version 2. # There is NO WARRANTY, to the extent permitted by law. @@ -14,6 +14,12 @@ from __future__ import absolute_import, with_statement from threading import RLock from functools import wraps +from ..helper import warning + +from .exceptions import UnsupportedSearchTypeError + +class UnsupportedSearchTypeError(Exception): + pass class PkgData (object): __slots__ = ("cat", "pkg", "inst", "disabled") @@ -37,8 +43,19 @@ class Database (object): ALL = _("ALL") + SEARCH_NAME = 1 + SEARCH_DESCRIPTION = 2 + + TYPES = { + SEARCH_NAME : _("Name"), + SEARCH_DESCRIPTION : _("Description"), + SEARCH_NAME | SEARCH_DESCRIPTION : "%s + %s" % (_("Name"), _("Description")) + } + + def __init__ (self): self._lock = RLock() + self.type = self.SEARCH_NAME @staticmethod def lock (f): @@ -51,6 +68,24 @@ class Database (object): return wrapper + def search_types (self): + """The types of search supported by the database. + + @return: type + @rtype: int""" + raise NotImplentedError + + def set_type (self, type): + if type & self.search_types() != type: + raise UnsupportedSearchTypeError, type + + self._type = type + + def get_type (self): + return self._type + + type = property(get_type, set_type) + def populate (self, category = None): """Populates the database. |