<commit_before># -*- coding: utf-8 -*-

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


import json


class Theme(object):
    def __init__(self, **kwargs):
        self.__dict__.update(kwargs)

    @classmethod
    def load(self, name):
        try:
            f = open(name)
        except IOError:
            # TODO: Add trace log here
            # switching to default theme
            return DefaultTheme()

        return Theme(**json.load(f))

    def __getitem__(self, name):
        return self.__dict__[name]


class DefaultTheme(Theme):
    def __init__(self):
        theme = {
            'bgcolor': (80, 80, 80),
            'defaultwidth': 100,
            'defaultheight': 100,
            'titlefont-name': 'Arial',
            'titlefont-size': 64,
            'titlefont-color': (255, 255, 255),
            'titlefont-antialias': True,
            'titlefont-bold': True,
            'titlefont-underline': False,
            'titlefont-italic': False
            }

        super(DefaultTheme, self).__init__(**theme)<commit_msg>Worked on the button widget, reworked the theme class, added a Color object<commit_after># -*- coding: utf-8 -*-

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.


import json


class Theme(object):
    def __init__(self, **kwargs):
        self.__dict__.update(kwargs)

    @classmethod
    def load(self, name):
        try:
            f = open(name)
        except IOError:
            # TODO: Add trace log here
            # switching to default theme
            return DefaultTheme()

        return Theme(**json.load(f))

    def __getitem__(self, name):
        levels = name.split('.')
        try:
            if len(levels) == 1:
                return self.__dict__[name]
            else:
                current = self.__dict__
                for level in levels[:-1]:
                    current = current[level]
                return current[levels[-1]]
        except:
            raise KeyError(name)

    def get(self, name, default=None):
        try:
            return self[name]
        except:
            return default


class DefaultTheme(Theme):
    def __init__(self):
        theme = {
            'bgcolor': (80, 80, 80),
            'defaultwidth': 100,
            'defaultheight': 100,
            'titlefont-name': 'Arial',
            'titlefont-size': 64,
            'titlefont-color': 'white',
            'titlefont-antialias': True,
            'titlefont-bold': True,
            'titlefont-underline': False,
            'titlefont-italic': False,
            'button': {
                'font-name': 'Arial',
                'font-size': 50,
                'bgcolor': (80, 80, 80),
                'clicked_bgcolor': (90, 90, 90),
                }
            }

        super(DefaultTheme, self).__init__(**theme)
{'fraction_non_alphanumeric': 0.11659192825112108, 'fraction_numerical': 0.020499679692504803, 'mean_word_length': 1.7015570934256055, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4162995', 'n_tokens_mistral': 943, 'n_tokens_neox': 861, 'n_words': 258}