Skip to content

Commit

Permalink
xml2nroff: Read whole file instead of line by line.
Browse files Browse the repository at this point in the history
The previous code processed the input file line by line, but I think
it looks a little more straight forward to just process the whole file
at once.

This patch also explicitly closes the file after reading its contents.

Signed-off-by: Russell Bryant <[email protected]>
Acked-by: Justin Pettit <[email protected]>
  • Loading branch information
russellb committed Dec 11, 2015
1 parent 138bc37 commit 069390b
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions build-aux/xml2nroff
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ The following options are also available:


def manpage_to_nroff(xml_file, subst, version=None):
f = open(xml_file)
content = []
for line in f:
for k, v in subst.iteritems():
line = line.replace(k, v)
content += [line]
doc = xml.dom.minidom.parseString(''.join(content)).documentElement
with open(xml_file) as f:
content = f.read()
for k, v in subst.iteritems():
content = content.replace(k, v)
doc = xml.dom.minidom.parseString(content).documentElement

if version is None:
version = "UNKNOWN"
Expand Down

0 comments on commit 069390b

Please sign in to comment.