Python bindings: Make examples PEP8 compliant
[babeltrace.git] / bindings / python / examples / example-api-test.py
index 56a8f88f4c84c1e58dad4a079eb47fca717b76b4..c1c6f42eac7ee1bd700de449ffbfdaf7c1663107 100644 (file)
@@ -25,36 +25,36 @@ from babeltrace import *
 
 # Check for path arg:
 if len(sys.argv) < 2:
-       raise TypeError("Usage: python example-api-test.py path/to/file")
+    raise TypeError("Usage: python example-api-test.py path/to/file")
 
 # Create TraceCollection and add trace:
 traces = 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
 print("--- Event list ---")
 for event_declaration in trace_handle.events:
-       print("event : {}".format(event_declaration.name))
-       if event_declaration.name == "sched_switch":
-               for field_declaration in event_declaration.fields:
-                       print(field_declaration)
+    print("event : {}".format(event_declaration.name))
+    if event_declaration.name == "sched_switch":
+        for field_declaration in event_declaration.fields:
+            print(field_declaration)
 print("--- Done ---")
 
 for event in traces.events:
-       print("TS: {}, {} : {}".format(event.timestamp, event.cycles, event.name))
-
-       if event.name == "sched_switch":
-               prev_comm = event["prev_comm"]
-               if prev_comm is None:
-                       print("ERROR: Missing prev_comm context info")
-               else:
-                       print("sched_switch prev_comm: {}".format(prev_comm))
-
-       if event.name == "exit_syscall":
-               ret_code = event["ret"]
-               if ret_code is None:
-                       print("ERROR: Unable to extract ret")
-               else:
-                       print("exit_syscall ret: {}".format(ret_code))
+    print("TS: {}, {} : {}".format(event.timestamp, event.cycles, event.name))
+
+    if event.name == "sched_switch":
+        prev_comm = event["prev_comm"]
+        if prev_comm is None:
+            print("ERROR: Missing prev_comm context info")
+        else:
+            print("sched_switch prev_comm: {}".format(prev_comm))
+
+    if event.name == "exit_syscall":
+        ret_code = event["ret"]
+        if ret_code is None:
+            print("ERROR: Unable to extract ret")
+        else:
+            print("exit_syscall ret: {}".format(ret_code))
This page took 0.025218 seconds and 4 git commands to generate.