MCPcopy Create free account
hub / github.com/TimMcCool/scratchattach / set_fields

Method set_fields

scratchattach/site/project.py:568–594  ·  view source on GitHub ↗

Sets fields. By default, ueses the api.scratch.mit.edu/projects/xxx/ PUT API. Keyword Arguments: use_site_api (bool): When enabled, the fields are set using the scratch.mit.edu/site-api API. This function allows setting more fields than Project.set_f

(self, fields_dict, *, use_site_api=False)

Source from the content-addressed store, hash-verified

566 )
567
568 def set_fields(self, fields_dict, *, use_site_api=False):
569 """
570 Sets fields. By default, ueses the api.scratch.mit.edu/projects/xxx/ PUT API.
571
572 Keyword Arguments:
573 use_site_api (bool):
574 When enabled, the fields are set using the scratch.mit.edu/site-api API.
575 This function allows setting more fields than Project.set_fields.
576 For example, you can also share / unshare the project by setting the "shared" field.
577 According to the Scratch team, this API is deprecated. As of 2024 it's still fully functional though.
578 """
579 self._assert_permission()
580 if use_site_api:
581 r = requests.put(
582 f"https://scratch.mit.edu/site-api/projects/all/{self.id}",
583 headers=self._headers,
584 cookies=self._cookies,
585 json=fields_dict,
586 ).json()
587 else:
588 r = requests.put(
589 f"https://api.scratch.mit.edu/projects/{self.id}",
590 headers=self._headers,
591 cookies=self._cookies,
592 json=fields_dict,
593 ).json()
594 return self._update_from_dict(r)
595
596 def turn_off_commenting(self):
597 """

Callers 6

turn_off_commentingMethod · 0.95
turn_on_commentingMethod · 0.95
toggle_commentingMethod · 0.95
set_titleMethod · 0.95
set_instructionsMethod · 0.95
set_notesMethod · 0.95

Calls 4

_assert_permissionMethod · 0.95
jsonMethod · 0.80
putMethod · 0.80
_update_from_dictMethod · 0.45

Tested by

no test coverage detected