Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
homepage
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
homepage
Commits
526f6eeb
Commit
526f6eeb
authored
Nov 03, 2020
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update vmod script to python3
parent
f6a28c5d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
178 additions
and
182 deletions
+178
-182
Makefile
R1/Makefile
+1
-1
build.py
R1/source/vmods/build.py
+177
-181
No files found.
R1/Makefile
View file @
526f6eeb
...
@@ -27,7 +27,7 @@ all: generate html
...
@@ -27,7 +27,7 @@ all: generate html
cp source
/favicon.ico build/html
cp source
/favicon.ico build/html
generate
:
generate
:
cd source
/vmods
&&
python
2.7
build.py
cd source
/vmods
&&
python
3
build.py
pub
:
pub
:
${
MAKE
}
rsync
\
${
MAKE
}
rsync
\
...
...
R1/source/vmods/build.py
View file @
526f6eeb
#!/usr/bin/env python
#!/usr/bin/env python
from
__future__
import
print_function
import
glob
import
glob
import
json
import
json
import
sys
import
sys
class
vmod
(
object
):
class
vmod
(
object
):
def
__init__
(
self
,
filename
):
def
__init__
(
self
,
filename
):
self
.
filename
=
filename
self
.
filename
=
filename
self
.
load
()
self
.
load
()
def
load
(
self
):
def
load
(
self
):
fi
=
open
(
self
.
filename
)
fi
=
open
(
self
.
filename
)
self
.
j
=
json
.
loads
(
fi
.
read
())
self
.
j
=
json
.
loads
(
fi
.
read
())
fi
.
close
()
fi
.
close
()
def
save
(
self
):
def
save
(
self
):
fo
=
open
(
self
.
filename
,
"w"
)
fo
=
open
(
self
.
filename
,
"w"
)
fo
.
write
(
json
.
dumps
(
self
.
j
,
sort_keys
=
True
,
indent
=
4
,
separators
=
(
","
,
": "
)))
fo
.
write
(
json
.
dumps
(
self
.
j
,
sort_keys
=
True
,
indent
=
4
,
separators
=
(
","
,
": "
)))
fo
.
close
()
fo
.
close
()
def
name
(
self
):
def
name
(
self
):
return
self
.
j
[
"name"
]
return
self
.
j
[
"name"
]
def
repos
(
self
):
def
repos
(
self
):
g
=
self
.
j
.
get
(
"github"
)
g
=
self
.
j
.
get
(
"github"
)
if
g
!=
None
:
if
g
!=
None
:
return
{
"Github"
:
"https://github.com/"
+
g
[
"user"
]
+
"/"
+
g
[
"project"
]}
return
{
"Github"
:
"https://github.com/"
+
g
[
"user"
]
+
"/"
+
g
[
"project"
]}
i
=
self
.
j
.
get
(
"repos"
)
i
=
self
.
j
.
get
(
"repos"
)
if
isinstance
(
i
,
dict
):
if
isinstance
(
i
,
dict
):
return
i
return
i
if
i
!=
None
:
if
i
!=
None
:
return
{
"Repos"
:
i
}
return
{
"Repos"
:
i
}
return
None
return
None
def
versions
(
self
):
def
versions
(
self
):
r
=
self
.
j
.
get
(
"rev"
)
r
=
self
.
j
.
get
(
"rev"
)
g
=
self
.
j
.
get
(
"github"
)
g
=
self
.
j
.
get
(
"github"
)
v
=
None
v
=
None
if
r
!=
None
:
if
r
!=
None
:
v
=
r
.
keys
()
v
=
r
.
keys
()
elif
g
!=
None
:
elif
g
!=
None
:
v
=
g
[
"branches"
]
.
keys
()
v
=
g
[
"branches"
]
.
keys
()
if
v
!=
None
:
if
v
!=
None
:
v
.
sort
()
return
sorted
(
v
)
return
v
return
list
()
return
list
()
def
url_vcc
(
self
,
rev
):
def
url_vcc
(
self
,
rev
):
r
=
self
.
j
.
get
(
"rev"
)
r
=
self
.
j
.
get
(
"rev"
)
if
r
!=
None
:
if
r
!=
None
:
if
"url_vcc"
in
r
[
rev
]:
if
"url_vcc"
in
r
[
rev
]:
return
r
[
rev
][
"url_vcc"
]
return
r
[
rev
][
"url_vcc"
]
fmt
=
self
.
j
.
get
(
"fmt"
)
fmt
=
self
.
j
.
get
(
"fmt"
)
if
fmt
!=
None
and
"url_vcc"
in
fmt
:
if
fmt
!=
None
and
"url_vcc"
in
fmt
:
fmt
=
fmt
[
"url_vcc"
]
fmt
=
fmt
[
"url_vcc"
]
else
:
else
:
fmt
=
None
fmt
=
None
if
fmt
!=
None
and
"branch"
in
r
[
rev
]:
if
fmt
!=
None
and
"branch"
in
r
[
rev
]:
return
fmt
%
r
[
rev
][
"branch"
]
return
fmt
%
r
[
rev
][
"branch"
]
g
=
self
.
j
.
get
(
"github"
)
g
=
self
.
j
.
get
(
"github"
)
if
g
!=
None
:
if
g
!=
None
:
s
=
"https://raw.githubusercontent.com/"
s
=
"https://raw.githubusercontent.com/"
s
+=
g
[
"user"
]
+
"/"
s
+=
g
[
"user"
]
+
"/"
s
+=
g
[
"project"
]
+
"/"
s
+=
g
[
"project"
]
+
"/"
s
+=
g
[
"branches"
][
rev
]
+
"/"
s
+=
g
[
"branches"
][
rev
]
+
"/"
s
+=
g
[
"vcc_path"
]
s
+=
g
[
"vcc_path"
]
return
s
return
s
return
None
return
None
def
url_doc
(
self
,
rev
):
def
url_doc
(
self
,
rev
):
r
=
self
.
j
.
get
(
"rev"
)
r
=
self
.
j
.
get
(
"rev"
)
if
r
!=
None
:
if
r
!=
None
:
if
"url_doc"
in
r
[
rev
]:
if
"url_doc"
in
r
[
rev
]:
return
r
[
rev
][
"url_doc"
]
return
r
[
rev
][
"url_doc"
]
fmt
=
self
.
j
.
get
(
"fmt"
)
fmt
=
self
.
j
.
get
(
"fmt"
)
if
fmt
!=
None
and
"url_doc"
in
fmt
:
if
fmt
!=
None
and
"url_doc"
in
fmt
:
fmt
=
fmt
[
"url_doc"
]
fmt
=
fmt
[
"url_doc"
]
else
:
else
:
fmt
=
None
fmt
=
None
if
fmt
!=
None
and
"branch"
in
r
[
rev
]:
if
fmt
!=
None
and
"branch"
in
r
[
rev
]:
return
fmt
%
r
[
rev
][
"branch"
]
return
fmt
%
r
[
rev
][
"branch"
]
g
=
self
.
j
.
get
(
"github"
)
g
=
self
.
j
.
get
(
"github"
)
if
g
!=
None
and
"doc_path"
in
g
:
if
g
!=
None
and
"doc_path"
in
g
:
s
=
"https://github.com/"
s
=
"https://github.com/"
s
+=
g
[
"user"
]
+
"/"
s
+=
g
[
"user"
]
+
"/"
s
+=
g
[
"project"
]
+
"/"
s
+=
g
[
"project"
]
+
"/"
s
+=
"blob/"
s
+=
"blob/"
s
+=
g
[
"branches"
][
rev
]
+
"/"
s
+=
g
[
"branches"
][
rev
]
+
"/"
s
+=
g
[
"doc_path"
]
s
+=
g
[
"doc_path"
]
return
s
return
s
return
None
return
None
def
www_table
(
self
):
def
www_table
(
self
):
l
=
[]
l
=
[]
l
.
append
(
self
.
j
.
get
(
"name"
))
l
.
append
(
self
.
j
.
get
(
"name"
))
l
.
append
(
self
.
j
.
get
(
"desc"
))
l
.
append
(
self
.
j
.
get
(
"desc"
))
s
=
""
s
=
""
for
r
in
self
.
versions
():
for
r
in
self
.
versions
():
doc
=
self
.
url_doc
(
r
)
doc
=
self
.
url_doc
(
r
)
if
doc
!=
None
:
if
doc
!=
None
:
s
+=
" `
%
s <
%
s>`__ "
%
(
r
,
doc
)
s
+=
" `
%
s <
%
s>`__ "
%
(
r
,
doc
)
else
:
else
:
vcc
=
self
.
url_vcc
(
r
)
vcc
=
self
.
url_vcc
(
r
)
s
+=
" `
%
s <
%
s>`__ "
%
(
r
,
vcc
)
s
+=
" `
%
s <
%
s>`__ "
%
(
r
,
vcc
)
l
.
append
(
s
)
l
.
append
(
s
)
l
.
append
(
self
.
j
.
get
(
"license"
))
l
.
append
(
self
.
j
.
get
(
"license"
))
l
.
append
(
self
.
j
.
get
(
"status"
))
l
.
append
(
self
.
j
.
get
(
"status"
))
s
=
""
s
=
""
i
=
self
.
repos
()
i
=
self
.
repos
()
if
i
!=
None
:
if
i
!=
None
:
for
n
in
sorted
(
i
):
for
n
in
sorted
(
i
.
iterkeys
()):
s
+=
" `
%
s <
%
s>`__ "
%
(
n
,
i
[
n
])
s
+=
" `
%
s <
%
s>`__ "
%
(
n
,
i
[
n
])
l
.
append
(
s
)
l
.
append
(
s
)
s
=
""
s
=
""
for
r
in
self
.
versions
():
for
r
in
self
.
versions
():
vcc
=
self
.
url_vcc
(
r
)
vcc
=
self
.
url_vcc
(
r
)
s
+=
" `
%
s <
%
s>`__ "
%
(
r
,
vcc
)
s
+=
" `
%
s <
%
s>`__ "
%
(
r
,
vcc
)
l
.
append
(
s
)
l
.
append
(
s
)
i
=
self
.
j
.
get
(
"support"
)
i
=
self
.
j
.
get
(
"support"
)
s
=
""
s
=
""
if
i
!=
None
:
if
i
!=
None
:
for
j
in
i
:
for
j
in
i
:
if
j
==
"Uplex"
:
if
j
==
"Uplex"
:
s
+=
" :ref:`business_uplex`"
s
+=
" :ref:`business_uplex`"
elif
j
==
"Varnish Software"
:
elif
j
==
"Varnish Software"
:
s
+=
":ref:`business_varnish_software`"
s
+=
":ref:`business_varnish_software`"
elif
j
!=
None
:
elif
j
!=
None
:
s
+=
" "
+
j
s
+=
" "
+
j
l
.
append
(
s
)
l
.
append
(
s
)
return
l
return
l
def
load_all
():
def
load_all
():
vmods
=
{}
vmods
=
{}
for
fn
in
glob
.
glob
(
"vmod_*.json"
):
for
fn
in
glob
.
glob
(
"vmod_*.json"
):
try
:
try
:
v
=
vmod
(
fn
)
v
=
vmod
(
fn
)
except
:
except
:
print
(
"ERROR: couldn't load "
+
fn
)
print
(
"ERROR: couldn't load "
+
fn
)
continue
continue
vmods
[
v
.
name
()]
=
v
vmods
[
v
.
name
()]
=
v
return
vmods
return
vmods
def
make_www_table
():
def
make_www_table
():
vmods
=
load_all
()
vmods
=
load_all
()
nms
=
vmods
.
keys
()
nms
=
sorted
(
vmods
.
keys
())
nms
.
sort
()
l
=
[]
l
=
[]
#######################################################################
#######################################################################
# Size columns
# Size columns
h
=
[
"VMOD"
,
"Description"
,
"Docs"
,
"License"
,
"Status"
,
"Link"
,
"VCC"
,
"Support"
]
h
=
[
"VMOD"
,
"Description"
,
"Docs"
,
"License"
,
"Status"
,
"Link"
,
"VCC"
,
"Support"
]
w
=
[
0
]
*
len
(
h
)
w
=
[
0
]
*
len
(
h
)
for
i
in
nms
:
for
i
in
nms
:
x
=
vmods
[
i
]
.
www_table
()
x
=
vmods
[
i
]
.
www_table
()
l
.
append
(
x
)
l
.
append
(
x
)
for
j
in
range
(
len
(
w
)):
for
j
in
range
(
len
(
w
)):
if
x
[
j
]
==
None
:
if
x
[
j
]
==
None
:
x
[
j
]
=
""
x
[
j
]
=
""
else
:
else
:
x
[
j
]
=
x
[
j
]
.
strip
()
x
[
j
]
=
x
[
j
]
.
strip
()
w
[
j
]
=
max
(
w
[
j
],
len
(
x
[
j
]))
w
[
j
]
=
max
(
w
[
j
],
len
(
x
[
j
]))
#######################################################################
#######################################################################
# Emit output
# Emit output
fo
=
open
(
"index.rst"
,
"w"
)
fo
=
open
(
"index.rst"
,
"w"
)
fo
.
write
(
'''
fo
.
write
(
'''
.. _vmods:
.. _vmods:
Varnish Modules
Varnish Modules
...
@@ -203,30 +199,30 @@ Instructions :ref:`how to get your VMOD on this list <vmods_reg>`.
...
@@ -203,30 +199,30 @@ Instructions :ref:`how to get your VMOD on this list <vmods_reg>`.
'''
)
'''
)
def
sep
(
ln
=
"-"
):
def
sep
(
ln
=
"-"
):
for
i
in
w
:
for
i
in
w
:
fo
.
write
(
"+"
+
ln
*
(
i
+
2
))
fo
.
write
(
"+"
+
ln
*
(
i
+
2
))
fo
.
write
(
"+
\n
"
)
fo
.
write
(
"+
\n
"
)
sep
(
"-"
)
sep
(
"-"
)
for
i
in
range
(
len
(
h
)):
for
i
in
range
(
len
(
h
)):
fo
.
write
(
"| "
+
h
[
i
]
.
ljust
(
w
[
i
])
+
" "
)
fo
.
write
(
"| "
+
h
[
i
]
.
ljust
(
w
[
i
])
+
" "
)
fo
.
write
(
"|
\n
"
)
fo
.
write
(
"|
\n
"
)
sep
(
"="
)
sep
(
"="
)
for
i
in
l
:
for
i
in
l
:
for
j
in
range
(
len
(
w
)):
for
j
in
range
(
len
(
w
)):
fo
.
write
(
"| "
+
i
[
j
]
.
ljust
(
w
[
j
])
+
" "
)
fo
.
write
(
"| "
+
i
[
j
]
.
ljust
(
w
[
j
])
+
" "
)
fo
.
write
(
"|
\n
"
)
fo
.
write
(
"|
\n
"
)
sep
()
sep
()
if
__name__
==
"__main__"
:
if
__name__
==
"__main__"
:
vmods
=
load_all
()
vmods
=
load_all
()
if
len
(
sys
.
argv
)
==
1
:
if
len
(
sys
.
argv
)
==
1
:
make_www_table
()
make_www_table
()
elif
len
(
sys
.
argv
)
==
2
and
sys
.
argv
[
1
]
==
"--polish"
:
elif
len
(
sys
.
argv
)
==
2
and
sys
.
argv
[
1
]
==
"--polish"
:
vmods
=
load_all
()
vmods
=
load_all
()
for
i
in
vmods
:
for
i
in
vmods
:
vmods
[
i
]
.
save
()
vmods
[
i
]
.
save
()
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