Пример #1
0
def up_b_mash(book, key, value, db=None):
    dbtools.updateIt({key: value},
                     None,
                     'Books',
                     "where Name =='" + book + "'",
                     mashconfig=True,
                     db=db)
Пример #2
0
def up_b_hotkey(value, bookname, db=None):
    '''
    Update The hotkey for a Book
    returns the old keycode so you can unregister the key if you wish
    '''
    condition = "where Bookname =='" + bookname + "'"
    old_hk = dbtools.turnIntoObj(
        dbtools.loadItColumn('Hotkey', 'Hotkeys', condition).fetchone()[0])
    try:
        dbtools.updateIt({'Hotkey': value}, True, 'Hotkeys', condition, db=db)
    except:
        raise UniqueHotkeyError('Hotkey not unique')
    return old_hk
Пример #3
0
def up_b_bookname(user_entered_name, oldname, db=None):
    '''
    Update name of a book
    Make sure to overwirte the old bookname,
    Make sure to pass in only the user entered part of the name
    '''
    widgettype = oldname.split('-')[0].strip()
    newname = ' - '.join((widgettype, user_entered_name))

    dbtools.updateIt(newname,
                     'Name',
                     'Books',
                     "where Name =='" + oldname + "'",
                     mashconfig=False,
                     db=db)
    condition = "where Bookname =='" + oldname + "'"
    for data in dbtools.loadItColumn('Name, Program, Profile', 'Pages',
                                     condition).fetchall():
        page, program, profile = data
        rest = page[len(oldname):]
        dbtools.updateIt(newname + rest,
                         'Name',
                         'Pages',
                         condition +
                         " and Program == '{0}' and Profile == '{1}'".format(
                             program, profile),
                         mashconfig=False)
    dbtools.updateIt(newname, 'Bookname', 'Pages', condition, mashconfig=False)
    dbtools.updateIt(newname,
                     'Bookname',
                     'Hotkeys',
                     condition,
                     mashconfig=False)
    return newname
Пример #4
0
def set_active_profile(profile, db=None):
    '''Sets the given profile as being active'''
    # Remove the previous active
    cond = "where Active == 1"
    dbtools.updateIt(False,
                     column='Active',
                     table='Profiles',
                     mashconfig=False,
                     condition=cond,
                     db=db)

    # Update the new
    cond = "where Name == '{0}'".format(profile)
    dbtools.updateIt(True,
                     column='Active',
                     table='Profiles',
                     mashconfig=False,
                     condition=cond,
                     db=db)