r5194 - trunk/varnish-cache/lib/libvmod_std
tfheen at varnish-cache.org
tfheen at varnish-cache.org
Mon Sep 13 08:46:00 CEST 2010
Author: tfheen
Date: 2010-09-13 08:45:59 +0200 (Mon, 13 Sep 2010)
New Revision: 5194
Modified:
trunk/varnish-cache/lib/libvmod_std/vmod.py
Log:
Implement compat function for str.partition
python 2.4 (which RHEL5 has, at least) doesn't have str.partition, so
implement it as a compatibility function.
Modified: trunk/varnish-cache/lib/libvmod_std/vmod.py
===================================================================
--- trunk/varnish-cache/lib/libvmod_std/vmod.py 2010-09-12 21:04:54 UTC (rev 5193)
+++ trunk/varnish-cache/lib/libvmod_std/vmod.py 2010-09-13 06:45:59 UTC (rev 5194)
@@ -104,6 +104,14 @@
#######################################################################
+def partition(string, separator):
+ if (hasattr(string,"partition")):
+ return string.partition(separator)
+ i = string.find(separator)
+ if i >= 0:
+ return (string[:i],separator,string[i+len(separator):])
+ return (string, '', '')
+
f = open(specfile, "r")
for l0 in f:
@@ -116,7 +124,7 @@
else:
line = l0
line = line.expandtabs().strip()
- l = line.partition(" ")
+ l = partition(line, " ")
if l[0] == "Module":
modname = l[2].strip();
@@ -129,27 +137,27 @@
if l[0] != "Function":
assert False
- l = l[2].strip().partition(" ")
+ l = partition(l[2].strip(), " ")
rt_type = l[0]
- l = l[2].strip().partition("(")
+ l = partition(l[2].strip(), "(")
fname = l[0].strip()
args = list()
while True:
- l = l[2].strip().partition(",")
+ l = partition(l[2].strip(), ",")
if len(l[2]) == 0:
break
args.append(l[0])
- l = l[0].strip().partition(")")
+ l = partition(l[0].strip(), ")")
args.append(l[0])
do_func(fname, rt_type, args)
#######################################################################
def dumps(s):
while True:
- l = s.partition("\n")
+ l = partition(s, "\n")
if len(l[0]) == 0:
break
fc.write('\t"' + l[0] + '\\n"\n')
More information about the varnish-commit
mailing list