<commit_before>import os
import PythonQt
from PythonQt import QtCore, QtGui
from collections import namedtuple
from collections import OrderedDict

import vtk

_objectTree = None
_propertiesPanel = None

objects = {}
PropertyAttributes = namedtuple('PropertyAttributes', ['decimals', 'minimum', 'maximum', 'singleStep', 'hidden'])


class Icons(object):

  Directory = QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_DirIcon)
  Eye = QtGui.QIcon(':/images/eye_icon.png')
  EyeOff = QtGui.QIcon(':/images/eye_icon_gray.png')
  Matlab = QtGui.QIcon(':/images/matlab_logo.png')
  Robot = QtGui.QIcon(':/images/robot_icon.png')
  Laser = QtGui.QIcon(':/images/laser_icon.jpg')



class ObjectModelItem(object):

    def __init__(self, name, icon=Icons.Robot):
        self.properties = OrderedDict()
        self.icon = icon
        self.addProperty('Name', name)

    def propertyNames(self):
        return self.properties.keys()

    def hasProperty(self, propertyName):
        return propertyName in self.properties

    def getProperty(self, propertyName):
        assert self.hasProperty(propertyName)
        return self.properties[propertyName]

    def addProperty(self, propertyName, propertyValue):
        self.properties[propertyName] = propertyValue
        self._onPropertyAdded(propertyName)

    def setProperty(self, propertyName, propertyValue):
        assert self.hasProperty(propertyName)
        self.oldPropertyValue = (propertyName, self.getProperty(propertyName))
        self.properties[propertyName] = propertyValue
        self._onPropertyChanged(propertyName)
        self.oldPropertyValue = None

    def getPropertyAttributes(self, propertyName):

        if propertyName == 'Alpha':
            return PropertyAttributes(decimals=2, minimum=0.0, maximum=1.0, singleStep=0.1, hidden=False)
        elif propertyName == 'Name':
            return PropertyAttributes(decimals=0, minimum=0, maximum=0, singleStep=0, hidden=True)
        else:
            return PropertyAttributes(decimals=0, minimum=0, maximum=0, singleStep=0, hidden=False)

    def _onPropertyChanged(self, propertyName):
        updatePropertyPanel(self, propertyName)
        if propertyName == 'Visible':
            updateVisIcon(self)

    def _onPropertyAdded(self, propertyName):
        pass

    def onRemoveFromObjectModel(self):
        pass


class ContainerItem(ObjectModelItem):

    def __init__(self, name):
        ObjectModelItem.__init__(self, name, Icons.Directory)

<commit_msg>add handler for Name property change<commit_after>import os
import PythonQt
from PythonQt import QtCore, QtGui
from collections import namedtuple
from collections import OrderedDict

import vtk

_objectTree = None
_propertiesPanel = None

objects = {}
PropertyAttributes = namedtuple('PropertyAttributes', ['decimals', 'minimum', 'maximum', 'singleStep', 'hidden'])


class Icons(object):

  Directory = QtGui.QApplication.style().standardIcon(QtGui.QStyle.SP_DirIcon)
  Eye = QtGui.QIcon(':/images/eye_icon.png')
  EyeOff = QtGui.QIcon(':/images/eye_icon_gray.png')
  Matlab = QtGui.QIcon(':/images/matlab_logo.png')
  Robot = QtGui.QIcon(':/images/robot_icon.png')
  Laser = QtGui.QIcon(':/images/laser_icon.jpg')



class ObjectModelItem(object):

    def __init__(self, name, icon=Icons.Robot):
        self.properties = OrderedDict()
        self.icon = icon
        self.addProperty('Name', name)

    def propertyNames(self):
        return self.properties.keys()

    def hasProperty(self, propertyName):
        return propertyName in self.properties

    def getProperty(self, propertyName):
        assert self.hasProperty(propertyName)
        return self.properties[propertyName]

    def addProperty(self, propertyName, propertyValue):
        self.properties[propertyName] = propertyValue
        self._onPropertyAdded(propertyName)

    def setProperty(self, propertyName, propertyValue):
        assert self.hasProperty(propertyName)
        self.oldPropertyValue = (propertyName, self.getProperty(propertyName))
        self.properties[propertyName] = propertyValue
        self._onPropertyChanged(propertyName)
        self.oldPropertyValue = None

    def getPropertyAttributes(self, propertyName):

        if propertyName == 'Alpha':
            return PropertyAttributes(decimals=2, minimum=0.0, maximum=1.0, singleStep=0.1, hidden=False)
        elif propertyName == 'Name':
            return PropertyAttributes(decimals=0, minimum=0, maximum=0, singleStep=0, hidden=True)
        else:
            return PropertyAttributes(decimals=0, minimum=0, maximum=0, singleStep=0, hidden=False)

    def _onPropertyChanged(self, propertyName):
        updatePropertyPanel(self, propertyName)
        if propertyName == 'Visible':
            updateVisIcon(self)
        if propertyName == 'Name':
            getItemForObject(self).setText(0, self.getProperty('Name'))

    def _onPropertyAdded(self, propertyName):
        pass

    def onRemoveFromObjectModel(self):
        pass


class ContainerItem(ObjectModelItem):

    def __init__(self, name):
        ObjectModelItem.__init__(self, name, Icons.Directory)


{'fraction_non_alphanumeric': 0.1043613707165109, 'fraction_numerical': 0.006035825545171339, 'mean_word_length': 3.7919776119402986, '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': '3199494', 'n_tokens_mistral': 1488, 'n_tokens_neox': 1427, 'n_words': 306}