1 # SPDX-License-Identifier: BSD-2-Clause
3 # Copyright (c) 2016, Matt Layman
8 class Directive(object):
9 """A representation of a result line directive."""
11 skip_pattern
= re
.compile(
13 (?P<whitespace>\s*) # Optional whitespace.
14 (?P<reason>.*) # Slurp up the rest.""",
15 re
.IGNORECASE | re
.VERBOSE
)
16 todo_pattern
= re
.compile(
17 r
"""^TODO\b # The directive name
18 (?P<whitespace>\s*) # Immediately following must be whitespace.
19 (?P<reason>.*) # Slurp up the rest.""",
20 re
.IGNORECASE | re
.VERBOSE
)
22 def __init__(self
, text
):
23 """Initialize the directive by parsing the text.
25 The text is assumed to be everything after a '#\s*' on a result line.
32 match
= self
.skip_pattern
.match(text
)
35 self
._reason
= match
.group('reason')
37 match
= self
.todo_pattern
.match(text
)
39 if match
.group('whitespace'):
42 # Catch the case where the directive has no descriptive text.
43 if match
.group('reason') == '':
45 self
._reason
= match
.group('reason')
49 """Get the entire text."""
54 """Check if the directive is a SKIP type."""
59 """Check if the directive is a TODO type."""
64 """Get the reason for the directive."""
This page took 0.030948 seconds and 4 git commands to generate.