From 8ad5502354a364db606b72455c5514cb56e918ba Mon Sep 17 00:00:00 2001 From: Jason Gerard DeRose Date: Thu, 13 Nov 2008 21:07:47 -0700 Subject: Added util.make_repr() function; added corresponding unit tests --- ipalib/frontend.py | 1 + ipalib/util.py | 9 +++++++++ 2 files changed, 10 insertions(+) (limited to 'ipalib') diff --git a/ipalib/frontend.py b/ipalib/frontend.py index 56c4ea01f..87126a440 100644 --- a/ipalib/frontend.py +++ b/ipalib/frontend.py @@ -227,6 +227,7 @@ class Param(plugable.ReadOnly): ) def __init__(self, name, **override): + self.__override = override if not ('required' in override or 'multivalue' in override): (name, kw_from_spec) = parse_param_spec(name) override.update(kw_from_spec) diff --git a/ipalib/util.py b/ipalib/util.py index 9bc432545..89e2c5a74 100644 --- a/ipalib/util.py +++ b/ipalib/util.py @@ -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)) -- cgit