<commit_before>import os

def check_several_themes(themes):
    Icons = {}

    for theme in themes:

        with open(os.path.join("../icon-database", theme + ".txt"), "r") as f:
            icons = f.read().splitlines()

        for icon in icons:

            context, name = icon.split("/")

            if not Icons.has_key(name):
                Icons[name] = {}

            if not Icons[name].has_key(context):
                Icons[name][context] = []

            Icons[name][context].append(theme)

    names = Icons.keys()
    names.sort()

    for name in names:

        data = Icons[name]

        number_of_contexts_for_current_icon = len(data.keys())

        if number_of_contexts_for_current_icon == 1:

            # everything is fine, the icon has the same context in all themes
                # themes = data[data.keys()[0]]

                # number_of_themes = len(themes)

                # if number_of_themes != 1:
                #     print name, themes

                # print name, data
                # print 
                # print
            pass
        else:    
            print name
            for category in data.keys():
                # print category,  data[category]

                for theme in data[category]:
                    print " %-13s:" %category, theme

            print
        #     print

    correct_icons = 0
    incorrect_icons = 0

    for name, data in Icons.iteritems():

        number_of_contexts_for_current_icon = len(data.keys())

        if number_of_contexts_for_current_icon == 1:

            correct_icons += 1
        else:
            incorrect_icons += 1
    print
    print "correct items", correct_icons
    print "incorrect items", incorrect_icons    

themes = ["standard-icons-0.8.90", "Oxygen-4"]
# themes = ["Oxygen-4"]


check_several_themes(themes)<commit_msg>some changes to check tool<commit_after>import os

ICON_DATABASE_FOLDER = "../icon-database"

def check_for_context_problems(themes):
    Icons = {}

    for theme in themes:

        with open(os.path.join(ICON_DATABASE_FOLDER, theme + ".txt"), "r") as f:
            icons = f.read().splitlines()

        for icon in icons:

            context, name = icon.split("/")

            if not Icons.has_key(name):
                Icons[name] = {}

            if not Icons[name].has_key(context):
                Icons[name][context] = []

            Icons[name][context].append(theme)

    names = Icons.keys()
    names.sort()

    for name in names:

        data = Icons[name]

        number_of_contexts_for_current_icon = len(data.keys())

        if number_of_contexts_for_current_icon == 1:

            # everything is fine, the icon has the same context in all themes
                # themes = data[data.keys()[0]]

                # number_of_themes = len(themes)

                # if number_of_themes != 1:
                #     print name, themes

                # print name, data
                # print 
                # print
            pass
        else:    
            print name
            for category in data.keys():
                # print category,  data[category]

                for theme in data[category]:
                    print " %-13s:" %category, theme

            print
        #     print

    correct_icons = 0
    incorrect_icons = 0

    for name, data in Icons.iteritems():

        number_of_contexts_for_current_icon = len(data.keys())

        if number_of_contexts_for_current_icon == 1:

            correct_icons += 1
        else:
            incorrect_icons += 1
    
    print
    print "Icons with unique contexts:  ", correct_icons
    print "Icons with multiple contexts:", incorrect_icons    


if __name__ == "__main__":

    import sys

    nparams = len(sys.argv) - 1

    # Please note: 
    # - all themes must be in the "../base_themes/" subfolder!
    # - the themename is the folder of the theme, notthe one given in the index.theme file
    # - one could implement direct support of locally installed theme files in /usr/share/icons
    #   but creating symlinks in the ".../base_themes/" folder might be easier

    # if there are parameters passed via command line then these are treated as theme names...
    if nparams >= 1: 
        themes = sys.argv[1:]

    # ... otherwise use all the available theme folders
    else:

        # get all files inthe base theme folder
        themes = os.listdir(ICON_DATABASE_FOLDER)

        # remove all folder in which 'index.theme' does not exist
        themes = [f for f in themes if os.path.isfile(os.path.join(ICON_DATABASE_FOLDER, f))]

        # take only file with the ending 'txt' strip the ending
        themes = [f[:-4] for f in themes if f.endswith(".txt")]

    check_for_context_problems(themes)


{'fraction_non_alphanumeric': 0.09506895110739658, 'fraction_numerical': 0.0062682824905975765, 'mean_word_length': 1.796144859813084, 'pattern_counts': {'":': 1, '<': 3, '<?xml version=': 0, '>': 4, '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': '6166527', 'n_tokens_mistral': 1460, 'n_tokens_neox': 1334, 'n_words': 392}