halo.DataStore module

Handles the data storage and retrieval.

class halo.DataStore.DataStore(db_location='/home/cijo/.halo/database.sqlite')[source]

Bases: object

sqlite3 database class that store user data and app settings.

add_city(params)[source]

Adds the city to db if it doesn’t exists.

Parameters:params – a tuple of city and country code
static get_api_key()[source]

Retrieves the api key

Returns:API key
static get_bg_file()[source]

Retrieves the background image path.

Returns:image file path
get_cities()[source]

Get a list of all the cities

Returns:list of city name and country codes.
static get_height()[source]

Retrieves the screen height.

static get_width()[source]

Retrieves the screen width.

refresh_preference()[source]

Loads latest preference values from db

screen(width, height)[source]

Save the screen width and height to the db.

Parameters:
  • width – Width of screen.
  • height – Height of screen.
set_api_key(key)[source]

Writes the new API key if it’s valid.

Parameters:key – API key
set_bg_file(file_name)[source]

Writes the new background image path if it exists.

Parameters:file_name – file path
halo.DataStore.query(fn)[source]

A decorator which ensures if a database lock ever happen, then sqlite query is retired seamlessly.