switched docstring format to one-line-sphinx

This commit is contained in:
Lucas Jensen
2024-05-05 13:32:31 -07:00
parent ab0fae44f7
commit e1a29b398e
12 changed files with 300 additions and 243 deletions

View File

@@ -2,10 +2,16 @@ import smtplib
from email.mime.text import MIMEText
from os import getenv
HOST = "grapefruitswebsite@gmail.com"
from app.constants import HOST
def send_email(subject: str, body: str) -> None:
"""
Sends an email using the Gmail SMTP server.
:param str subject: The subject of the email
:param str body: The body of the email
"""
password = getenv("APP_PASSWORD")
email = getenv("EMAIL")
msg = MIMEText(body)

View File

@@ -1,7 +1,6 @@
# Set your Cloudinary credentials
# ==============================
from pprint import pprint
from dotenv import load_dotenv
@@ -22,10 +21,20 @@ uploader = cloudinary.uploader
class CloudinaryException(Exception):
"""
Custom exception for Cloudinary errors.
"""
pass
def delete_image(public_id: str) -> None:
"""
Deletes an image from the Cloudinary cloud.
:param str public_id: The public ID of the image to delete
:raises CloudinaryException: If the image deletion fails
"""
result = uploader.destroy(public_id)
if result.get("result") != "ok":
@@ -33,16 +42,25 @@ def delete_image(public_id: str) -> None:
def get_image_data(public_id: str) -> dict:
"""
Retrieves the metadata for an image from the Cloudinary cloud.
:param str public_id: The public ID of the image to retrieve
:return dict: The metadata for the image
"""
data = cloudinary.api.resource(public_id)
return data
def get_image_url(public_id: str) -> str:
"""
Retrieves the URL for an image from the Cloudinary cloud.
:param str public_id: The public ID of the image to retrieve
:raises CloudinaryException: If the image URL retrieval fails
:return str: The URL of the image
"""
url = cloudinary.utils.cloudinary_url(public_id)[0]
if url is None:
raise CloudinaryException("Failed to get image URL")
return url
if __name__ == "__main__":
image_id = "coco_copy_jywbxm"