# Copyright (C) 2023 Stefy Lanza <stefy@nexlab.net> and SexHack.me
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <https://www.gnu.org/licenses/>.

def get_buttons():
    r=1
    buttons = {}
    while r >= 1 and r<10:
        buttons[r] = {}
        for s in [x for x in config.sections() if 'BUTTON:'+str(r)+':' in x]:
            values = config.items(s)
            if len(values) > 0:
                buttons[r][s.split(':',2)[2]] = {}
                for t in values:
                    buttons[r][s.split(':',2)[2]][t[0]] = t[1]
        r=r+1
        if len(buttons[r-1].keys()) < 1:
            del(buttons[r-1])
            r=0
    numrows = len(buttons.keys())
    return buttons, numrows
