Updated to include strings in @objects output.

This commit is contained in:
Jeremy Fincher 2003-11-25 08:20:41 +00:00
parent 4e273a2395
commit 6ce845f8d3

View File

@ -33,6 +33,8 @@
Provides a multitude of fun, useless commands. Provides a multitude of fun, useless commands.
""" """
__revision__ = "$Id$"
import plugins import plugins
import gc import gc
@ -400,12 +402,15 @@ class Fun(callbacks.Privmsg):
classes = 0 classes = 0
functions = 0 functions = 0
modules = 0 modules = 0
strings = 0
dicts = 0 dicts = 0
lists = 0 lists = 0
tuples = 0 tuples = 0
refcounts = 0 refcounts = 0
objs = gc.get_objects() objs = gc.get_objects()
for obj in objs: for obj in objs:
if isinstance(obj, str):
strings += 1
if isinstance(obj, tuple): if isinstance(obj, tuple):
tuples += 1 tuples += 1
elif inspect.isroutine(obj): elif inspect.isroutine(obj):
@ -420,10 +425,11 @@ class Fun(callbacks.Privmsg):
modules += 1 modules += 1
refcounts += sys.getrefcount(obj) refcounts += sys.getrefcount(obj)
response = 'I have %s objects: %s modules, %s classes, %s functions, '\ response = 'I have %s objects: %s modules, %s classes, %s functions, '\
'%s dictionaries, %s lists, and %s tuples (and a few other'\ '%s dictionaries, %s lists, %s tuples, %s strings, and a ' \
' different types). I have a total of %s references.' %\ 'few other odds and ends. ' \
'I have a total of %s references.' %\
(len(objs), modules, classes, functions, (len(objs), modules, classes, functions,
dicts, lists, tuples, refcounts) dicts, lists, tuples, strings, refcounts)
irc.reply(msg, response) irc.reply(msg, response)
def levenshtein(self, irc, msg, args): def levenshtein(self, irc, msg, args):