@@ -414,7 +414,9 @@ def _list_arg(arg: list):
414
414
"""
415
415
if isinstance (arg , str ):
416
416
arg = list (arg )
417
- return [json .loads (a .replace ("'" , '"' )) if isinstance (a , str ) else a for a in arg ]
417
+ return list (
418
+ map (lambda a : json .loads (a .replace ("'" , '"' )) if isinstance (a , str ) else a , arg )
419
+ )
418
420
419
421
420
422
# Search
@@ -506,20 +508,20 @@ def next_page_url(next_offset):
506
508
507
509
feature_collection .extra_fields ["links" ].extend (
508
510
(
509
- {
510
- " href" : url_for (".stac_search" ),
511
- " rel" : "search" ,
512
- " title" : "Search" ,
513
- " type" : "application/geo+json" ,
514
- " method" : "GET" ,
515
- } ,
516
- {
517
- " href" : url_for (".stac_search" ),
518
- " rel" : "search" ,
519
- " title" : "Search" ,
520
- " type" : "application/geo+json" ,
521
- " method" : "POST" ,
522
- } ,
511
+ dict (
512
+ href = url_for (".stac_search" ),
513
+ rel = "search" ,
514
+ title = "Search" ,
515
+ type = "application/geo+json" ,
516
+ method = "GET" ,
517
+ ) ,
518
+ dict (
519
+ href = url_for (".stac_search" ),
520
+ rel = "search" ,
521
+ title = "Search" ,
522
+ type = "application/geo+json" ,
523
+ method = "POST" ,
524
+ ) ,
523
525
)
524
526
)
525
527
return feature_collection
@@ -747,18 +749,18 @@ def search_stac_items(
747
749
page = 0
748
750
if limit != 0 :
749
751
page = offset // limit
750
- extra_properties = {
751
- " links" : [],
752
+ extra_properties = dict (
753
+ links = [],
752
754
# Stac standard
753
- " numberReturned" : len (returned ),
755
+ numberReturned = len (returned ),
754
756
# Compatibility with older implementation. Was removed from stac-api standard.
755
757
# (page numbers + limits are not ideal as they prevent some big db optimisations.)
756
- " context" : {
757
- " page" : page ,
758
- " limit" : limit ,
759
- " returned" : len (returned ),
760
- } ,
761
- }
758
+ context = dict (
759
+ page = page ,
760
+ limit = limit ,
761
+ returned = len (returned ),
762
+ ) ,
763
+ )
762
764
if include_total_count :
763
765
count_matching = _model .STORE .get_count (
764
766
product_names = product_names , time = time , bbox = bbox , dataset_ids = dataset_ids
@@ -775,34 +777,34 @@ def search_stac_items(
775
777
result = ItemCollection (items , extra_fields = extra_properties )
776
778
777
779
if there_are_more :
778
- next_link = {
779
- " rel" : "next" ,
780
- " title" : "Next page of Items" ,
781
- " type" : "application/geo+json" ,
782
- }
780
+ next_link = dict (
781
+ rel = "next" ,
782
+ title = "Next page of Items" ,
783
+ type = "application/geo+json" ,
784
+ )
783
785
if use_post_request :
784
786
next_link .update (
785
- {
786
- " method" : "POST" ,
787
- " merge" : True ,
787
+ dict (
788
+ method = "POST" ,
789
+ merge = True ,
788
790
# Unlike GET requests, we can tell them to repeat their same request args
789
791
# themselves.
790
792
#
791
793
# Same URL:
792
- " href" : flask .request .url ,
794
+ href = flask .request .url ,
793
795
# ... with a new offset.
794
- " body" : {
795
- "_o" : offset + limit ,
796
- } ,
797
- }
796
+ body = dict (
797
+ _o = offset + limit ,
798
+ ) ,
799
+ )
798
800
)
799
801
else :
800
802
# Otherwise, let the route create the next url.
801
803
next_link .update (
802
- {
803
- " method" : "GET" ,
804
- " href" : get_next_url (offset + limit ),
805
- }
804
+ dict (
805
+ method = "GET" ,
806
+ href = get_next_url (offset + limit ),
807
+ )
806
808
)
807
809
808
810
result .extra_fields ["links" ].append (next_link )
@@ -904,10 +906,10 @@ def _geojson_stac_response(doc: Union[STACObject, ItemCollection]) -> flask.Resp
904
906
905
907
def stac_endpoint_information () -> Dict :
906
908
config = _model .app .config
907
- o = {
908
- "id" : config .get ("STAC_ENDPOINT_ID" , "odc-explorer" ),
909
- " title" : config .get ("STAC_ENDPOINT_TITLE" , "Default ODC Explorer instance" ),
910
- }
909
+ o = dict (
910
+ id = config .get ("STAC_ENDPOINT_ID" , "odc-explorer" ),
911
+ title = config .get ("STAC_ENDPOINT_TITLE" , "Default ODC Explorer instance" ),
912
+ )
911
913
description = config .get (
912
914
"STAC_ENDPOINT_DESCRIPTION" ,
913
915
"Configure stac endpoint information in your Explorer `settings.env.py` file" ,
@@ -995,7 +997,7 @@ def root():
995
997
"http://www.opengis.net/spec/ogcapi-features-3/1.0/conf/filter" ,
996
998
"https://api.stacspec.org/v1.0.0-rc.1/collections" ,
997
999
]
998
- c .extra_fields = { " conformsTo" : conformance_classes }
1000
+ c .extra_fields = dict ( conformsTo = conformance_classes )
999
1001
1000
1002
return _stac_response (c )
1001
1003
@@ -1033,18 +1035,18 @@ def collections():
1033
1035
an array (instead of just a link to each collection).
1034
1036
"""
1035
1037
return _utils .as_json (
1036
- {
1037
- " links" : [
1038
- { " rel" : " self" , " type" : " application/json" , " href" : request .url } ,
1039
- { " rel" : " root" , " type" : " application/json" , " href" : url_for (".root" )} ,
1040
- { " rel" : " parent" , " type" : " application/json" , " href" : url_for (".root" )} ,
1038
+ dict (
1039
+ links = [
1040
+ dict ( rel = " self" , type = " application/json" , href = request .url ) ,
1041
+ dict ( rel = " root" , type = " application/json" , href = url_for (".root" )) ,
1042
+ dict ( rel = " parent" , type = " application/json" , href = url_for (".root" )) ,
1041
1043
],
1042
- " collections" : [
1044
+ collections = [
1043
1045
# TODO: This has a root link, right?
1044
1046
_stac_collection (product .name ).to_dict ()
1045
1047
for product , product_summary in _model .get_products_with_summaries ()
1046
1048
],
1047
- }
1049
+ )
1048
1050
)
1049
1051
1050
1052
0 commit comments