phenny/tools.py

45 lines
1000 B
Python
Raw Permalink Normal View History

2012-12-16 17:09:43 -05:00
#!/usr/bin/env python3
"""
tools.py - Phenny Tools
Copyright 2008, Sean B. Palmer, inamidst.com
Licensed under the Eiffel Forum License 2.
http://inamidst.com/phenny/
"""
def decorate(obj, delegate):
class Decorator(object):
def __getattr__(self, attr):
if attr in delegate:
return delegate[attr]
return getattr(obj, attr)
def __setattr__(self, attr, value):
return setattr(obj, attr, value)
return Decorator()
class GrumbleError(Exception):
pass
def deprecated(old):
2012-06-02 01:33:13 -04:00
def new(phenny, input, old=old):
self = phenny
origin = type('Origin', (object,), {
'sender': input.sender,
'nick': input.nick
})()
match = input.match
args = [input.bytes, input.sender, '@@']
2012-06-02 01:33:13 -04:00
old(self, origin, match, args)
new.__module__ = old.__module__
new.__name__ = old.__name__
return new
if __name__ == '__main__':
2012-06-02 01:33:13 -04:00
print(__doc__.strip())