mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-25 04:02:46 +01:00
Let's hope this doesn't break anything too serious.
This commit is contained in:
parent
62ff576aaa
commit
6ecf2ae6ea
@ -35,6 +35,7 @@ import supybot.fix as fix
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
import socket
|
import socket
|
||||||
import string
|
import string
|
||||||
|
|
||||||
@ -90,11 +91,13 @@ def registerGroup(Group, name, group=None):
|
|||||||
|
|
||||||
def registerGlobalValue(group, name, value):
|
def registerGlobalValue(group, name, value):
|
||||||
value.channelValue = False
|
value.channelValue = False
|
||||||
|
#value._lastModified = time.time() # So reloads don't change the value.
|
||||||
return group.register(name, value)
|
return group.register(name, value)
|
||||||
|
|
||||||
def registerChannelValue(group, name, value):
|
def registerChannelValue(group, name, value):
|
||||||
value._supplyDefault = True
|
value._supplyDefault = True
|
||||||
value.channelValue = True
|
value.channelValue = True
|
||||||
|
#value._lastModified = time.time() # So reloads don't change the value.
|
||||||
return group.register(name, value)
|
return group.register(name, value)
|
||||||
|
|
||||||
def registerPlugin(name, currentValue=None, public=True):
|
def registerPlugin(name, currentValue=None, public=True):
|
||||||
|
@ -153,12 +153,15 @@ class Group(object):
|
|||||||
class X(OriginalClass):
|
class X(OriginalClass):
|
||||||
"""This class exists to differentiate those values that have
|
"""This class exists to differentiate those values that have
|
||||||
been changed from their default from those that haven't."""
|
been changed from their default from those that haven't."""
|
||||||
def set(self, *args):
|
|
||||||
self.__class__ = OriginalClass
|
|
||||||
self.set(*args)
|
|
||||||
def setValue(self, *args):
|
def setValue(self, *args):
|
||||||
|
comeBack = self._lastModified == 0
|
||||||
|
if not comeBack:
|
||||||
|
print '***', 'Changing %s to its OriginalClass.'%self._name
|
||||||
|
print '******', utils.stackTrace(compact=True)
|
||||||
self.__class__ = OriginalClass
|
self.__class__ = OriginalClass
|
||||||
self.setValue(*args)
|
self.setValue(*args)
|
||||||
|
if comeBack:
|
||||||
|
self.__class__ = X
|
||||||
self.X = X
|
self.X = X
|
||||||
|
|
||||||
def __call__(self):
|
def __call__(self):
|
||||||
@ -172,7 +175,7 @@ class Group(object):
|
|||||||
v = self.__class__(self._default, self.help)
|
v = self.__class__(self._default, self.help)
|
||||||
v.set(s)
|
v.set(s)
|
||||||
v.__class__ = self.X
|
v.__class__ = self.X
|
||||||
#v._supplyDefault = False
|
v._lastModified = time.time()
|
||||||
v.help = '' # Clear this so it doesn't print a bazillion times.
|
v.help = '' # Clear this so it doesn't print a bazillion times.
|
||||||
self.register(attr, v)
|
self.register(attr, v)
|
||||||
return v
|
return v
|
||||||
@ -217,11 +220,13 @@ class Group(object):
|
|||||||
if name in self._children:
|
if name in self._children:
|
||||||
# It's already here, let's copy some stuff over.
|
# It's already here, let's copy some stuff over.
|
||||||
oldNode = self._children[name]
|
oldNode = self._children[name]
|
||||||
|
node._name = oldNode._name
|
||||||
node._added = oldNode._added
|
node._added = oldNode._added
|
||||||
node._children = oldNode._children
|
node._children = oldNode._children
|
||||||
for v in node._children.values():
|
for v in node._children.values():
|
||||||
if v.__class__ is oldNode.X:
|
if v.__class__ is oldNode.X:
|
||||||
v.__class__ = node.X
|
v.__class__ = node.X
|
||||||
|
node._lastModified = oldNode._lastModified
|
||||||
self._children[name] = node
|
self._children[name] = node
|
||||||
if name not in self._added:
|
if name not in self._added:
|
||||||
self._added.append(name)
|
self._added.append(name)
|
||||||
@ -280,9 +285,12 @@ class Value(Group):
|
|||||||
raise InvalidRegistryValue, utils.normalizeWhitespace(s)
|
raise InvalidRegistryValue, utils.normalizeWhitespace(s)
|
||||||
|
|
||||||
def setName(self, *args):
|
def setName(self, *args):
|
||||||
|
# If we're getting our name for the first time, we should definitely
|
||||||
|
# look in the _cache for our value.
|
||||||
if self._name == 'unset':
|
if self._name == 'unset':
|
||||||
self._lastModified = 0
|
self._lastModified = 0
|
||||||
Group.setName(self, *args)
|
Group.setName(self, *args)
|
||||||
|
# Now we can feel safe setting our _lastModified to now.
|
||||||
self._lastModified = time.time()
|
self._lastModified = time.time()
|
||||||
|
|
||||||
def set(self, s):
|
def set(self, s):
|
||||||
|
Loading…
Reference in New Issue
Block a user