| 99 | | # FIXME: for now, rather than changing PyParse, I'm converting |
| 100 | | # everything to newlines because PyParse is hardcoded for newlines |
| 101 | | # only |
| 102 | | if stc.getLinesep() == "\r\n": |
| 103 | | #dprint("Converting windows!") |
| 104 | | rawtext = rawtext.replace("\r\n", "\n") |
| 105 | | elif stc.getLinesep() == "\r": |
| 106 | | #dprint("Converting old mac!") |
| 107 | | rawtext = rawtext.replace("\r", "\n") |
| 108 | | y.set_str(rawtext+"\n") |
| | 99 | # Handle two issues with this loop. 1: Remove comments that start |
| | 100 | # at column zero so they don't affect the indenting. 2: PyParse |
| | 101 | # is hardcoded for "\n" style newlines only, so by splitting the |
| | 102 | # lines here we can change whatever the newlines are into "\n" |
| | 103 | # characters. |
| | 104 | lines = [] |
| | 105 | for line in rawtext.splitlines(): |
| | 106 | if len(line) > 0: |
| | 107 | if line[0] != '#': |
| | 108 | lines.append(line) |
| | 109 | lines.append('') # include a blank line at the end |
| | 110 | rawtext = "\n".join(lines) |
| | 111 | y.set_str(rawtext) |