Replace any alternate token by its original counterpart. In order to comply with the google rule stating that unary operators should never be followed by a space, an exception is made for the 'not' and 'compl' alternate tokens. For these, any trailing space is removed during the con
(line)
| 2120 | |
| 2121 | |
| 2122 | def ReplaceAlternateTokens(line): |
| 2123 | """Replace any alternate token by its original counterpart. |
| 2124 | |
| 2125 | In order to comply with the google rule stating that unary operators should |
| 2126 | never be followed by a space, an exception is made for the 'not' and 'compl' |
| 2127 | alternate tokens. For these, any trailing space is removed during the |
| 2128 | conversion. |
| 2129 | |
| 2130 | Args: |
| 2131 | line: The line being processed. |
| 2132 | |
| 2133 | Returns: |
| 2134 | The line with alternate tokens replaced. |
| 2135 | """ |
| 2136 | for match in _ALT_TOKEN_REPLACEMENT_PATTERN.finditer(line): |
| 2137 | token = _ALT_TOKEN_REPLACEMENT[match.group(2)] |
| 2138 | tail = "" if match.group(2) in ["not", "compl"] and match.group(3) == " " else r"\3" |
| 2139 | line = re.sub(match.re, rf"\1{token}{tail}", line, count=1) |
| 2140 | return line |
| 2141 | |
| 2142 | |
| 2143 | class CleansedLines: |
no outgoing calls
no test coverage detected
searching dependent graphs…