49 lines
1.9 KiB
Python
49 lines
1.9 KiB
Python
# -*- coding: utf-8 -*-
|
|
"base 'interface' types for option types"
|
|
# Copyright (C) 2012 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
|
|
#
|
|
# The original `Config` design model is unproudly borrowed from
|
|
# the rough gus of pypy: pypy: http://codespeak.net/svn/pypy/dist/pypy/config/
|
|
# the whole pypy projet is under MIT licence
|
|
# ____________________________________________________________
|
|
|
|
class BaseType(object):
|
|
def has_properties(self):
|
|
return bool(len(self.properties))
|
|
|
|
class HiddenBaseType(BaseType):
|
|
def hide(self):
|
|
if not 'hidden' in self.properties:
|
|
self.properties.append('hidden')
|
|
def show(self):
|
|
if 'hidden' in self.properties:
|
|
self.properties.remove('hidden')
|
|
def _is_hidden(self):
|
|
# dangerous method: how an Option() can determine its status by itself ?
|
|
return 'hidden' in self.properties
|
|
|
|
class DisabledBaseType(BaseType):
|
|
def disable(self):
|
|
if not 'disabled' in self.properties:
|
|
self.properties.append('disabled')
|
|
def enable(self):
|
|
if 'disabled' in self.properties:
|
|
self.properties.remove('disabled')
|
|
def _is_disabled(self):
|
|
return 'disabled' in self.properties
|
|
|