Skip to content

Commit

Permalink
key class repr
Browse files Browse the repository at this point in the history
  • Loading branch information
ASEM000 committed Oct 4, 2023
1 parent c7f0f59 commit 8ad20b0
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sepes/_src/tree_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ def _(self, other: int) -> bool:
def _(self, other: SequenceKeyType) -> bool:
return self.idx == other.idx

def __repr__(self) -> str:
return f"{self.idx}"


class NameKey(BaseKey):
def __init__(self, name: str) -> None:
Expand All @@ -204,6 +207,9 @@ def _(self, other: GetAttrKeyType) -> bool:
def _(self, other: DictKeyType) -> bool:
return self.name == other.key

def __repr__(self) -> str:
return f"{self.name}"


class EllipsisKey(BaseKey):
"""Match all leaves."""
Expand All @@ -214,6 +220,9 @@ def __init__(self, _):
def __eq__(self, _: KeyEntry) -> bool:
return True

def __repr__(self) -> str:
return "..."


class MultiKey(BaseKey):
"""Match a leaf with multiple keys at the same level."""
Expand Down Expand Up @@ -264,6 +273,9 @@ def _(self, other) -> bool:
def _(self, other) -> bool:
return re.fullmatch(self.pattern, other.key) is not None

def __repr__(self) -> str:
return f"{self.pattern}"


# dispatch on type of indexer to convert input item to at indexer
# `__getitem__` to the appropriate key
Expand Down

0 comments on commit 8ad20b0

Please sign in to comment.