Skip to content

Commit

Permalink
Add __iter__ and __getitem__ to logical operators in filters
Browse files Browse the repository at this point in the history
ref:c24a441cb1250d70c8362c8dc82b2bb8287480a4
  • Loading branch information
ladine0n committed Feb 25, 2021
1 parent 6650369 commit df3df33
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/client/filter.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ def __or__(self, other: FilterCondition):
self.or_.append(other)
return self

def __iter__(self):
return iter(self.or_)

def __getitem__(self, item):
return self.or_.__getitem__(item)

@classmethod
def structure(cls, data):
return super(FilterCondition, cls).structure(data)
Expand All @@ -52,6 +58,12 @@ def __and__(self, other):
self.and_.append(other)
return self

def __iter__(self):
return iter(self.and_)

def __getitem__(self, item):
return self.and_.__getitem__(item)

@classmethod
def structure(cls, data):
return super(FilterCondition, cls).structure(data)
Expand Down

0 comments on commit df3df33

Please sign in to comment.