Fix (python): use of braces in format strings
authorAmit Margalit <amitm@il.ibm.com>
Tue, 20 Aug 2013 06:30:38 +0000 (09:30 +0300)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 26 Aug 2013 17:38:09 +0000 (13:38 -0400)
Using braces in format strings without specifying a number (e.g. "The
number {} is incorrect".format(some_variable)) is available since Python
2.7, and older Python 2.6 required a number, zero-based (e.g. "The
number {0} is incorrect").

This patch adds these numbers for the sake of older systems.

Acked-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Amit Margalit <amitm@il.ibm.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
bindings/python/babeltrace.i.in

index 16dbbbde60cf053bb2214acfd705068bba7db326..24581604e57856713ceaa9744a26dd8092dfdc24 100644 (file)
@@ -477,7 +477,7 @@ class TraceHandle(object):
                raise NotImplementedError("TraceHandle cannot be instantiated")
 
        def __repr__(self):
-               return "Babeltrace TraceHandle: trace_id('{}')".format(self._id)
+               return "Babeltrace TraceHandle: trace_id('{0}')".format(self._id)
 
        def get_id(self):
                """Return the TraceHandle id."""
@@ -832,7 +832,7 @@ class ctf:
                        raise NotImplementedError("ctf.Definition cannot be instantiated")
 
                def __repr__(self):
-                       return "Babeltrace Definition: name('{}'), type({})".format(
+                       return "Babeltrace Definition: name('{0}'), type({1})".format(
                                self.field_name(), self.field_type())
 
                def field_name(self):
@@ -926,7 +926,7 @@ class ctf:
                        raise NotImplementedError("ctf.EventDecl cannot be instantiated")
 
                def __repr__(self):
-                       return "Babeltrace EventDecl: name {}".format(self.get_name())
+                       return "Babeltrace EventDecl: name {0}".format(self.get_name())
 
                def get_name(self):
                        """Return the name of the event or None on error"""
@@ -965,7 +965,7 @@ class ctf:
                        raise NotImplementedError("ctf.FieldDecl cannot be instantiated")
 
                def __repr__(self):
-                       return "Babeltrace FieldDecl: name {}".format(self.get_name())
+                       return "Babeltrace FieldDecl: name {0}".format(self.get_name())
 
                def get_name(self):
                        """Return the name of a FieldDecl or None on error"""
@@ -1085,7 +1085,7 @@ class File(object):
                        stat = 'opened'
                else:
                        stat = 'closed'
-               return "{} babeltrace File; file_path('{}'), mode('{}')".format(
+               return "{0} babeltrace File; file_path('{1}'), mode('{2}')".format(
                        stat, self._file_path, self._mode)
 
        def close(self):
This page took 0.028588 seconds and 4 git commands to generate.