def _attributes(self): """ Return all available attributes as dictionary. The dictionary includes all class and instance attributes. """ return attributes(self)
def _format(self, template, recursive=0): """ Format the text template using the namespace contents. template must be a text using Python string placeholders, e.g. "%(attrname)s" or "%(attrname)r". Formatting is done using all available attributes of the namespace (including class attributes). If recursive is true, the formatting is applied recursively (as long as the string '%(' occurs in the template), i.e. the Namespace attributes may also contain Python string placeholders. """ if not recursive: return template % attributes(self) dict = attributes(self) while template.find('%(') >= 0: template = template % dict return template