HandlerDatabase module

class databaseUser.HandlerDatabase.HandlerDatabase

Bases: object

static areImagesEqual(current_image, new_image) -> (<class 'bool'>, <class 'str'>)

Compare two images

Returns

If the images are equal or not and the dataURI of image

static arePokemonsEqual(pokemonA: dict, pokemonB: dict) → bool

Compare two dicionaries

Returns

If the dictionaries are equal or not

static deleteAllPokemons() → message.StatusCode.StatusCode

Delete all objects in the database

Returns

Status code of this operation

static deletePokemonByID(pokemonID: str) → message.StatusCode.StatusCode

Delete an object present in the database

Parameters

pokemonID – Object ID to be deleted

Returns

Status code of this operation

static getData() → any

Read json file and set dictionary with values

Returns

Dictionary with the list of objects or None

static getSizeList() → int

Get number of objects in database

Returns

Size of object list

static insertPokemon(obj: databaseUser.ObjectUser.UserObj) → message.StatusCode.StatusCode

Insert a new object in the database

Parameters

obj – Object to be inserted

Returns

Status code of this insertion

static isPokemonRegistered(pokemonID: str) -> (<class 'bool'>, <class 'int'>)

Check if object exists in database

Parameters

pokemonID – Object ID to be checked

Returns

If the object exists and the index in the database

pokemonDatabase: dict = {}
pokemonDatabasePath: str = 'databaseUser/database.json'
static setData(data: dict) → bool

Write json file with dictionary

Parameters

data – dictionary containing the database

Returns

If can be updated or not

static updatePokemonByID(pokemonID: str, pokemonData: databaseUser.ObjectUser.UserObj) → message.StatusCode.StatusCode

Update an object present in the database

Parameters
  • pokemonID – Object ID to be updated

  • pokemonData – New object information

Returns

Status code of this update