HandlerErrors module¶
-
class
handler.HandlerImage.
HandlerImage
¶ Bases:
object
Class responsible for handling images
-
static
data_to_image
(data: str, id_user: str) → any¶ Responsible for creating an image from a data URI
- Parameters
data – A string containing the data URI
id_user – A string containing the user id
- Returns
Three strings each containing the image name, image extension and image path. Can also return None.
-
static
delete_all_images
() → bool¶ Responsible for deleting all images from the database
- Returns
A boolean representing if the operation was successful or not
-
static
delete_image_database
(image_id: str) → bool¶ Responsible for deleting an image with given id from the database
- Parameters
image_id – A string containing the image id
- Returns
A boolean representing if the operation was successful or not
-
directory
= './databaseUser/Images'¶
-
static
getData
() → any¶ Responsible for getting the images from the database
- Returns
A dictionary containing the images or None.
-
imageDatabase
: dict = {}¶
-
imageDatabasePath
: str = 'databaseUser/Images/images.json'¶
-
image_formats
= ['.jpeg', '.jpg', '.png', '.gif']¶
-
static
image_to_data
(image_path: str) → str¶ Responsible for converting an image into a data URI
- Parameters
image_path – A string containing the image path
- Returns
A string containing the dataURI from the image
-
static
insert_image_database
(data: str, id_user: str) → any¶ Responsible for inserting the image into our database
- Parameters
data – A string containing the data URI
id_user – A string containing the user id
- Returns
A string containing the id of the registered image or None
-
static
isImageRegistered
(image_id: str) -> (<class 'bool'>, <built-in function any>)¶ Responsible for checking if the image with given id is registered
- Parameters
image_id – A string containing the id of the image to be deleted
- Returns
A bool containing the result of the operation and the image index in case it’s registered
-
static
remove_img
(img_name: str) → bool¶ Responsible for removing a image from the images directory
- Param
img_name: A string containing the image name
- Returns
A boolean representing if the operation was successful or not
-
static
setData
(data: dict) → bool¶ Responsible for replacing the whole image database with the given data
- Parameters
data – a dictionary containing the new image database
- Returns
A boolean representing if the operation was successful or not
-
static