Note: this post is essentially notes to myself. Feel free to ignore
it.
The spectrum of Python scripts runs from the utterly straightforward
to the truly complex.
A few days ago, as part of the ongoing revision of docstrings, I wrote
the following script. It prints a report, grouped by class name, of
command name, length of docstring, and corresponding function name::
'''print a summary of commands and their docstrings.'''
d = c.commandsDict
# Keys are command names; values are functions
# Group commands by class.
groups = {}
for command in sorted(d.keys()):
f = d.get(command)
key = f.__self__.__class__.__name__ if hasattr(f,'__self__')
else f.__name__
aList = groups.get(key,[])
aList.append((command,f),)
groups[key] = aList
# Print groups.
for group in sorted(groups.keys()):
print('%s...' % (group))
aList = groups.get(group)
for command,f in sorted(aList):
fname = f.__name__ or ''
doc = f.__doc__ or ''
print('%40s:%4s %s' % (command,len(doc),fname))
print('%s commands' % (len(list(d.keys()))))
Here is a short excerpt from the resulting output::
atFile...
check-derived-file: 63 checkDerivedFile
write-at-auto-nodes: 46 writeAtAutoNodes
write-dirty-at-auto-nodes: 52
writeDirtyAtAutoNodes
bufferCommandsClass...
buffer-append-to: 80 appendToBuffer
buffer-kill: 47 killBuffer
etc!
As short and simple as this script is, it took more than an hour to
get it into its present form. The time spent improving and
simplifying this script was not just worthwhile, it was essential.
Without the added work, the presentation of the data would be much
less useful than it is.
The script above is at the extreme easy end of the spectrum. At the
other end of the spectrum lie the type inference machinery used by
pylint and rope.
The point of this post is that I want tdb, the tracing debugger, to
gather data that can be summarized with simple scripts.
Edward
--
You received this message because you are subscribed to the Google Groups
"leo-editor" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/leo-editor?hl=en.