Returns: string_idx such that @LL[string_idx] is equal to our target (i.e. matched) string, if this line matches the ternary expression requirements listed in the 'Requirements' section of this classes' docstring. OR
(LL: list[Leaf])
| 2052 | |
| 2053 | @staticmethod |
| 2054 | def _else_match(LL: list[Leaf]) -> int | None: |
| 2055 | """ |
| 2056 | Returns: |
| 2057 | string_idx such that @LL[string_idx] is equal to our target (i.e. |
| 2058 | matched) string, if this line matches the ternary expression |
| 2059 | requirements listed in the 'Requirements' section of this classes' |
| 2060 | docstring. |
| 2061 | OR |
| 2062 | None, otherwise. |
| 2063 | """ |
| 2064 | # If this line is a part of a ternary expression and the first leaf |
| 2065 | # contains the "else" keyword... |
| 2066 | if ( |
| 2067 | parent_type(LL[0]) == syms.test |
| 2068 | and LL[0].type == token.NAME |
| 2069 | and LL[0].value == "else" |
| 2070 | ): |
| 2071 | is_valid_index = is_valid_index_factory(LL) |
| 2072 | |
| 2073 | idx = 2 if is_valid_index(1) and is_empty_par(LL[1]) else 1 |
| 2074 | # The next visible leaf MUST contain a string... |
| 2075 | if is_valid_index(idx) and LL[idx].type == token.STRING: |
| 2076 | return idx |
| 2077 | |
| 2078 | return None |
| 2079 | |
| 2080 | @staticmethod |
| 2081 | def _assert_match(LL: list[Leaf]) -> int | None: |
no test coverage detected