New SettingsAttribute class

This commit is contained in:
Julia Medina 2014-05-22 05:38:31 -03:00
parent 9a4ee20991
commit 1276b12c25
1 changed files with 25 additions and 0 deletions

View File

@ -2,6 +2,31 @@ import json
from . import default_settings
class SettingsAttribute(object):
"""Class for storing data related to settings attributes.
This class is intended for internal usage, you should try Settings class
for settings configuration, not this one.
"""
def __init__(self, value, priority):
self.value = value
self.priority = priority
def set(self, value, priority):
"""Sets value if priority is higher or equal than current priority."""
if priority >= self.priority:
self.value = value
self.priority = priority
def __str__(self):
return "<SettingsAttribute value={self.value!r} " \
"priority={self.priority}>".format(self=self)
__repr__ = __str__
class Settings(object):
def __init__(self, values=None):