MCPcopy Create free account
hub / github.com/bugy/script-server / load_script

Method load_script

src/config/config_service.py:220–239  ·  view source on GitHub ↗
(path, content)

Source from the content-addressed store, hash-verified

218 has_admin_rights = self._authorizer.is_admin(user.user_id)
219
220 def load_script(path, content) -> Optional[ShortConfig]:
221 try:
222 config_object = self.load_config_file(path, content)
223 short_config = script_config.read_short(path, config_object)
224
225 if short_config is None:
226 return None
227
228 if edit_mode and (not conf_service._can_edit_script(user, short_config)):
229 return None
230
231 if (not edit_mode) and (not conf_service._can_access_script(user, short_config)):
232 return None
233
234 return short_config
235 except json.decoder.JSONDecodeError:
236 LOGGER.exception(CorruptConfigFileException.VERBOSE_ERROR + ': ' + path)
237 return create_failed_short_config(path, has_admin_rights)
238 except Exception:
239 LOGGER.exception('Could not load script: ' + path)
240
241 return self._visit_script_configs(load_script)
242

Callers

nothing calls this directly

Calls 4

load_config_fileMethod · 0.95
_can_edit_scriptMethod · 0.80
_can_access_scriptMethod · 0.80

Tested by

no test coverage detected