Determine if the input source ends in two blanks. A blank is either a newline or a line consisting of whitespace. Parameters ---------- src : string A single or multiline string.
(src)
| 221 | last_two_blanks_re2 = re.compile(r'.+\n\s*\n\s+$', re.MULTILINE) |
| 222 | |
| 223 | def last_two_blanks(src): |
| 224 | """Determine if the input source ends in two blanks. |
| 225 | |
| 226 | A blank is either a newline or a line consisting of whitespace. |
| 227 | |
| 228 | Parameters |
| 229 | ---------- |
| 230 | src : string |
| 231 | A single or multiline string. |
| 232 | """ |
| 233 | if not src: return False |
| 234 | # The logic here is tricky: I couldn't get a regexp to work and pass all |
| 235 | # the tests, so I took a different approach: split the source by lines, |
| 236 | # grab the last two and prepend '###\n' as a stand-in for whatever was in |
| 237 | # the body before the last two lines. Then, with that structure, it's |
| 238 | # possible to analyze with two regexps. Not the most elegant solution, but |
| 239 | # it works. If anyone tries to change this logic, make sure to validate |
| 240 | # the whole test suite first! |
| 241 | new_src = '\n'.join(['###\n'] + src.splitlines()[-2:]) |
| 242 | return (bool(last_two_blanks_re.match(new_src)) or |
| 243 | bool(last_two_blanks_re2.match(new_src)) ) |
| 244 | |
| 245 | |
| 246 | def remove_comments(src): |
nothing calls this directly
no outgoing calls
no test coverage detected