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
,
17 todo_pattern
= re
.compile(
18 r
"""^TODO\b # The directive name
19 (?P<whitespace>\s*) # Immediately following must be whitespace.
20 (?P<reason>.*) # Slurp up the rest.""",
21 re
.IGNORECASE | re
.VERBOSE
,
24 def __init__(self
, text
):
25 """Initialize the directive by parsing the text.
27 The text is assumed to be everything after a '#\s*' on a result line.
34 match
= self
.skip_pattern
.match(text
)
37 self
._reason
= match
.group('reason')
39 match
= self
.todo_pattern
.match(text
)
41 if match
.group('whitespace'):
44 # Catch the case where the directive has no descriptive text.
45 if match
.group('reason') == '':
47 self
._reason
= match
.group('reason')
51 """Get the entire text."""
56 """Check if the directive is a SKIP type."""
61 """Check if the directive is a TODO type."""
66 """Get the reason for the directive."""
This page took 0.045143 seconds and 4 git commands to generate.