<reponame>bio-hpc/metascreener<gh_stars>1-10
#!/usr/bin/env python
# $Revision: 1.1.1.12 $ $Date: 2007/01/08 14:43:56 $ kgm
"""Lister 1.8
Pretty-printer for SimPy class objects
"""
__version__ = '1.8 $Revision: 1.1.1.12 $ $Date: 2007/01/08 14:43:56 $'

class Lister(object):
    indent=0
    def __str__(self):
        Lister.indent+=1
        result= ("<Instance of %s, id %s:\n%s"%(self.__class__.__name__,
                                               id(self),self.attrnames()))+"\t"*(Lister.indent-1)+">"
        Lister.indent-=1
        return result
    
    def attrnames(self):
        result=''
        for attr in self.__dict__.keys():
            if attr[:2] == "__": #builtin
                pass
            elif attr[0]=="_": #private
                pass
            else:
                result=result+"\t"*Lister.indent+".%s=%s\n" %(attr,self.__dict__[attr])
        return result
    def __repr__(self):
        Lister.indent+=1
        result= ("<Instance of %s, id %s:\n%s"%(self.__class__.__name__,
                                               id(self),self.attrnames()))+"\t"*(Lister.indent-1)+">"
        Lister.indent-=1
        return result

