#!/usr/bin/env python ############################################################################## # # Copyright (c) 2003 Zope Corporation and Contributors. # All Rights Reserved. # # This software is subject to the provisions of the Zope Public License, # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS # FOR A PARTICULAR PURPOSE. # ############################################################################## __version__ = '$Revision: 1.3 $'[11:-2] import ZConfig.loader from ZConfig.info import * import sys, cgi def esc(x): return cgi.escape(str(x)) def dt(x): tn = type(x).__name__ if tn == 'instance': return '%s %s'%(tn, x.__class__.__module__ + '.' + x.__class__.__name__) elif tn == 'class': return '%s %s'%(tn, x.__module__ + '.' + x.__name__) else: return '%s %s'%(tn, x.__name__) class explain: done = [] def __call__(self, st): if st.name in self.done: return self.done.append(st.name) if st.description: print st.description for sub in st.getsubtypenames(): print '
' printContents(None, st.getsubtype(sub)) print '
' explain = explain() def printSchema(schema): print '
' for child in schema: printContents(*child) print '
' def printContents(name, info): if isinstance(info, SectionType): print '
', info.name, ' (%s)
'%dt(info.datatype) print '
' if info.description: print info.description print '
' for sub in info: printContents(*sub) print '
' elif isinstance(info, SectionInfo): st = info.sectiontype if st.isabstract(): print '
', st.name, '', info.name, '
' print '
' if info.description: print info.description explain(st) print '
' else: print '
', info.attribute, info.name, '' print '(%s)
'%dt(info.datatype) print '
' for sub in info.sectiontype: printContents(*sub) print '
' else: print '
',info.name, '', '(%s)'%dt(info.datatype) default = info.getdefault() if isinstance(default, ValueInfo): print '(default: %r)'%esc(default.value) elif default is not None: print '(default: %r)'%esc(default) if info.metadefault: print '(metadefault: %s)' % info.metadefault print '
' if info.description: print '
',info.description,'
' schema = ZConfig.loader.loadSchemaFile(sys.argv[1]) print ''' ''' printSchema(schema) print '' # vim: set filetype=python ts=4 sw=4 et si