Skip to content

Commit 3f1a3e5

Browse files
formatting fixes
1 parent c8edf52 commit 3f1a3e5

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/app.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,15 @@
1919
TokenPaginationExtension,
2020
TransactionExtension,
2121
)
22-
2322
from stac_fastapi.extensions.third_party import BulkTransactionExtension
2423

2524
settings = ElasticsearchSettings()
2625
session = Session.create_from_settings(settings)
2726

2827
filter_extension = FilterExtension(client=EsAsyncBaseFiltersClient())
29-
filter_extension.conformance_classes.append("http://www.opengis.net/spec/cql2/1.0/req/advanced-comparison-operators")
28+
filter_extension.conformance_classes.append(
29+
"http://www.opengis.net/spec/cql2/1.0/req/advanced-comparison-operators"
30+
)
3031

3132
extensions = [
3233
TransactionExtension(client=TransactionsClient(session=session), settings=settings),
@@ -36,7 +37,7 @@
3637
SortExtension(),
3738
TokenPaginationExtension(),
3839
ContextExtension(),
39-
filter_extension
40+
filter_extension,
4041
]
4142

4243
post_request_model = create_post_request_model(extensions)

stac_fastapi/elasticsearch/stac_fastapi/elasticsearch/extensions/filter.py

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ def to_es(self):
184184
}
185185
}
186186
elif self.op == AdvancedComparisonOp.like:
187-
return {
188-
"wildcard": {
189-
to_es(self.args[0]): {
190-
"value": cql2_like_to_es(str(to_es(self.args[1]))),
187+
return {
188+
"wildcard": {
189+
to_es(self.args[0]): {
190+
"value": cql2_like_to_es(str(to_es(self.args[1]))),
191191
"boost": 1.0,
192-
"case_insensitive": "true"
192+
"case_insensitive": "true",
193193
}
194194
}
195195
}
@@ -232,23 +232,20 @@ def to_es(arg: Arg):
232232
return arg
233233
else:
234234
raise RuntimeError(f"unknown arg {repr(arg)}")
235-
235+
236236

237237
def cql2_like_to_es(input_string):
238-
"""
239-
Convert arugument in CQL2 ('_' and '%') to Elasticsearch wildcard operators ('?' and '*', respectively). Handle escape characters and
240-
handle Elasticsearch wildcards directly.
241-
"""
238+
"""Convert arugument in CQL2 ('_' and '%') to Elasticsearch wildcard operators ('?' and '*', respectively). Handle escape characters and handle Elasticsearch wildcards directly."""
242239
es_string = ""
243240
escape = False
244241

245242
for char in input_string:
246243
if char == "\\":
247244
escape = True
248-
elif char == '_' and not escape:
249-
es_string += '?'
250-
elif char == '%' and not escape:
251-
es_string += '*'
245+
elif char == "_" and not escape:
246+
es_string += "?"
247+
elif char == "%" and not escape:
248+
es_string += "*"
252249
else:
253250
es_string += char
254251
escape = False

stac_fastapi/elasticsearch/tests/extensions/test_filter.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,9 @@ async def test_search_filter_extension_wildcard_es(app_client, ctx):
285285

286286
@pytest.mark.asyncio
287287
async def test_search_filter_extension_escape_chars(app_client, ctx):
288-
esc_chars = ctx.item["properties"]["landsat:product_id"].replace("_", "\_")[:-1] + "_"
288+
esc_chars = (
289+
ctx.item["properties"]["landsat:product_id"].replace("_", "\\_")[:-1] + "_"
290+
)
289291

290292
params = {
291293
"filter": {
@@ -298,7 +300,7 @@ async def test_search_filter_extension_escape_chars(app_client, ctx):
298300
{"property": "properties.landsat:product_id"},
299301
esc_chars,
300302
],
301-
}
303+
},
302304
],
303305
}
304306
}

0 commit comments

Comments
 (0)