Skip to content

Commit

Permalink
Adding helper classmethod to create a nested And/Or
Browse files Browse the repository at this point in the history
structure from a list of conditions to be joined
  • Loading branch information
constantinius committed Nov 13, 2021
1 parent 235e38a commit e1cc28d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pygeofilter/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ def get_sub_nodes(self):
def get_template(self):
return f"{{}} {self.op.name} {{}}"

@classmethod
def from_items(cls, first, *rest) -> Node:
result = first
for item in rest:
result = cls(result, item)
return result


@dataclass
class And(Combination):
Expand Down

0 comments on commit e1cc28d

Please sign in to comment.