def sources_save(db: Database, **kwargs): """ function for saving sources :key sources: List with sources """ for src in kwargs['sources']: db.insert_or_update('sources', **src)
def tasks_executed(db: Database, **kwargs): """ Function for changing task's executing time :key tid: Task id """ db.insert_or_update( 'tasks', id=kwargs['tid'], last_execution=datetime.today().date().strftime("%Y-%m-%d"), crashed=kwargs['crashed'])
def channels_save(db: Database, **kwargs): """ Function for saving channels to database :key channels: List with channels, should be list """ done = 0 for ch in kwargs['channels']: # TODO: Remake with single request done += 1 print(f"\r\t- Saving channels... \t{done}/{len(kwargs['channels'])}", end='') db.insert_or_update('channels', **ch.get_dict()) print(f"\r\t- Saving channels... Done!")
def themes_add(db: Database, **kwargs): """ Function that add new theme to database :key theme: name of theme, should be str :return: id of added theme """ return db.insert_or_update('themes', name=kwargs['theme'], _return_id=True)
def themes_add_default(db: Database): themes = list(THEMES['themes'].keys()) for name in themes: if name != '': db.insert_or_update('themes', id=themes.index(name), name=name)