diff options
author | Sergei Trofimov <sergei.trofimov@arm.com> | 2018-05-11 15:42:33 +0100 |
---|---|---|
committer | Marc Bonnici <marc.bonnici@arm.com> | 2018-05-14 17:05:06 +0100 |
commit | 795b3485ce18b56946300215403de7485af5c488 (patch) | |
tree | bc93d3cd9ed73f345315e97856565b74aa68b98e /wa/utils | |
parent | ed1553816b1e597a4904196ce54917ac32d40cc7 (diff) |
utils/trace_cmd: move params to __init__()
Move the check_for_markers and events parameters from parser() to
__init__(). These parameters control the behavior of the parser, and do
not relate to a particular trace file, so it makes more sense to have
them there.
Diffstat (limited to 'wa/utils')
-rw-r--r-- | wa/utils/trace_cmd.py | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/wa/utils/trace_cmd.py b/wa/utils/trace_cmd.py index 72c479f0..b308f41a 100644 --- a/wa/utils/trace_cmd.py +++ b/wa/utils/trace_cmd.py @@ -235,7 +235,7 @@ class TraceCmdParser(object): """ - def __init__(self, filter_markers=True): + def __init__(self, filter_markers=True, check_for_markers=True, events=None): """ Initialize a new trace parser. @@ -245,27 +245,29 @@ class TraceCmdParser(object): markers will be reported). This maybe overriden based on `check_for_markers` parameter of `parse()` + :param check_for_markers: Check if the start/stop markers are present + in the trace and ensure that `filter_markers` + is `False` if they aren't + :param events: A list of event names to be reported; if not specified, + all events will be reported. + """ self.filter_markers = filter_markers + self.check_for_markers = check_for_markers + self.events = events - def parse(self, filepath, events=None, check_for_markers=True): # pylint: disable=too-many-branches,too-many-locals + def parse(self, filepath): # pylint: disable=too-many-branches,too-many-locals """ This is a generator for the trace event stream. :param filepath: The path to the file containg text trace as reported by trace-cmd - :param events: A list of event names to be reported; if not specified, - all events will be reported. - :param check_for_markers: Check if the start/stop markers are present - in the trace and ensure that `filter_markers` - is `False` if they aren't - """ inside_maked_region = False - filters = [re.compile('^{}$'.format(e)) for e in (events or [])] + filters = [re.compile('^{}$'.format(e)) for e in (self.events or [])] filter_markers = self.filter_markers - if filter_markers and check_for_markers: + if filter_markers and self.check_for_markers: with open(filepath) as fh: for line in fh: if TRACE_MARKER_START in line: |