| 156 | |
| 157 | |
| 158 | class Alt: |
| 159 | def __init__(self, items: list[NamedItem], *, icut: int = -1, action: str | None = None): |
| 160 | self.items = items |
| 161 | self.icut = icut |
| 162 | self.action = action |
| 163 | |
| 164 | def __str__(self) -> str: |
| 165 | core = " ".join(str(item) for item in self.items) |
| 166 | if not SIMPLE_STR and self.action: |
| 167 | return f"{core} {{ {self.action} }}" |
| 168 | else: |
| 169 | return core |
| 170 | |
| 171 | def __repr__(self) -> str: |
| 172 | args = [repr(self.items)] |
| 173 | if self.icut >= 0: |
| 174 | args.append(f"icut={self.icut}") |
| 175 | if self.action: |
| 176 | args.append(f"action={self.action!r}") |
| 177 | return f"Alt({', '.join(args)})" |
| 178 | |
| 179 | def __iter__(self) -> Iterator[list[NamedItem]]: |
| 180 | yield self.items |
| 181 | |
| 182 | |
| 183 | class NamedItem: |
no outgoing calls
no test coverage detected