Tests: Multi-trace stream intersection test
[babeltrace.git] / bindings / python / examples / sequence_test.py
index cf0e2c8ed3154c942bf796ec0298dd735c407f5a..e9116ced652080bb02cb55f7b02284491d1cd87c 100644 (file)
 #
 # The above copyright notice and this permission notice shall be included in
 # all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
 
 # This example uses the babeltrace python module
 # to partially test the sequence API
 
 import sys
-from babeltrace import *
+import babeltrace.reader
+
 
 # Check for path arg:
 if len(sys.argv) < 2:
-       raise TypeError("Usage: sequence_test.py path/to/file")
+    raise TypeError("Usage: sequence_test.py path/to/file")
 
 # Create TraceCollection and add trace:
-traces = TraceCollection()
+traces = babeltrace.reader.TraceCollection()
 trace_handle = traces.add_trace(sys.argv[1], "ctf")
 if trace_handle is None:
-       raise IOError("Error adding trace")
+    raise IOError("Error adding trace")
 
 # Listing events
-lst = get_event_decl_list(trace_handle, traces)
 print("--- Event list ---")
-for item in lst:
-       print("event : {}".format(item.get_name()))
+for event_declaration in trace_handle.events:
+    print("event : {}".format(event_declaration.name))
 print("--- Done ---")
 
 for event in traces.events:
-       print("TS: {}, {} : {}".format(event.timestamp,
-               event.cycles, event.name))
-
-       try:
-               sequence = event["seq_int_field"]
-               print("int sequence values: {}". format(sequence))
-       except KeyError:
-               pass
-
-       try:
-               sequence = event["seq_long_field"]
-               print("long sequence values: {}". format(sequence))
-       except KeyError:
-               pass
+    print("TS: {}, {} : {}".format(event.timestamp,
+                                   event.cycles, event.name))
+
+    try:
+        sequence = event["seq_int_field"]
+        print("int sequence values: {}". format(sequence))
+    except KeyError:
+        pass
+
+    try:
+        sequence = event["seq_long_field"]
+        print("long sequence values: {}". format(sequence))
+    except KeyError:
+        pass
This page took 0.024221 seconds and 4 git commands to generate.