Return the REQ's pattern tag from a REQUIREMENTS.md block, or None. Raises ValueError when the block carries an invalid pattern value. Valid values are VALID_PATTERN_VALUES. Absent field returns None.
(req_block)
| 76 | |
| 77 | |
| 78 | def extract_req_pattern(req_block): |
| 79 | """Return the REQ's pattern tag from a REQUIREMENTS.md block, or None. |
| 80 | |
| 81 | Raises ValueError when the block carries an invalid pattern value. Valid |
| 82 | values are VALID_PATTERN_VALUES. Absent field returns None. |
| 83 | """ |
| 84 | m = _REQ_PATTERN_RE.search(req_block) |
| 85 | if not m: |
| 86 | return None |
| 87 | value = m.group(1).strip() |
| 88 | if value not in VALID_PATTERN_VALUES: |
| 89 | raise ValueError( |
| 90 | "Invalid REQ pattern '{}'. Expected one of: {}".format( |
| 91 | value, sorted(VALID_PATTERN_VALUES) |
| 92 | ) |
| 93 | ) |
| 94 | return value |
| 95 | |
| 96 | |
| 97 | # v1.5.2 — cardinality gate (Lever 3) |
no test coverage detected