<commit_before># -*- coding: utf8 -*-

# Copyright (C) 2015 - <NAME> <<EMAIL>>
# This program is Free Software see LICENSE file for details

import xbmcgui
import xbmc

from kodi65 import addon

C_LIST_SIMPLE = 3
C_LIST_DETAIL = 6
C_BUTTON_GET_MORE = 5
C_LABEL_HEADER = 1


class SelectDialog(xbmcgui.WindowXMLDialog):

    def __init__(self, *args, **kwargs):
        xbmcgui.WindowXMLDialog.__init__(self)
        self.items = kwargs.get('listing')
        self.header = kwargs.get('header')
        self.detailed = kwargs.get('detailed')
        self.extrabutton = kwargs.get('extrabutton')
        self.listitems = [i.get_listitem() for i in self.items] if self.items else []
        self.index = -1

    def onInit(self):
        if not self.listitems:
            self.index == -1
            self.close()
        self.list = self.getControl(C_LIST_DETAIL)
        self.getControl(C_LIST_DETAIL).setVisible(self.detailed)
        self.getControl(C_LIST_SIMPLE).setVisible(not self.detailed)
        self.getControl(C_BUTTON_GET_MORE).setVisible(bool(self.extrabutton))
        if self.extrabutton:
            self.getControl(C_BUTTON_GET_MORE).setLabel(self.extrabutton)
        self.getControl(C_LABEL_HEADER).setLabel(self.header)
        self.list.addItems(self.listitems)
        self.setFocus(self.list)

    def onClick(self, control_id):
        if control_id in [C_LIST_SIMPLE, C_LIST_DETAIL]:
            self.index = int(self.list.getSelectedPosition())
        elif control_id == C_BUTTON_GET_MORE:
            self.index = -2
        self.close()

    def onFocus(self, control_id):
        pass


def open(listitems, header, detailed=True, extrabutton=False):
    """
    open selectdialog, return index (-1 for closing, -2 for extra button)
    """
    xbmc.executebuiltin("Dialog.Close(busydialog)")<commit_msg>cleanup<commit_after># -*- coding: utf8 -*-

# Copyright (C) 2015 - <NAME> <<EMAIL>>
# This program is Free Software see LICENSE file for details

import xbmcgui
import xbmc

from kodi65 import addon

C_LABEL_HEADER = 1
C_LIST_SIMPLE = 3
C_LIST_DETAIL = 6
C_BUTTON_GET_MORE = 5
C_BUTTON_CANCEL = 7


class SelectDialog(xbmcgui.WindowXMLDialog):

    def __init__(self, *args, **kwargs):
        xbmcgui.WindowXMLDialog.__init__(self)
        self.items = kwargs.get('listing')
        self.header = kwargs.get('header')
        self.detailed = kwargs.get('detailed')
        self.extrabutton = kwargs.get('extrabutton')
        self.listitems = [i.get_listitem() for i in self.items] if self.items else []
        self.index = -1

    def onInit(self):
        if not self.listitems:
            self.index == -1
            self.close()
        self.list = self.getControl(C_LIST_DETAIL)
        self.getControl(C_LIST_DETAIL).setVisible(self.detailed)
        self.getControl(C_LIST_SIMPLE).setVisible(not self.detailed)
        self.getControl(C_BUTTON_GET_MORE).setVisible(bool(self.extrabutton))
        if self.extrabutton:
            self.getControl(C_BUTTON_GET_MORE).setLabel(self.extrabutton)
        self.getControl(C_LABEL_HEADER).setLabel(self.header)
        self.list.addItems(self.listitems)
        self.setFocus(self.list)

    def onClick(self, control_id):
        if control_id in [C_LIST_SIMPLE, C_LIST_DETAIL]:
            self.index = int(self.list.getSelectedPosition())
            self.close()
        elif control_id == C_BUTTON_GET_MORE:
            self.index = -2
            self.close()
        elif control_id == C_BUTTON_CANCEL:
            self.close()

    def onFocus(self, control_id):
        pass


def open(listitems, header, detailed=True, extrabutton=False):
    """
    open selectdialog, return index (-1 for closing, -2 for extra button)
    """
    xbmc.executebuiltin("Dialog.Close(busydialog)")
{'fraction_non_alphanumeric': 0.11169931180518793, 'fraction_numerical': 0.008734780307040762, 'mean_word_length': 2.8878600823045266, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3798112', 'n_tokens_mistral': 1277, 'n_tokens_neox': 1239, 'n_words': 240}