mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-26 20:14:20 +01:00
Extra docstrings, and indentation problem fixed.
This commit is contained in:
parent
43e41f4c51
commit
2db658482a
@ -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))
|
||||||
|
Loading…
Reference in New Issue
Block a user