[Zope-Checkins] CVS: Zope3/lib/python/Interface - pyskel.py:1.1.2.4.2.1
Jim Fulton
jim@zope.com
Wed, 20 Mar 2002 17:18:15 -0500
Update of /cvs-repository/Zope3/lib/python/Interface
In directory cvs.zope.org:/tmp/cvs-serv31837
Modified Files:
Tag: Zope3-publisher-refactor-branch
pyskel.py
Log Message:
Added better organization of output:
- Visual dividers between methods by base interface
- Methods are sorted by name within interface.
=== Zope3/lib/python/Interface/pyskel.py 1.1.2.4 => 1.1.2.4.2.1 ===
from Interface.Method import Method
-def rskel(iface):
- name = iface.__name__
- for base in iface.__bases__:
- rskel(base)
+def rskel(iface, print_iface=1):
+ name = "%s.%s" % (iface.__module__, iface.__name__)
+
+ namesAndDescriptions = list(iface.namesAndDescriptions())
+
+ if namesAndDescriptions and print_iface:
+ print
+ print " ######################################"
+ print " # from:", name
- for aname, ades in iface.namesAndDescriptions():
+ # XXX it would be better to keep the original order, but interfaces don't
+ # preserve this, so we'll just sort for now.
+ namesAndDescriptions.sort()
+ for aname, ades in namesAndDescriptions:
if isinstance(ades, Method):
sig = ades.getSignatureString()[1:-1]
if sig: sig = "self, %s" % sig
else: sig = "self"
print
print " def %s(%s):" % (aname, sig)
- print " '''See interface %s'''" % name
+ print " 'See %s'" % name
+
+ for base in iface.__bases__:
+ rskel(base)
def skel(name):
iface = resolve(name)
@@ -59,7 +70,7 @@
print " # Implementation methods for interface"
print " #", name
- rskel(iface)
+ rskel(iface, 0)
print " #"
print " ############################################################"