2727
2828logger = logging .getLogger ("smartAPI" )
2929
30+
3031def github_authenticated (func ):
3132 """
3233 RegistryHandler Decorator
@@ -44,6 +45,7 @@ def _(self, *args, **kwargs):
4445class BaseHandler (BioThingsAuthnMixin , BaseAPIHandler ):
4546 pass
4647
48+
4749class AuthHandler (BaseHandler ):
4850 def set_cache_header (self , cache_value ):
4951 # disabel cache for auth-related handlers
@@ -418,7 +420,7 @@ def get_filtered_api(self, api_dict):
418420 filtered_api = api_info .copy ()
419421 if not bte :
420422 filtered_api .pop ("bte" , None )
421-
423+
422424 # Handle case where "ui" key exists and ends with "None"
423425 if filtered_api .get ('smartapi' , {}).get ("ui" , "" ).endswith ("/None" ):
424426 filtered_api ["smartapi" ]["ui" ] = None
@@ -441,51 +443,6 @@ def get_filtered_api(self, api_dict):
441443 filtered_dict ["bte" ] = filtered_dict ["api" ].pop ("bte" )
442444
443445 return filtered_dict
444- # # Default structure to preserve top-level keys
445- # filtered_dict = {
446- # key: api_dict.get(key)
447- # for key in ["subject", "object", "predicate", "subject_prefix", "object_prefix"]
448- # if key in api_dict
449- # }
450-
451- # # Determine filtered API structure based on `bte` and `api_details`
452- # if bte == 1 and api_details == 0:
453- # filtered_api = {
454- # **({"name": api_info.get("name")} if "name" in api_info else {}),
455- # **(
456- # {"smartapi": {"id": api_info.get("smartapi", {}).get("id", None)}}
457- # if "smartapi" in api_info
458- # else {"smartapi": {"id": None}}
459- # ),
460- # "bte": api_info.get("bte", {}),
461- # }
462- # elif api_details == 1:
463- # # Covers both (bte=0, api_details=1) and (bte=1, api_details=1)
464- # filtered_api = api_info.copy()
465- # if bte == 0:
466- # filtered_api.pop("bte", None)
467- # # Check if the "ui" key exists and ends with "None"
468- # if filtered_api['smartapi'].get("ui", "").endswith("/None"):
469- # filtered_api["smartapi"]["ui"] = None
470- # else: # bte == 0 and api_details == 0
471- # filtered_api = {
472- # **({"name": api_info.get("name")} if "name" in api_info else {}),
473- # **(
474- # {"smartapi": {"id": api_info.get("smartapi", {}).get("id", None)}}
475- # if "smartapi" in api_info
476- # else {"smartapi": {"id": None}}
477- # ),
478- # }
479-
480- # # Add the filtered 'api' key to the preserved top-level structure
481- # filtered_dict["api"] = filtered_api
482-
483- # # Remove 'bte' from 'api' and move it to the top level
484- # if "bte" in filtered_dict["api"]:
485- # filtered_dict["bte"] = filtered_dict["api"].pop("bte")
486-
487-
488- # return filtered_dict
489446
490447
491448class MetaKGQueryHandler (QueryHandler , MetaKGHandlerMixin ):
@@ -564,7 +521,6 @@ async def get(self, *args, **kwargs):
564521 value_list = get_expanded_values (value_list , self .biolink_model_toolkit ) if expanded_fields [field ] else value_list
565522 setattr (self .args , field , value_list )
566523
567-
568524 await super ().get (* args , ** kwargs )
569525
570526 def process_apis (self , apis ):
@@ -576,9 +532,9 @@ def process_apis(self, apis):
576532 elif isinstance (apis , dict ):
577533 if 'bte' in apis :
578534 # update dict for new format
579- apis ['api' ]['bte' ]= apis .pop ('bte' )
535+ apis ['api' ]['bte' ] = apis .pop ('bte' )
580536 api_dict = apis ["api" ]
581- filtered_api = self .get_filtered_api (api_dict )
537+ filtered_api = self .get_filtered_api (api_dict )
582538 apis ["api" ] = filtered_api
583539
584540 def write (self , chunk ):
@@ -610,7 +566,7 @@ def write(self, chunk):
610566
611567 if self .format == "html" :
612568 # setup template
613- template_path = os .path .abspath (os .path .join (os .path .dirname ( __file__ ), '..' , 'templates' ))
569+ template_path = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' , 'templates' ))
614570 loader = Loader (template_path )
615571 template = loader .load ("cytoscape.html" )
616572 # initial counts
@@ -627,7 +583,7 @@ def write(self, chunk):
627583 graph_data = serializer .to_json (cdf .get_data ())
628584 # generate global template variable with graph data
629585 result = template .generate (
630- data = graph_data ,
586+ data = graph_data ,
631587 response = serializer .to_json (chunk ),
632588 shown = shown ,
633589 available = available ,
0 commit comments