Added util.make_repr() function; added corresponding unit tests

This commit is contained in:
Jason Gerard DeRose
2008-11-13 21:07:47 -07:00
parent 01a7f1f437
commit 8ad5502354
3 changed files with 24 additions and 2 deletions

View File

@@ -137,3 +137,12 @@ class LogFormatter(logging.Formatter):
Log formatter that uses UTC for all timestamps.
"""
converter = time.gmtime
def make_repr(name, *args, **kw):
"""
Construct a standard representation of a class instance.
"""
args = [repr(a) for a in args]
kw = ['%s=%r' % (k, kw[k]) for k in sorted(kw)]
return '%s(%s)' % (name, ', '.join(args + kw))