ovsdb-doc: Use minus sign in negative numbers in nroff output.
authorBen Pfaff <blp@nicira.com>
Fri, 9 Mar 2012 23:10:56 +0000 (15:10 -0800)
committerBen Pfaff <blp@nicira.com>
Mon, 12 Mar 2012 17:13:38 +0000 (10:13 -0700)
ovs-vswitchd.conf.db.5 has autogenerated text "at least -1" in one place.
This '-' should be a minus sign, but ovsdb-doc was generating it as a
hyphen.

Found by lintian.

Reported-by: Thomas Goirand <zigo@debian.org>
Reviewed-by: Simon Horman <horms@verge.net.au>
Signed-off-by: Ben Pfaff <blp@nicira.com>
ovsdb/ovsdb-doc.in
python/ovs/db/types.py

index a4eabc59a21a67c8ee767604f8a314c9e6bfc993..7b783e1a0414c9e29b329c3b30ec44133b844ae8 100755 (executable)
@@ -144,7 +144,8 @@ def blockXmlToNroff(nodes, para='.PP'):
 
 def typeAndConstraintsToNroff(column):
     type = column.type.toEnglish(escapeNroffLiteral)
-    constraints = column.type.constraintsToEnglish(escapeNroffLiteral)
+    constraints = column.type.constraintsToEnglish(escapeNroffLiteral,
+                                                   textToNroff)
     if constraints:
         type += ", " + constraints
     if column.unique:
@@ -187,7 +188,8 @@ def columnGroupToNroff(table, groupXml):
                 nameNroff = "%s : %s" % (name, key)
 
                 if column.type.value:
-                    typeNroff = "optional %s" % column.type.value.toEnglish()
+                    typeNroff = "optional %s" % column.type.value.toEnglish(
+                        escapeNroffLiteral)
                     if (column.type.value.type == ovs.db.types.StringType and
                         type_.type == ovs.db.types.BooleanType):
                         # This is a little more explicit and helpful than
@@ -201,7 +203,8 @@ def columnGroupToNroff(table, groupXml):
                             else:
                                 typeNroff += ", containing a %s" % type_english
                         constraints = (
-                            type_.constraintsToEnglish(escapeNroffLiteral))
+                            type_.constraintsToEnglish(escapeNroffLiteral,
+                                                       textToNroff))
                         if constraints:
                             typeNroff += ", %s" % constraints
                 else:
index a8a53dd010ed3c48bee76cb397241e5e55cfb88b..fc9fc0a231d8a463a48f5c2d3b3d18d038e6d05d 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2009, 2010, 2011 Nicira Networks
+# Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -282,7 +282,8 @@ class BaseType(object):
         else:
             return self.type.to_string()
 
-    def constraintsToEnglish(self, escapeLiteral=returnUnchanged):
+    def constraintsToEnglish(self, escapeLiteral=returnUnchanged,
+                             escapeNumber=returnUnchanged):
         if self.enum:
             literals = [value.toEnglish(escapeLiteral)
                         for value in self.enum.values]
@@ -294,20 +295,23 @@ class BaseType(object):
                                                     literals[-1])
         elif self.min is not None and self.max is not None:
             if self.type == IntegerType:
-                english = 'in range %s to %s' % (commafy(self.min),
-                                                 commafy(self.max))
+                english = 'in range %s to %s' % (
+                    escapeNumber(commafy(self.min)),
+                    escapeNumber(commafy(self.max)))
             else:
-                english = 'in range %g to %g' % (self.min, self.max)
+                english = 'in range %s to %s' % (
+                    escapeNumber("%g" % self.min),
+                    escapeNumber("%g" % self.max))
         elif self.min is not None:
             if self.type == IntegerType:
-                english = 'at least %s' % commafy(self.min)
+                english = 'at least %s' % escapeNumber(commafy(self.min))
             else:
-                english = 'at least %g' % self.min
+                english = 'at least %s' % escapeNumber("%g" % self.min)
         elif self.max is not None:
             if self.type == IntegerType:
-                english = 'at most %s' % commafy(self.max)
+                english = 'at most %s' % escapeNumber(commafy(self.max))
             else:
-                english = 'at most %g' % self.max
+                english = 'at most %s' % escapeNumber("%g" % self.max)
         elif self.min_length != 0 and self.max_length != sys.maxint:
             if self.min_length == self.max_length:
                 english = ('exactly %s characters long'
@@ -537,9 +541,11 @@ class Type(object):
                     plural = keyName + "s"
                 return "set of %s%s" % (quantity, plural)
 
-    def constraintsToEnglish(self, escapeLiteral=returnUnchanged):
+    def constraintsToEnglish(self, escapeLiteral=returnUnchanged,
+                             escapeNumber=returnUnchanged):
         constraints = []
-        keyConstraints = self.key.constraintsToEnglish(escapeLiteral)
+        keyConstraints = self.key.constraintsToEnglish(escapeLiteral,
+                                                       escapeNumber)
         if keyConstraints:
             if self.value:
                 constraints.append('key %s' % keyConstraints)
@@ -547,7 +553,8 @@ class Type(object):
                 constraints.append(keyConstraints)
 
         if self.value:
-            valueConstraints = self.value.constraintsToEnglish(escapeLiteral)
+            valueConstraints = self.value.constraintsToEnglish(escapeLiteral,
+                                                               escapeNumber)
             if valueConstraints:
                 constraints.append('value %s' % valueConstraints)