Skip to content

Commit

Permalink
Add __repr__ to Pythom Group and HorizonalChoice to fix #101 (#102)
Browse files Browse the repository at this point in the history
* Group is missing a repr().

* HorizontalChoice is missing a repr().

* Update railroad.py

---------

Co-authored-by: Tab Atkins Jr <jackalmage@gmail.com>
  • Loading branch information
RossPatterson and tabatkins authored Nov 17, 2023
1 parent c3a16b9 commit 16eda32
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions railroad.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,10 @@ def format(self, x: float, y: float, width: float) -> HorizontalChoice:
)
return self

def __repr__(self) -> str:
items = ", ".join(repr(item) for item in self.items)
return f"HorizontalChoice({items})"


def Optional(item: Node, skip: bool = False) -> Choice:
return Choice(0 if skip else 1, Skip(), item)
Expand Down Expand Up @@ -1219,6 +1223,9 @@ def walk(self, cb: WalkerF) -> None:
if self.label:
self.label.walk(cb)

def __repr__(self) -> str:
return f"Group({repr(self.item)}, label={repr(self.label)})"


class Start(DiagramItem):
def __init__(self, type: str = "simple", label: Opt[str] = None):
Expand Down

0 comments on commit 16eda32

Please sign in to comment.