[master] 2180ad2 Output autogen-msg to .rst; pythonify a bit.

Lasse Karstensen lkarsten at varnish-software.com
Tue May 13 11:55:59 CEST 2014


commit 2180ad2b748996d7550748199db46f4924765bf0
Author: Lasse Karstensen <lkarsten at varnish-software.com>
Date:   Tue May 13 11:46:18 2014 +0200

    Output autogen-msg to .rst; pythonify a bit.
    
    Write a header in generated .rst files that it was generated from the
    .vcc file.
    
    Also softly sprinkled with some python formatting:
    * use a python 2.5 context manager for the filepointer
    * and make the output easier to read by avoiding concatination.

diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 9dc2c4b..74fd633 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -799,16 +799,19 @@ fc.close()
 fh.close()
 
 for suf in ("", ".man"):
-	fr = open("vmod_" + vx[0].nam + suf + ".rst", "w")
-	vx[0].doc_dump(fr, suf)
-
-	if len(copyright) > 0:
-		fr.write("\n")
-		fr.write("COPYRIGHT\n")
-		fr.write("=========\n")
-		fr.write("\n::\n\n")
-		for i in copyright:
-			fr.write("  " + i + "\n")
-		fr.write("\n")
-
-	fr.close()
+	with open("vmod_%s%s.rst" % (vx[0].nam, suf), "w") as fp:
+		fp.write("..\n")
+		fp.write(".. This file was autogenerated by %s. DO NOT EDIT!\n" %
+			 basename(__file__))
+		fp.write("..\n")
+
+		vx[0].doc_dump(fp, suf)
+
+		if len(copyright) > 0:
+			fp.write("\n")
+			fp.write("COPYRIGHT\n")
+			fp.write("=========\n")
+			fp.write("\n::\n\n")
+			for i in copyright:
+				fp.write("  %s\n" % i)
+			fp.write("\n")



More information about the varnish-commit mailing list