2012-12-16 17:09:43 -05:00
|
|
|
#!/usr/bin/env python3
|
2008-02-21 07:06:33 -05:00
|
|
|
"""
|
|
|
|
tools.py - Phenny Tools
|
|
|
|
Copyright 2008, Sean B. Palmer, inamidst.com
|
|
|
|
Licensed under the Eiffel Forum License 2.
|
|
|
|
|
|
|
|
http://inamidst.com/phenny/
|
|
|
|
"""
|
|
|
|
|
2012-06-02 01:17:09 -04:00
|
|
|
|
2018-03-14 13:31:10 -04:00
|
|
|
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()
|
|
|
|
|
2012-06-02 01:17:09 -04:00
|
|
|
class GrumbleError(Exception):
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
2008-02-21 07:06:33 -05:00
|
|
|
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, '@@']
|
2008-02-21 07:06:33 -05:00
|
|
|
|
2012-06-02 01:33:13 -04:00
|
|
|
old(self, origin, match, args)
|
|
|
|
new.__module__ = old.__module__
|
|
|
|
new.__name__ = old.__name__
|
|
|
|
return new
|
2008-02-21 07:06:33 -05:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
2012-06-02 01:33:13 -04:00
|
|
|
print(__doc__.strip())
|