<commit_before>import wx
import os
import prefs
import datetime, time
import EnhancedStatusBar as ESB
from utility import platform

# get the images once at compile time
icons = {}
iconpath = os.path.join(wx.GetApp().path, "icons")
for icon_file in os.listdir(iconpath):
    feature, _ = icon_file.split('.')
    icons[feature] = wx.Image(os.path.join(iconpath, icon_file)).ConvertToBitmap()

class StatusBar(ESB.EnhancedStatusBar):

    def __init__(self, parent, connection):
        ESB.EnhancedStatusBar.__init__(self, parent)
        self.parent = parent
        self.connection = connection

        # status field
        self.status_field = wx.Panel(self)

        # "feature icons" container
        self.feature_tray = wx.Window(self)
        self.feature_sizer = wx.BoxSizer()
        self.feature_icons = {}
        for i,w in icons.items():
            icon = FeatureIcon(self.feature_tray, i, w)
            self.feature_sizer.Add(icon, 0, wx.EXPAND|wx.SHAPED)
            icon.Hide()
            self.feature_icons[i] = icon
        self.feature_tray.SetSizerAndFit(self.feature_sizer)<commit_msg>Don't crash if statusbar icon files are missing<commit_after>import wx
import os
import prefs
import datetime, time
import EnhancedStatusBar as ESB
from utility import platform

# get the images once at compile time
icons = {}
iconpath = os.path.join(wx.GetApp().path, "icons", "features")
if os.path.exists(iconpath):
    for icon_file in os.listdir(iconpath):
        feature, _ = icon_file.split('.')
        icons[feature] = wx.Image(os.path.join(iconpath, icon_file)).ConvertToBitmap()

class StatusBar(ESB.EnhancedStatusBar):

    def __init__(self, parent, connection):
        ESB.EnhancedStatusBar.__init__(self, parent)
        self.parent = parent
        self.connection = connection

        # status field
        self.status_field = wx.Panel(self)

        # "feature icons" container
        self.feature_tray = wx.Window(self)
        self.feature_sizer = wx.BoxSizer()
        self.feature_icons = {}
        for i,w in icons.items():
            icon = FeatureIcon(self.feature_tray, i, w)
            self.feature_sizer.Add(icon, 0, wx.EXPAND|wx.SHAPED)
            icon.Hide()
            self.feature_icons[i] = icon
        self.feature_tray.SetSizerAndFit(self.feature_sizer)
{'fraction_non_alphanumeric': 0.10688013846819559, 'fraction_numerical': 0.0008654262224145391, 'mean_word_length': 2.9521367521367523, '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': '5069260', 'n_tokens_mistral': 730, 'n_tokens_neox': 713, 'n_words': 161}