summaryrefslogtreecommitdiff
path: root/compat.py
diff options
context:
space:
mode:
authoryvesf <yvesf-git@xapek.org>2010-11-24 21:44:52 +0100
committeryvesf <yvesf-git@xapek.org>2010-11-24 21:44:52 +0100
commit9a1362c62fb52c125fd818a147e63c96c317081f (patch)
treebbd16d0bf96c244c7983e519f48c390b51b1edf9 /compat.py
parent0d256d1dacb1d38105859a717db0e05062d89c74 (diff)
parent003592d52cd1b7fd868b6ffe41136b25ebac309d (diff)
downloadbooksearch-9a1362c62fb52c125fd818a147e63c96c317081f.tar.gz
booksearch-9a1362c62fb52c125fd818a147e63c96c317081f.zip
Merge branch 'master' of ssh://192.168.0.6/home/yvesf/virtualenv/booksearch into HEAD
Diffstat (limited to 'compat.py')
-rw-r--r--compat.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/compat.py b/compat.py
new file mode 100644
index 0000000..ba14fb2
--- /dev/null
+++ b/compat.py
@@ -0,0 +1,12 @@
+
+if not hasattr('', 'format'):
+ from string import Template
+ import re
+ def str_format(string, *args, **kwargs):
+ tpl = Template(string)
+ tpl.pattern = str_format.re
+ return tpl.substitute(*args, **kwargs)
+ str_format.re = re.compile(r'\{(?P<named>[A-Za-z0-9_]+)\}')
+else:
+ def str_format(string, *args, **kwargs):
+ return string.format(*args, **kwargs)