MCPcopy Index your code
hub / github.com/praw-dev/praw / update

Method update

praw/models/reddit/widgets.py:1805–1833  ·  view source on GitHub ↗

Update the widget. Returns the updated widget. Parameters differ based on the type of widget. See `Reddit documentation `_ or the document of the particular type of widget. :returns: The updated :class:`.Wid

(self, **kwargs: Any)

Source from the content-addressed store, hash-verified

1803 self._reddit.delete(path)
1804
1805 def update(self, **kwargs: Any) -> Widget:
1806 """Update the widget. Returns the updated widget.
1807
1808 Parameters differ based on the type of widget. See `Reddit documentation
1809 <https://www.reddit.com/dev/api#PUT_api_widget_{widget_id}>`_ or the document of
1810 the particular type of widget.
1811
1812 :returns: The updated :class:`.Widget`.
1813
1814 For example, update a text widget like so:
1815
1816 .. code-block:: python
1817
1818 text_widget.mod.update(shortName="New text area", text="Hello!")
1819
1820 .. note::
1821
1822 Most parameters follow the ``lowerCamelCase`` convention. When in doubt,
1823 check the Reddit documentation linked above.
1824
1825 """
1826 path = API_PATH["widget_modify"].format(subreddit=self._subreddit, widget_id=self.widget.id)
1827 payload = {key: value for key, value in vars(self.widget).items() if not key.startswith("_")}
1828 del payload["subreddit"] # not JSON serializable
1829 payload.pop("mod", None)
1830 payload.update(kwargs)
1831 widget = self._reddit.put(path, data={"json": dumps(payload, cls=WidgetEncoder)})
1832 widget.subreddit = self._subreddit
1833 return widget

Callers 8

add_button_widgetMethod · 0.45
add_calendarMethod · 0.45
add_community_listMethod · 0.45
add_custom_widgetMethod · 0.45
add_image_widgetMethod · 0.45
add_menuMethod · 0.45
add_post_flair_widgetMethod · 0.45
add_text_areaMethod · 0.45

Calls 2

itemsMethod · 0.80
putMethod · 0.80

Tested by

no test coverage detected