Add is_trace_directory() util function
This commit is contained in:
parent
caac5cafe3
commit
510a515101
1 changed files with 17 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
||||||
|
|
||||||
"""Module with functions for reading traces."""
|
"""Module with functions for reading traces."""
|
||||||
|
|
||||||
|
import os
|
||||||
from typing import Iterable
|
from typing import Iterable
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
@ -25,6 +26,22 @@ from . import DictEvent
|
||||||
BabeltraceEvent = babeltrace.babeltrace.Event
|
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]:
|
def get_trace_ctf_events(trace_directory: str) -> Iterable[BabeltraceEvent]:
|
||||||
"""
|
"""
|
||||||
Get the events of a trace.
|
Get the events of a trace.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue