File tree Expand file tree Collapse file tree 2 files changed +21
-11
lines changed
Expand file tree Collapse file tree 2 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -188,10 +188,17 @@ def install(self):
188188 ):
189189 # load context
190190 context = {"@context" :self .metadata ["@context" ]}
191- if ".jsonld" in self .metadata ["@context" ]:
192- response = requests .get (self .metadata ["@context" ])
193- if response .status_code == 200 :
194- context = response .json ()
191+
192+ # Check if context["@context"] is a URL
193+ if isinstance (context ["@context" ], str ):
194+ # Fetch the external context
195+ external_context_url = context ["@context" ]
196+ response = requests .get (external_context_url )
197+ external_context = response .json ()
198+
199+ # Replace the external URL in your original context with the expanded one
200+ context ["@context" ] = external_context
201+
195202
196203 # add @base to context
197204 context ["@context" ]["@base" ] = str (
Original file line number Diff line number Diff line change @@ -174,12 +174,15 @@ async def download_file(ko_id: str):
174174 ):
175175 # load context
176176 context = {"@context" :Knowledge_Objects [ko_id ].metadata ["@context" ]}
177- if ".jsonld" in Knowledge_Objects [ko_id ].metadata ["@context" ]:
178- response = requests .get (
179- Knowledge_Objects [ko_id ].metadata ["@context" ]
180- )
181- if response .status_code == 200 :
182- context = response .json ()
177+ # Check if context["@context"] is a URL
178+ if isinstance (context ["@context" ], str ):
179+ # Fetch the external context
180+ external_context_url = context ["@context" ]
181+ response = requests .get (external_context_url )
182+ external_context = response .json ()
183+
184+ # Replace the external URL in your original context with the expanded one
185+ context ["@context" ] = external_context
183186
184187 # add @base to context
185188 context ["@context" ]["@base" ] = str (
@@ -199,7 +202,7 @@ async def download_file(ko_id: str):
199202
200203 # use resolved hasServiceSpcification
201204 full_path = service [0 ].get (
202- "http ://kgrid.org/koio#hasServiceSpcification "
205+ "https ://kgrid.org/koio#hasServiceSpecification "
203206 )[0 ]["@id" ]
204207 break
205208 except Exception as e :
You can’t perform that action at this time.
0 commit comments