ofpbuf: Fix trivial spelling typo.
[cascardo/ovs.git] / python / build / nroff.py
index 75461eb..aed60eb 100644 (file)
 # limitations under the License.
 
 import re
+import sys
 
 from ovs.db import error
 
+
 def text_to_nroff(s, font=r'\fR'):
     def escape(match):
         c = match.group(0)
@@ -55,9 +57,11 @@ def text_to_nroff(s, font=r'\fR'):
     s = re.sub('(-[0-9]|--|[-"\'\\\\.])', escape, s)
     return s
 
+
 def escape_nroff_literal(s, font=r'\fB'):
     return font + r'%s\fR' % text_to_nroff(s, font)
 
+
 def inline_xml_to_nroff(node, font, to_upper=False, newline='\n'):
     if node.nodeType == node.TEXT_NODE:
         if to_upper:
@@ -84,7 +88,8 @@ def inline_xml_to_nroff(node, font, to_upper=False, newline='\n'):
             elif node.hasAttribute('db'):
                 s += node.attributes['db'].nodeValue
             else:
-                raise error.Error("'ref' lacks required attributes: %s" % node.attributes.keys())
+                raise error.Error("'ref' lacks required attributes: %s"
+                                  % list(node.attributes.keys()))
             return s + font
         elif node.tagName in ['var', 'dfn', 'i']:
             s = r'\fI'
@@ -92,12 +97,14 @@ def inline_xml_to_nroff(node, font, to_upper=False, newline='\n'):
                 s += inline_xml_to_nroff(child, r'\fI', to_upper, newline)
             return s + font
         else:
-            raise error.Error("element <%s> unknown or invalid here" % node.tagName)
+            raise error.Error("element <%s> unknown or invalid here"
+                              % node.tagName)
     elif node.nodeType == node.COMMENT_NODE:
         return ''
     else:
         raise error.Error("unknown node %s in inline xml" % node)
 
+
 def pre_to_nroff(nodes, para, font):
     # This puts 'font' at the beginning of each line so that leading and
     # trailing whitespace stripping later doesn't removed leading spaces
@@ -108,6 +115,12 @@ def pre_to_nroff(nodes, para, font):
     s += '\n.fi\n'
     return s
 
+
+def fatal(msg):
+    sys.stderr.write('%s\n' % msg)
+    sys.exit(1)
+
+
 def diagram_header_to_nroff(header_node):
     header_fields = []
     i = 0
@@ -134,7 +147,8 @@ def diagram_header_to_nroff(header_node):
 
     pic_s = ""
     for f in header_fields:
-        pic_s += "  %s: box \"%s\" width %s" % (f['tag'], f['name'], f['width'])
+        pic_s += "  %s: box \"%s\" width %s" % (f['tag'], f['name'],
+                                                f['width'])
         if f['fill'] == 'yes':
             pic_s += " fill"
         pic_s += '\n'
@@ -161,6 +175,7 @@ def diagram_header_to_nroff(header_node):
         text_s += "\n"
     return pic_s, text_s
 
+
 def diagram_to_nroff(nodes, para):
     pic_s = ''
     text_s = ''
@@ -203,6 +218,7 @@ fillval = .2
 .RE
 \\}"""
 
+
 def block_xml_to_nroff(nodes, para='.PP'):
     s = ''
     for node in nodes:
@@ -228,7 +244,8 @@ def block_xml_to_nroff(nodes, para='.PP'):
                         pass
                     elif (li_node.nodeType != node.TEXT_NODE
                           or not li_node.data.isspace()):
-                        raise error.Error("<%s> element may only have <li> children" % node.tagName)
+                        raise error.Error("<%s> element may only have "
+                                          "<li> children" % node.tagName)
                 s += ".RE\n"
             elif node.tagName == 'dl':
                 if s != "":
@@ -252,7 +269,8 @@ def block_xml_to_nroff(nodes, para='.PP'):
                         continue
                     elif (li_node.nodeType != node.TEXT_NODE
                           or not li_node.data.isspace()):
-                        raise error.Error("<dl> element may only have <dt> and <dd> children")
+                        raise error.Error("<dl> element may only have "
+                                          "<dt> and <dd> children")
                     s += block_xml_to_nroff(li_node.childNodes, ".IP")
                 s += ".RE\n"
             elif node.tagName == 'p':