Given a match and a query location of query string return a tuple of wrapped texts at `width` for: - the matched query text as a string. - the matched rule text as a string. If `width` is a number superior to zero, the texts are wrapped to width.
(match, width=80, margin=0)
| 16 | |
| 17 | |
| 18 | def get_texts(match, width=80, margin=0): |
| 19 | """ |
| 20 | Given a match and a query location of query string return a tuple of wrapped |
| 21 | texts at `width` for: |
| 22 | |
| 23 | - the matched query text as a string. |
| 24 | - the matched rule text as a string. |
| 25 | |
| 26 | If `width` is a number superior to zero, the texts are wrapped to width. |
| 27 | """ |
| 28 | qtokens = match.matched_text(whole_lines=False).split() |
| 29 | mqt = format_text(tokens=qtokens, width=width, margin=margin) |
| 30 | if match.matcher == '6-unknown': |
| 31 | itokens = match.rule.text.split() |
| 32 | else: |
| 33 | itokens = matched_rule_tokens_str(match) |
| 34 | mit = format_text(tokens=itokens, width=width, margin=margin) |
| 35 | |
| 36 | return mqt, mit |
| 37 | |
| 38 | |
| 39 | def format_text(tokens, width=80, margin=4): |