Commit 510a5151 authored by Christophe Bedard's avatar Christophe Bedard

Add is_trace_directory() util function

parent caac5caf
Pipeline #88442700 passed with stage
in 9 minutes and 52 seconds
......@@ -14,6 +14,7 @@
"""Module with functions for reading traces."""
import os
from typing import Iterable
from typing import List
......@@ -25,6 +26,22 @@ from . import DictEvent
BabeltraceEvent = babeltrace.babeltrace.Event
def is_trace_directory(path: str) -> bool:
Check recursively if a path is a trace directory.
:param path: the path to check
:return: `True` if it is a trace directory, `False` otherwise
path = os.path.expanduser(path)
if not os.path.isdir(path):
return False
tc = babeltrace.TraceCollection()
# Could still return an empty dict even if it is not a trace directory (recursively)
traces = tc.add_traces_recursive(path, 'ctf')
return traces is not None and len(traces) > 0
def get_trace_ctf_events(trace_directory: str) -> Iterable[BabeltraceEvent]:
Get the events of a trace.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment