SubredditStylesheet¶
- class asyncpraw.models.reddit.subreddit.SubredditStylesheet(subreddit: asyncpraw.models.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 = await reddit.subreddit("SUBREDDIT") stylesheet = await subreddit.stylesheet() stylesheet.stylesheet.stylesheet += ".test{color:blue}" await subreddit.stylesheet.update(stylesheet.stylesheet)
- await __call__() asyncpraw.models.Stylesheet ¶
Return the subreddit’s stylesheet.
To be used as:
subreddit = await reddit.subreddit("SUBREDDIT") stylesheet = await subreddit.stylesheet()
- __init__(subreddit: asyncpraw.models.Subreddit)¶
Create a SubredditStylesheet instance.
- Parameters
subreddit – The subreddit associated with the stylesheet.
An instance of this class is provided as:
subreddit = await reddit.subreddit("SUBREDDIT") subreddit.stylesheet
- await delete_banner()¶
Remove the current subreddit (redesign) banner image.
Succeeds even if there is no banner image.
For example:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.delete_banner()
- await 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:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.delete_banner_additional_image()
- await delete_banner_hover_image()¶
Remove the current subreddit (redesign) banner hover image.
Succeeds even if there is no hover image.
For example:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.delete_banner_hover_image()
- await delete_header()¶
Remove the current subreddit header image.
Succeeds even if there is no header image.
For example:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.delete_header()
- await delete_image(name: str)¶
Remove the named image from the subreddit.
Succeeds even if the named image does not exist.
For example:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.delete_image("smile")
- await delete_mobile_header()¶
Remove the current subreddit mobile header.
Succeeds even if there is no mobile header.
For example:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.delete_mobile_header()
- await delete_mobile_icon()¶
Remove the current subreddit mobile icon.
Succeeds even if there is no mobile icon.
For example:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.delete_mobile_icon()
- await update(stylesheet: str, reason: Optional[str] = None)¶
Update the subreddit’s stylesheet.
- Parameters
stylesheet – The CSS for the new stylesheet.
reason – The reason for updating the stylesheet.
For example:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.update("p { color: green; }", "color text green")
- await upload(name: str, image_path: str) Dict[str, str] ¶
Upload an image to the Subreddit.
- Parameters
name – The name to use for the image. If an image already exists with the same name, it will be replaced.
image_path – A path to a jpeg or png image.
- Returns
A dictionary containing a link to the uploaded image under the key
img_src
.- Raises
asyncprawcore.TooLarge
if the overall request body is too large.- Raises
RedditAPIException
if 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:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.upload("smile", "img.png")
- await upload_banner(image_path: str)¶
Upload an image for the subreddit’s (redesign) banner image.
- Parameters
image_path – A path to a jpeg or png image.
- Raises
asyncprawcore.TooLarge
if the overall request body is too large.- Raises
RedditAPIException
if 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:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.upload_banner("banner.png")
- await upload_banner_additional_image(image_path: str, align: Optional[str] = None)¶
Upload an image for the subreddit’s (redesign) additional image.
- Parameters
image_path – A path to a jpeg or png image.
align – Either
left
,centered
, orright
. (default:left
).
- Raises
asyncprawcore.TooLarge
if the overall request body is too large.- Raises
RedditAPIException
if 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:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.upload_banner_additional_image("banner.png")
- await upload_banner_hover_image(image_path: str)¶
Upload an image for the subreddit’s (redesign) additional image.
- Parameters
image_path – A path to a jpeg or png image.
Fails if the Subreddit does not have an additional image defined
- Raises
asyncprawcore.TooLarge
if the overall request body is too large.- Raises
RedditAPIException
if 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:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.upload_banner_hover_image("banner.png")
- await upload_header(image_path: str) Dict[str, str] ¶
Upload an image to be used as the Subreddit’s header image.
- Parameters
image_path – A path to a jpeg or png image.
- Returns
A dictionary containing a link to the uploaded image under the key
img_src
.- Raises
asyncprawcore.TooLarge
if the overall request body is too large.- Raises
RedditAPIException
if 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:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.upload_header("header.png")
- await upload_mobile_header(image_path: str) Dict[str, str] ¶
Upload an image to be used as the Subreddit’s mobile header.
- Parameters
image_path – A path to a jpeg or png image.
- Returns
A dictionary containing a link to the uploaded image under the key
img_src
.- Raises
asyncprawcore.TooLarge
if the overall request body is too large.- Raises
RedditAPIException
if 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:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.upload_mobile_header("header.png")
- await upload_mobile_icon(image_path: str) Dict[str, str] ¶
Upload an image to be used as the Subreddit’s mobile icon.
- Parameters
image_path – A path to a jpeg or png image.
- Returns
A dictionary containing a link to the uploaded image under the key
img_src
.- Raises
asyncprawcore.TooLarge
if the overall request body is too large.- Raises
RedditAPIException
if 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:
subreddit = await reddit.subreddit("SUBREDDIT") await subreddit.stylesheet.upload_mobile_icon("icon.png")