'Sets properties and text given a text field'

def setText(self, text):

    self.text = text
    try:
        result = {}
        end = len(text)
        index = 0
        strs = []
        while (index < end):
            length = ord(text[index])
            index += 1
            strs.append(text[index:(index + length)])
            index += length
        for s in strs:
            eindex = s.find('=')
            if (eindex == (-1)):
                key = s
                value = 0
            else:
                key = s[:eindex]
                value = s[(eindex + 1):]
                if (value == 'true'):
                    value = 1
                elif ((value == 'false') or (not value)):
                    value = 0
            if (key and (result.get(key) == None)):
                result[key] = value
        self.properties = result
    except:
        traceback.print_exc()
        self.properties = None
