-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.py
More file actions
21 lines (16 loc) · 726 Bytes
/
example.py
File metadata and controls
21 lines (16 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from odata_v4_query import ODataQueryParser, ODataFilterParser
# Create parser instance
parser = ODataQueryParser()
# Parse a complete URL
options = parser.parse_url('https://example.com/odata?$count=true&$top=10&$skip=20')
print('Parsing URL:', options, end='\n\n')
# Parse just the query string
options = parser.parse_query_string("$filter=name eq 'John' and age gt 25")
print('Parsing query string:', options, end='\n\n')
# Parse filter expressions
filter_parser = ODataFilterParser()
ast = filter_parser.parse("name eq 'John' and age gt 25")
print('Parsing filter expression:', ast, end='\n\n')
# Evaluate filter expressions
expr = filter_parser.evaluate(ast)
print('Evaluating filter expression:', expr, end='\n\n')