6171ca2e28e2011ff4754ab86809c7234b00dbd4
1 # Copyright (c) 2016, Matt Layman
6 class Directive(object):
7 """A representation of a result line directive."""
9 skip_pattern
= re
.compile(
11 (?P<whitespace>\s*) # Optional whitespace.
12 (?P<reason>.*) # Slurp up the rest.""",
13 re
.IGNORECASE | re
.VERBOSE
)
14 todo_pattern
= re
.compile(
15 r
"""^TODO\b # The directive name
16 (?P<whitespace>\s*) # Immediately following must be whitespace.
17 (?P<reason>.*) # Slurp up the rest.""",
18 re
.IGNORECASE | re
.VERBOSE
)
20 def __init__(self
, text
):
21 """Initialize the directive by parsing the text.
23 The text is assumed to be everything after a '#\s*' on a result line.
30 match
= self
.skip_pattern
.match(text
)
33 self
._reason
= match
.group('reason')
35 match
= self
.todo_pattern
.match(text
)
37 if match
.group('whitespace'):
40 # Catch the case where the directive has no descriptive text.
41 if match
.group('reason') == '':
43 self
._reason
= match
.group('reason')
47 """Get the entire text."""
52 """Check if the directive is a SKIP type."""
57 """Check if the directive is a TODO type."""
62 """Get the reason for the directive."""
This page took 0.030709 seconds and 3 git commands to generate.