Collapses strings and chars on a line to simple "" or '' blocks. We nix strings first so we're not fooled by text like '"http://"' Args: elided: The line being processed. Returns: The line with collapsed strings.
(elided)
| 1211 | |
| 1212 | @staticmethod |
| 1213 | def _CollapseStrings(elided): |
| 1214 | """Collapses strings and chars on a line to simple "" or '' blocks. |
| 1215 | |
| 1216 | We nix strings first so we're not fooled by text like '"http://"' |
| 1217 | |
| 1218 | Args: |
| 1219 | elided: The line being processed. |
| 1220 | |
| 1221 | Returns: |
| 1222 | The line with collapsed strings. |
| 1223 | """ |
| 1224 | if not _RE_PATTERN_INCLUDE.match(elided): |
| 1225 | # Remove escaped characters first to make quote/single quote collapsing |
| 1226 | # basic. Things that look like escaped characters shouldn't occur |
| 1227 | # outside of strings and chars. |
| 1228 | elided = _RE_PATTERN_CLEANSE_LINE_ESCAPES.sub('', elided) |
| 1229 | elided = _RE_PATTERN_CLEANSE_LINE_SINGLE_QUOTES.sub("''", elided) |
| 1230 | elided = _RE_PATTERN_CLEANSE_LINE_DOUBLE_QUOTES.sub('""', elided) |
| 1231 | return elided |
| 1232 | |
| 1233 | |
| 1234 | def FindEndOfExpressionInLine(line, startpos, depth, startchar, endchar): |