Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
45362c9c
Commit
45362c9c
authored
May 14, 2014
by
Lasse Karstensen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support both python2 and python3.
parent
babbaa53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
9 deletions
+11
-9
vmodtool.py
lib/libvcc/vmodtool.py
+11
-9
No files found.
lib/libvcc/vmodtool.py
View file @
45362c9c
#!/usr/bin/env python
2
#!/usr/bin/env python
#-
# Copyright (c) 2010-2014 Varnish Software AS
# All rights reserved.
...
...
@@ -37,6 +37,9 @@
# as a string, suitable for inclusion in the C-source of the compile VCL
# program.
# This script should work with both Python 2 and Python 3.
from
__future__
import
print_function
import
sys
import
re
import
optparse
...
...
@@ -45,7 +48,6 @@ from os import unlink
from
os.path
import
dirname
,
basename
,
realpath
,
exists
from
pprint
import
pprint
,
pformat
ctypes
=
{
'BACKEND'
:
"VCL_BACKEND"
,
'BOOL'
:
"VCL_BOOL"
,
...
...
@@ -89,7 +91,7 @@ class FormatError(Exception):
"""
Raised if the content of the (otherwise well-formed) input file
is invalid.
"""
"""
def
__init__
(
self
,
msg
,
details
):
self
.
msg
=
msg
self
.
details
=
details
...
...
@@ -699,8 +701,8 @@ class file_section(object):
if
opts
.
strict
:
raise
FormatError
(
m
,
details
)
else
:
print
>>
sys
.
stderr
,
"WARNING:
%
s:"
%
m
print
>>
sys
.
stderr
,
details
print
(
"WARNING:
%
s:"
%
m
,
file
=
sys
.
stderr
)
print
(
details
,
file
=
sys
.
stderr
)
else
:
for
ln
,
i
in
self
.
l
:
o
.
doc
(
i
)
...
...
@@ -798,12 +800,12 @@ def runmain(inputvcc, outputname="vcc_if"):
i
.
parse
(
vx
)
assert
len
(
i
.
tl
)
==
0
except
ParseError
as
e
:
print
"ERROR: Parse error reading
\"
%
s
\"
:"
%
inputvcc
print
(
"ERROR: Parse error reading
\"
%
s
\"
:"
%
inputvcc
)
pprint
(
str
(
e
))
exit
(
-
1
)
except
FormatError
as
e
:
print
"ERROR: Format error reading
\"
%
s
\"
:
%
s"
%
(
inputvcc
,
pformat
(
e
.
msg
))
print
e
.
details
print
(
"ERROR: Format error reading
\"
%
s
\"
:
%
s"
%
(
inputvcc
,
pformat
(
e
.
msg
)
))
print
(
e
.
details
)
exit
(
-
2
)
#######################################################################
...
...
@@ -879,7 +881,7 @@ if __name__ == "__main__":
if
not
inputvcc
:
inputvcc
=
"vmod.vcc"
else
:
print
>>
sys
.
stderr
,
"ERROR: No vmod.vcc file supplied or found."
print
(
"ERROR: No vmod.vcc file supplied or found."
,
file
=
sys
.
stderr
)
oparser
.
print_help
()
exit
(
-
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment