62 lines
2.1 KiB
Python
62 lines
2.1 KiB
Python
# -*- coding: utf-8 -*-
|
|
"default plugin for setting: set it in a simple dictionary"
|
|
# Copyright (C) 2013 Team tiramisu (see AUTHORS for all contributors)
|
|
#
|
|
# 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
#
|
|
# ____________________________________________________________
|
|
from ..cache import Cache
|
|
|
|
|
|
class Settings(Cache):
|
|
__slots__ = ('_properties', '_permissives')
|
|
|
|
def __init__(self, storage):
|
|
# properties attribute: the name of a property enables this property
|
|
# key is None for global properties
|
|
self._properties = {}
|
|
# permissive properties
|
|
self._permissives = {}
|
|
super(Settings, self).__init__(storage)
|
|
|
|
# propertives
|
|
def setproperties(self, path, properties):
|
|
self._properties[path] = properties
|
|
|
|
def getproperties(self, path, default_properties):
|
|
return self._properties.get(path, set(default_properties))
|
|
|
|
def hasproperties(self, path):
|
|
return path in self._properties
|
|
|
|
def reset_all_propertives(self):
|
|
self._properties.clear()
|
|
|
|
def reset_properties(self, path):
|
|
try:
|
|
del(self._properties[path])
|
|
except KeyError:
|
|
pass
|
|
|
|
def get_properties(self, context):
|
|
return self._properties
|
|
|
|
# permissive
|
|
def setpermissive(self, path, permissive):
|
|
self._permissives[path] = frozenset(permissive)
|
|
|
|
def getpermissive(self, path=None):
|
|
return self._permissives.get(path, frozenset())
|