<commit_before>import os.path
from pyface.api import ImageResource

def find_icon(icon_name, size=16):
	"""
	Finds the icon named @icon_name, in the system icon theme directory if
	possible, and return it as an ImageResource.
	"""

	possible_names = (
		icon_name + '.png',
		'stock_' + icon_name + '.png',
		'gtk-' + icon_name + '.png')
	# First try the system directory
	# ...
	# Next the application directory
	for tryname in possible_names:
		icon_path = '../icons/' + tryname
		if os.path.exists(icon_path):
			return ImageResource(icon_path)
	# Next the current directory
	for tryname in possible_names:
		if os.path.exists(tryname):
			return ImageResource(tryname)
	raise IOError('Cannot find icon named "{}"'.format(icon_name))<commit_msg>Search system icon directory for icons too<commit_after>import os.path
from pyface.api import ImageResource


def find_icon(icon_name, size=16):
    """
    Finds the icon named @icon_name, in the system icon theme directory if
    possible, and return it as an ImageResource.
    """

    possible_names = (
        icon_name + '.png',
        'stock_' + icon_name + '.png',
        'gtk-' + icon_name + '.png')
    # First try the system directory
    system_icon_path = '/Users/fliep/gtk/inst/share'  # os.getenv('XDG_DATA_DIRS')
    size_dir = '{0}x{0}'.format(size)
    if system_icon_path:
        for tryname in possible_names:
            icon_path = os.path.join(system_icon_path, 'icons', 'hicolor',
                'actions', size_dir, tryname)
            if os.path.exists(icon_path):
                return ImageResource(icon_path)
    # Next the application directory
    for tryname in possible_names:
        icon_path = os.path.join('..', 'icons', tryname)
        if os.path.exists(icon_path):
            return ImageResource(icon_path)
    # Next the current directory
    for tryname in possible_names:
        if os.path.exists(tryname):
            return ImageResource(tryname)
    raise IOError('Cannot find icon named "{}"'.format(icon_name))
{'fraction_non_alphanumeric': 0.11006445215666832, 'fraction_numerical': 0.002974714923153198, 'mean_word_length': 3.160824742268041, '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': '3346716', 'n_tokens_mistral': 645, 'n_tokens_neox': 627, 'n_words': 178}