Split a string on all unquoted newlines. Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite character is inside of a string.
(stmt)
| 34 | |
| 35 | |
| 36 | def split_unquoted_newlines(stmt): |
| 37 | """Split a string on all unquoted newlines. |
| 38 | |
| 39 | Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite |
| 40 | character is inside of a string.""" |
| 41 | text = str(stmt) |
| 42 | lines = SPLIT_REGEX.split(text) |
| 43 | outputlines = [''] |
| 44 | for line in lines: |
| 45 | if not line: |
| 46 | continue |
| 47 | elif LINE_MATCH.match(line): |
| 48 | outputlines.append('') |
| 49 | else: |
| 50 | outputlines[-1] += line |
| 51 | return outputlines |
| 52 | |
| 53 | |
| 54 | def remove_quotes(val): |