|
|
3bf6bab |
--- lib/libvcc/vmodtool.py.orig 2016-03-29 11:16:00.534066134 +0200
|
|
|
3bf6bab |
+++ lib/libvcc/vmodtool.py 2016-03-29 12:11:54.571647851 +0200
|
|
|
3bf6bab |
@@ -33,8 +33,8 @@
|
|
|
3bf6bab |
vmod_${name}.rst -- Extracted documentation
|
|
|
3bf6bab |
"""
|
|
|
3bf6bab |
|
|
|
3bf6bab |
-# This script should work with both Python 2 and Python 3.
|
|
|
3bf6bab |
-from __future__ import print_function
|
|
|
3bf6bab |
+## This script should work with both Python 2 and Python 3.
|
|
|
3bf6bab |
+#from __future__ import print_function
|
|
|
3bf6bab |
|
|
|
3bf6bab |
import sys
|
|
|
3bf6bab |
import re
|
|
|
3bf6bab |
@@ -45,6 +45,16 @@
|
|
|
3bf6bab |
from os.path import dirname, exists, join, realpath
|
|
|
3bf6bab |
from pprint import pprint, pformat
|
|
|
3bf6bab |
|
|
|
3bf6bab |
+# __future__ print_function is not available on python2.4 in rhel5, so
|
|
|
3bf6bab |
+# make a local simple variant _print
|
|
|
3bf6bab |
+
|
|
|
3bf6bab |
+def _print(*objects, **kwargs):
|
|
|
3bf6bab |
+ sep = kwargs.get('sep', ' ')
|
|
|
3bf6bab |
+ end = kwargs.get('end', '\n')
|
|
|
3bf6bab |
+ out = kwargs.get('file', sys.stdout)
|
|
|
3bf6bab |
+ out.write(sep.join(objects) + end)
|
|
|
3bf6bab |
+
|
|
|
3bf6bab |
+
|
|
|
3bf6bab |
ctypes = {
|
|
|
3bf6bab |
'ACL': "VCL_ACL",
|
|
|
3bf6bab |
'BACKEND': "VCL_BACKEND",
|
|
|
3bf6bab |
@@ -728,7 +738,7 @@
|
|
|
3bf6bab |
def get_token(self):
|
|
|
3bf6bab |
while True:
|
|
|
3bf6bab |
if len(self.tl) > 0:
|
|
|
3bf6bab |
- # print("T\t", self.tl[0])
|
|
|
3bf6bab |
+ # _print("T\t", self.tl[0])
|
|
|
3bf6bab |
return self.tl.pop(0)
|
|
|
3bf6bab |
if len(self.l) == 0:
|
|
|
3bf6bab |
break
|
|
|
3bf6bab |
@@ -796,7 +806,7 @@
|
|
|
3bf6bab |
raise FormatError("Unknown keyword: %s" %
|
|
|
3bf6bab |
t.str, "")
|
|
|
3bf6bab |
else:
|
|
|
3bf6bab |
- print("WARNING: Unknown keyword: %s:" %
|
|
|
3bf6bab |
+ _print("WARNING: Unknown keyword: %s:" %
|
|
|
3bf6bab |
t.str, file=sys.stderr)
|
|
|
3bf6bab |
o = None
|
|
|
3bf6bab |
while len(self.tl) > 0:
|
|
|
3bf6bab |
@@ -809,8 +819,8 @@
|
|
|
3bf6bab |
if opts.strict:
|
|
|
3bf6bab |
raise FormatError(m, details)
|
|
|
3bf6bab |
else:
|
|
|
3bf6bab |
- print("WARNING: %s:" % m, file=sys.stderr)
|
|
|
3bf6bab |
- print(details, file=sys.stderr)
|
|
|
3bf6bab |
+ _print("WARNING: %s:" % m, file=sys.stderr)
|
|
|
3bf6bab |
+ _print(details, file=sys.stderr)
|
|
|
3bf6bab |
else:
|
|
|
3bf6bab |
for ln, i in self.l:
|
|
|
3bf6bab |
o.doc(i)
|
|
|
3bf6bab |
@@ -852,9 +862,12 @@
|
|
|
3bf6bab |
def runmain(inputvcc, rstdir, outputprefix):
|
|
|
3bf6bab |
# Read the file in
|
|
|
3bf6bab |
lines = []
|
|
|
3bf6bab |
- with open(inputvcc, "r") as fp:
|
|
|
3bf6bab |
+ fp = open(inputvcc, "r")
|
|
|
3bf6bab |
+ try:
|
|
|
3bf6bab |
for i in fp:
|
|
|
3bf6bab |
lines.append(i.rstrip())
|
|
|
3bf6bab |
+ finally:
|
|
|
3bf6bab |
+ fp.close
|
|
|
3bf6bab |
ln = 0
|
|
|
3bf6bab |
|
|
|
3bf6bab |
#######################################################################
|
|
|
3bf6bab |
@@ -874,7 +887,7 @@
|
|
|
3bf6bab |
|
|
|
3bf6bab |
if False:
|
|
|
3bf6bab |
for i in copy_right:
|
|
|
3bf6bab |
- print("(C)\t", i)
|
|
|
3bf6bab |
+ _print("(C)\t", i)
|
|
|
3bf6bab |
|
|
|
3bf6bab |
#######################################################################
|
|
|
3bf6bab |
# Break into sections
|
|
|
3bf6bab |
@@ -899,14 +912,14 @@
|
|
|
3bf6bab |
for i in sl:
|
|
|
3bf6bab |
i.parse(vx)
|
|
|
3bf6bab |
assert len(i.tl) == 0
|
|
|
3bf6bab |
- except ParseError as e:
|
|
|
3bf6bab |
- print("ERROR: Parse error reading \"%s\":" % inputvcc)
|
|
|
3bf6bab |
+ except ParseError, e:
|
|
|
3bf6bab |
+ _print("ERROR: Parse error reading \"%s\":" % inputvcc)
|
|
|
3bf6bab |
pprint(str(e))
|
|
|
3bf6bab |
exit(-1)
|
|
|
3bf6bab |
- except FormatError as e:
|
|
|
3bf6bab |
- print("ERROR: Format error reading \"%s\": %s" %
|
|
|
3bf6bab |
+ except FormatError, e:
|
|
|
3bf6bab |
+ _print("ERROR: Format error reading \"%s\": %s" %
|
|
|
3bf6bab |
(inputvcc, pformat(e.msg)))
|
|
|
3bf6bab |
- print(e.details)
|
|
|
3bf6bab |
+ _print(e.details)
|
|
|
3bf6bab |
exit(-2)
|
|
|
3bf6bab |
|
|
|
3bf6bab |
#######################################################################
|
|
|
3bf6bab |
@@ -981,7 +994,7 @@
|
|
|
3bf6bab |
if not i_vcc:
|
|
|
3bf6bab |
i_vcc = "vmod.vcc"
|
|
|
3bf6bab |
else:
|
|
|
3bf6bab |
- print("ERROR: No vmod.vcc file supplied or found.",
|
|
|
3bf6bab |
+ _print("ERROR: No vmod.vcc file supplied or found.",
|
|
|
3bf6bab |
file=sys.stderr)
|
|
|
3bf6bab |
oparser.print_help()
|
|
|
3bf6bab |
exit(-1)
|