Extra docstrings, and indentation problem fixed.

This commit is contained in:
Jeremy Fincher 2003-10-04 12:36:48 +00:00
parent 43e41f4c51
commit 2db658482a

View File

@ -254,6 +254,11 @@ def mircColor(s, fg=None, bg=None):
return '\x03%s,%s%s\x0F' % (fg, bg, s) return '\x03%s,%s%s\x0F' % (fg, bg, s)
def canonicalColor(s, bg=False, shift=0): def canonicalColor(s, bg=False, shift=0):
"""Assigns an (fg, bg) canonical color pair to a string based on its hash
value. This means it might change between Python versions. This pair can
be used as a *parameter to mircColor. The shift parameter is how much to
right-shift the hash value initially.
"""
h = hash(s) >> shift h = hash(s) >> shift
fg = h % 14 + 2 # The + 2 is to rule out black and white. fg = h % 14 + 2 # The + 2 is to rule out black and white.
if bg: if bg:
@ -349,6 +354,7 @@ class IrcDict(dict):
dict.__delitem__(self, IrcString(s)) dict.__delitem__(self, IrcString(s))
class IrcSet(sets.Set): class IrcSet(sets.Set):
"""A sets.Set using IrcStrings instead of regular strings."""
__slots__ = () __slots__ = ()
def add(self, s): def add(self, s):
return sets.Set.add(self, IrcString(s)) return sets.Set.add(self, IrcString(s))