mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-27 13:19:24 +01:00
Reordred some more, changed the default of prefixChars, and fixed some older-written values.
This commit is contained in:
parent
e853325a42
commit
27b24e142a
23
src/conf.py
23
src/conf.py
@ -114,14 +114,13 @@ supybot.register('channels', SpaceSeparatedListOfChannels(['#supybot'], """
|
|||||||
Determines what channels the bot will join when it connects to the server."""))
|
Determines what channels the bot will join when it connects to the server."""))
|
||||||
|
|
||||||
class ValidPrefixChars(registry.String):
|
class ValidPrefixChars(registry.String):
|
||||||
def set(self, s):
|
def setValue(self, v):
|
||||||
registry.String.set(self, s)
|
if v.translate(string.ascii, '`~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?'):
|
||||||
if self.value.translate(string.ascii,
|
|
||||||
'`~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?'):
|
|
||||||
raise registry.InvalidRegistryValue, \
|
raise registry.InvalidRegistryValue, \
|
||||||
'Value must contain only ~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?'
|
'Value must contain only ~!@#$%^&*()_-+=[{}]\\|\'";:,<.>/?'
|
||||||
|
registry.String.setValue(self, v)
|
||||||
|
|
||||||
supybot.register('prefixChars', ValidPrefixChars('@', """Determines what prefix
|
supybot.register('prefixChars', ValidPrefixChars('', """Determines what prefix
|
||||||
characters the bot will reply to. A prefix character is a single character
|
characters the bot will reply to. A prefix character is a single character
|
||||||
that the bot will use to determine what messages are addressed to it; when
|
that the bot will use to determine what messages are addressed to it; when
|
||||||
there are no prefix characters set, it just uses its nick."""))
|
there are no prefix characters set, it just uses its nick."""))
|
||||||
@ -361,20 +360,12 @@ supybot.drivers.register('poll', registry.Float(1.0, """Determines the default
|
|||||||
length of time a driver should block waiting for input."""))
|
length of time a driver should block waiting for input."""))
|
||||||
|
|
||||||
class ValidDriverModule(registry.String):
|
class ValidDriverModule(registry.String):
|
||||||
def set(self, s):
|
def setValue(self, v):
|
||||||
original = getattr(self, 'value', self.default)
|
if v not in ('socketDrivers', 'twistedDrivers', 'asyncoreDrivers'):
|
||||||
registry.String.set(self, s)
|
|
||||||
if self.value not in ('socketDrivers',
|
|
||||||
'twistedDrivers',
|
|
||||||
'asyncoreDrivers'):
|
|
||||||
self.value = original
|
|
||||||
raise registry.InvalidRegistryValue, \
|
raise registry.InvalidRegistryValue, \
|
||||||
'Value must be one of "socketDrivers", "asyncoreDrivers", ' \
|
'Value must be one of "socketDrivers", "asyncoreDrivers", ' \
|
||||||
'or twistedDrivers.'
|
'or twistedDrivers.'
|
||||||
else:
|
registry.String.setValue(self, v)
|
||||||
# TODO: check to make sure Twisted is available if it's set to
|
|
||||||
# twistedDrivers.
|
|
||||||
pass
|
|
||||||
|
|
||||||
supybot.drivers.register('module', ValidDriverModule('socketDrivers', """
|
supybot.drivers.register('module', ValidDriverModule('socketDrivers', """
|
||||||
Determines what driver module the bot will use. socketDrivers, a simple
|
Determines what driver module the bot will use. socketDrivers, a simple
|
||||||
|
23
src/log.py
23
src/log.py
@ -36,7 +36,6 @@ import fix
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import cgitb
|
|
||||||
import types
|
import types
|
||||||
import atexit
|
import atexit
|
||||||
import logging
|
import logging
|
||||||
@ -57,15 +56,6 @@ class Formatter(logging.Formatter):
|
|||||||
for exn in deadlyExceptions:
|
for exn in deadlyExceptions:
|
||||||
if issubclass(e.__class__, exn):
|
if issubclass(e.__class__, exn):
|
||||||
raise
|
raise
|
||||||
if conf.supybot.log.detailedTracebacks():
|
|
||||||
try:
|
|
||||||
# Cgitb has bugs, and they break the bot.
|
|
||||||
#return cgitb.text((E, e, tb)).rstrip('\r\n')
|
|
||||||
return logging.Formatter.formatException(self, (E, e, tb))
|
|
||||||
except:
|
|
||||||
error('Cgitb.text raised an exception.')
|
|
||||||
return logging.Formatter.formatException(self, (E, e, tb))
|
|
||||||
else:
|
|
||||||
return logging.Formatter.formatException(self, (E, e, tb))
|
return logging.Formatter.formatException(self, (E, e, tb))
|
||||||
|
|
||||||
|
|
||||||
@ -198,15 +188,6 @@ conf.supybot.log.register('level', LogLevel(logging.INFO,
|
|||||||
"""Determines what the minimum priority level logged will be. Valid values are
|
"""Determines what the minimum priority level logged will be. Valid values are
|
||||||
DEBUG, INFO, WARNING, ERROR, and CRITICAL, in order of increasing
|
DEBUG, INFO, WARNING, ERROR, and CRITICAL, in order of increasing
|
||||||
priority."""))
|
priority."""))
|
||||||
conf.supybot.log.register('timestampFormat',
|
|
||||||
registry.String('[%d-%b-%Y %H:%M:%S]',
|
|
||||||
"""Determines the format string for timestamps in logfiles. Refer to the
|
|
||||||
Python documentation for the time module to see what formats are accepted."""))
|
|
||||||
conf.supybot.log.register('detailedTracebacks', registry.Boolean(True, """
|
|
||||||
Determines whether highly detailed tracebacks will be logged. While more
|
|
||||||
informative (and thus more useful for debugging) they also take a significantly
|
|
||||||
greater amount of space in the logs. Hopefully, however, such uncaught
|
|
||||||
exceptions aren't very common."""))
|
|
||||||
conf.supybot.log.register('stdout',
|
conf.supybot.log.register('stdout',
|
||||||
registry.Boolean(True, """Determines whether the bot will log to
|
registry.Boolean(True, """Determines whether the bot will log to
|
||||||
stdout."""))
|
stdout."""))
|
||||||
@ -221,6 +202,10 @@ conf.supybot.log.stdout.register('colorized',
|
|||||||
BooleanRequiredFalseOnWindows(False, """Determines whether the bot's logs to
|
BooleanRequiredFalseOnWindows(False, """Determines whether the bot's logs to
|
||||||
stdout (if enabled) will be colorized with ANSI color."""))
|
stdout (if enabled) will be colorized with ANSI color."""))
|
||||||
|
|
||||||
|
conf.supybot.log.register('timestampFormat',
|
||||||
|
registry.String('[%d-%b-%Y %H:%M:%S]',
|
||||||
|
"""Determines the format string for timestamps in logfiles. Refer to the
|
||||||
|
Python documentation for the time module to see what formats are accepted."""))
|
||||||
if not os.path.exists(conf.supybot.directories.log()):
|
if not os.path.exists(conf.supybot.directories.log()):
|
||||||
os.mkdir(conf.supybot.directories.log(), 0755)
|
os.mkdir(conf.supybot.directories.log(), 0755)
|
||||||
|
|
||||||
|
@ -283,7 +283,7 @@ class String(Value):
|
|||||||
v = utils.safeEval(s)
|
v = utils.safeEval(s)
|
||||||
if not isinstance(v, basestring):
|
if not isinstance(v, basestring):
|
||||||
raise ValueError
|
raise ValueError
|
||||||
self.value = v
|
self.setValue(v)
|
||||||
except ValueError: # This catches utils.safeEval(s) errors too.
|
except ValueError: # This catches utils.safeEval(s) errors too.
|
||||||
raise InvalidRegistryValue, '%r is not a string.' % s
|
raise InvalidRegistryValue, '%r is not a string.' % s
|
||||||
|
|
||||||
@ -319,8 +319,9 @@ class Regexp(Value):
|
|||||||
try:
|
try:
|
||||||
if s:
|
if s:
|
||||||
self.value = utils.perlReToPythonRe(s)
|
self.value = utils.perlReToPythonRe(s)
|
||||||
|
self._lastModified = time.time()
|
||||||
else:
|
else:
|
||||||
self.value = None
|
self.setValue(None)
|
||||||
self.sr = s
|
self.sr = s
|
||||||
except ValueError, e:
|
except ValueError, e:
|
||||||
raise InvalidRegistryValue, '%r is not a valid regexp: %s' % (s, e)
|
raise InvalidRegistryValue, '%r is not a valid regexp: %s' % (s, e)
|
||||||
@ -328,7 +329,7 @@ class Regexp(Value):
|
|||||||
def setValue(self, v):
|
def setValue(self, v):
|
||||||
if v is None:
|
if v is None:
|
||||||
self.sr = ''
|
self.sr = ''
|
||||||
self.value = None
|
Value.setValue(self, None)
|
||||||
else:
|
else:
|
||||||
raise InvalidRegistryValue, \
|
raise InvalidRegistryValue, \
|
||||||
'Can\'t set to a regexp, there would be an inconsistency ' \
|
'Can\'t set to a regexp, there would be an inconsistency ' \
|
||||||
|
Loading…
Reference in New Issue
Block a user