[master] 5dfd0c0 Minor cleanup of how we write the warning at the top of generated files.

Poul-Henning Kamp phk at FreeBSD.org
Tue May 27 12:42:16 CEST 2014


commit 5dfd0c099569282164e4f03c64e172205cb2c17d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue May 27 10:18:22 2014 +0000

    Minor cleanup of how we write the warning at the top of generated files.

diff --git a/lib/libvcc/vmodtool.py b/lib/libvcc/vmodtool.py
index 25e0624..42e2fd3 100755
--- a/lib/libvcc/vmodtool.py
+++ b/lib/libvcc/vmodtool.py
@@ -68,14 +68,18 @@ ctypes = {
 
 #######################################################################
 
-def write_file_header(fo):
-	fo.write("""/*
- * NB:  This file is machine generated, DO NOT EDIT!
- *
- * Edit vmod.vcc and run %s instead
- */
+def write_file_warning(fo, a, b, c):
+	fo.write(a + "\n")
+	fo.write(b + "NB:  This file is machine generated, DO NOT EDIT!\n")
+	fo.write(b + "\n")
+	fo.write(b + "Edit vmod.vcc and run make instead\n")
+	fo.write(c + "\n\n")
 
-""" % basename(__file__))
+def write_c_file_warning(fo):
+	write_file_warning(fo, "/*", " * ", " */")
+
+def write_rst_file_warning(fo):
+	write_file_warning(fo, "..", ".. ", "..")
 
 #######################################################################
 
@@ -815,8 +819,8 @@ def runmain(inputvcc, outputname="vcc_if"):
 	fc = open("%s.c" % outputname, "w")
 	fh = open("%s.h" % outputname, "w")
 
-	write_file_header(fc)
-	write_file_header(fh)
+	write_c_file_warning(fc)
+	write_c_file_warning(fh)
 
 	fh.write('struct vrt_ctx;\n')
 	fh.write('struct VCL_conf;\n')
@@ -841,22 +845,19 @@ def runmain(inputvcc, outputname="vcc_if"):
 	fh.close()
 
 	for suf in ("", ".man"):
-		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\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")
+		fp = open("vmod_%s%s.rst" % (vx[0].nam, suf), "w")
+		write_rst_file_warning(fp)
+
+		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")
 
 
 if __name__ == "__main__":



More information about the varnish-commit mailing list