[PATCH 1/3] make-secnet-sites: refactor to break out new function "pfilepath"

Ian Jackson ijackson at chiark.greenend.org.uk
Thu Dec 15 13:45:38 GMT 2011


No intentional functional change.

Signed-off-by: Ian Jackson <ijackson at chiark.greenend.org.uk>
---
 make-secnet-sites |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/make-secnet-sites b/make-secnet-sites
index 4c6f0f4..f102b1f 100755
--- a/make-secnet-sites
+++ b/make-secnet-sites
@@ -379,6 +379,11 @@ def pline(i):
 
 	complain("unknown keyword '%s'"%(keyword))
 
+def pfilepath(pathname):
+	f=open(pathname)
+	pfile(pathname,f.readlines())
+	f.close()
+
 def pfile(name,lines):
 	"Process a file"
 	global file,line
@@ -450,19 +455,14 @@ else:
 		if not ok:
 			print "caller not in group %s"%group
 			sys.exit(1)
-		f=open(header)
-		headerinput=f.readlines()
-		f.close()
-		pfile(header,headerinput)
+		pfilepath(header)
 		userinput=sys.stdin.readlines()
 		pfile("user input",userinput)
 	else:
 		if len(sys.argv)>3:
 			print "Too many arguments"
 			sys.exit(1)
-		f=open(sys.argv[1])
-		pfile(sys.argv[1],f.readlines())
-		f.close()
+		pfilepath(sys.argv[1])
 		of=sys.stdout
 		if len(sys.argv)>2:
 			of=open(sys.argv[2],'w')
-- 
1.5.6.5




More information about the sgo-software-discuss mailing list