From 77a15740cbbc8bbb49c62c84cf4c6af99acb5b99 Mon Sep 17 00:00:00 2001 From: wirawan Date: Wed, 31 Aug 2011 18:25:07 +0000 Subject: [PATCH] * New module wpylib.debugging: Debugging tools. --- debugging.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 debugging.py diff --git a/debugging.py b/debugging.py new file mode 100644 index 0000000..4cce012 --- /dev/null +++ b/debugging.py @@ -0,0 +1,22 @@ +# -*- python -*- +# +# $Id: debugging.py,v 1.1 2011-08-31 18:25:07 wirawan Exp $ +# +# Created: 20100909 +# Wirawan Purwanto +# +# Debugging tools for python +# + +import re + +def fmtstr_find_missing_arguments(fmtstr, args): + """Finds what named arguments are not supplied.""" + missing = {} + for kw1 in re.findall("%\([^)]+\)", fmtstr): + kw = kw1[2:-1] + if kw not in args: + missing[kw] = missing.get(kw,0) + 1 + missing2 = missing.keys() + missing2.sort() + return missing2