SubredditStylesheet¶
- class praw.models.reddit.subreddit.SubredditStylesheet(subreddit)¶
Provides a set of stylesheet functions to a
Subreddit.For example, to add the css data
.test{color:blue}to the existing stylesheet:subreddit = reddit.subreddit("test") stylesheet = subreddit.stylesheet() stylesheet.stylesheet += ".test{color:blue}" subreddit.stylesheet.update(stylesheet.stylesheet)
- Parameters:
subreddit (models.Subreddit)
- __call__()¶
Return the
Subreddit’s stylesheet.To be used as:
stylesheet = reddit.subreddit("test").stylesheet()
- Return type:
- __init__(subreddit)¶
Initialize a
SubredditStylesheetinstance.An instance of this class is provided as:
reddit.subreddit("test").stylesheet
- delete_banner()¶
Remove the current
Subreddit(redesign) banner image.Succeeds even if there is no banner image.
For example:
reddit.subreddit("test").stylesheet.delete_banner()
- Return type:
- delete_banner_additional_image()¶
Remove the current
Subreddit(redesign) banner additional image.Succeeds even if there is no additional image. Will also delete any configured hover image.
For example:
reddit.subreddit("test").stylesheet.delete_banner_additional_image()
- Return type:
- delete_banner_hover_image()¶
Remove the current
Subreddit(redesign) banner hover image.Succeeds even if there is no hover image.
For example:
reddit.subreddit("test").stylesheet.delete_banner_hover_image()
- Return type:
- delete_header()¶
Remove the current
Subredditheader image.Succeeds even if there is no header image.
For example:
reddit.subreddit("test").stylesheet.delete_header()
- Return type:
- delete_image(name)¶
Remove the named image from the
Subreddit.Succeeds even if the named image does not exist.
For example:
reddit.subreddit("test").stylesheet.delete_image("smile")
- delete_mobile_banner()¶
Remove the current
Subreddit(redesign) mobile banner.Succeeds even if there is no mobile banner.
For example:
subreddit = reddit.subreddit("test") subreddit.stylesheet.delete_banner_hover_image()
- Return type:
- delete_mobile_header()¶
Remove the current
Subredditmobile header.Succeeds even if there is no mobile header.
For example:
reddit.subreddit("test").stylesheet.delete_mobile_header()
- Return type:
- delete_mobile_icon()¶
Remove the current
Subredditmobile icon.Succeeds even if there is no mobile icon.
For example:
reddit.subreddit("test").stylesheet.delete_mobile_icon()
- Return type:
- update(stylesheet, *, reason=None)¶
Update the
Subreddit’s stylesheet.- Parameters:
- Return type:
For example:
reddit.subreddit("test").stylesheet.update( "p { color: green; }", reason="color text green" )
- upload(*, image_path, name)¶
Upload an image to the
Subreddit.- Parameters:
- Return type:
- Returns:
A dictionary containing a link to the uploaded image under the key
img_src.- Raises:
prawcore.TooLargeif the overall request body is too large.- Raises:
RedditAPIExceptionif there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.
For example:
reddit.subreddit("test").stylesheet.upload(name="smile", image_path="img.png")
- upload_banner(image_path)¶
Upload an image for the
Subreddit’s (redesign) banner image.- Parameters:
image_path (
str) – A path to a jpeg or png image.- Raises:
prawcore.TooLargeif the overall request body is too large.- Raises:
RedditAPIExceptionif there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.- Return type:
For example:
reddit.subreddit("test").stylesheet.upload_banner("banner.png")
- upload_banner_additional_image(image_path, *, align=None)¶
Upload an image for the
Subreddit’s (redesign) additional image.- Parameters:
- Raises:
prawcore.TooLargeif the overall request body is too large.- Raises:
RedditAPIExceptionif there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.- Return type:
For example:
subreddit = reddit.subreddit("test") subreddit.stylesheet.upload_banner_additional_image("banner.png")
- upload_banner_hover_image(image_path)¶
Upload an image for the
Subreddit’s (redesign) additional image.Fails if the
Subredditdoes not have an additional image defined.- Raises:
prawcore.TooLargeif the overall request body is too large.- Raises:
RedditAPIExceptionif there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.- Parameters:
image_path (str)
- Return type:
None
For example:
subreddit = reddit.subreddit("test") subreddit.stylesheet.upload_banner_hover_image("banner.png")
- upload_header(image_path)¶
Upload an image to be used as the
Subreddit’s header image.- Parameters:
image_path (
str) – A path to a jpeg or png image.- Return type:
- Returns:
A dictionary containing a link to the uploaded image under the key
img_src.- Raises:
prawcore.TooLargeif the overall request body is too large.- Raises:
RedditAPIExceptionif there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.
For example:
reddit.subreddit("test").stylesheet.upload_header("header.png")
- upload_mobile_banner(image_path)¶
Upload an image for the
Subreddit’s (redesign) mobile banner.For example:
subreddit = reddit.subreddit("test") subreddit.stylesheet.upload_mobile_banner("banner.png")
Fails if the
Subredditdoes not have an additional image defined.- Raises:
prawcore.TooLargeif the overall request body is too large.- Raises:
RedditAPIExceptionif there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.- Parameters:
image_path (str)
- Return type:
None
- upload_mobile_header(image_path)¶
Upload an image to be used as the
Subreddit’s mobile header.- Parameters:
image_path (
str) – A path to a jpeg or png image.- Return type:
- Returns:
A dictionary containing a link to the uploaded image under the key
img_src.- Raises:
prawcore.TooLargeif the overall request body is too large.- Raises:
RedditAPIExceptionif there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.
For example:
reddit.subreddit("test").stylesheet.upload_mobile_header("header.png")
- upload_mobile_icon(image_path)¶
Upload an image to be used as the
Subreddit’s mobile icon.- Parameters:
image_path (
str) – A path to a jpeg or png image.- Return type:
- Returns:
A dictionary containing a link to the uploaded image under the key
img_src.- Raises:
prawcore.TooLargeif the overall request body is too large.- Raises:
RedditAPIExceptionif there are other issues with the uploaded image. Unfortunately the exception info might not be very specific, so try through the website with the same image to see what the problem actually might be.
For example:
reddit.subreddit("test").stylesheet.upload_mobile_icon("icon.png")