Process a (key, value) pair

def process_pair(self, key, value):
        """ Process a (key, value) pair """

        old_key = key
        old_value = value

        # Create key intelligently
        keyparts = self.bspacere.split(key)
        # print keyparts

        strippable = False
        lastpart = keyparts[-1]

        if lastpart.find('\\ ') != -1:
            keyparts[-1] = lastpart.replace('\\','')

        # If no backspace is found at the end, but empty
        # space is found, strip it
        elif lastpart and lastpart[-1] == ' ':
            strippable = True

        key = ''.join(keyparts)
        if strippable:
            key = key.strip()
            old_key = old_key.strip()

        old_value = self.unescape(old_value)
        value = self.unescape(value)

        # Patch from N B @ ActiveState
        curlies = re.compile(r'\$?\{.+?\}')
        found_variables = curlies.findall(value)

        for found_variable in found_variables:
            if found_variable.startswith('$'):
                source_key = found_variable[2:-1]
            else:
                source_key = found_variable[1:-1]

            if source_key in self._properties:
                value = value.replace(found_variable, self._properties[source_key], 1)

        self._properties[key] = value.strip()

        # Check if an entry exists in pristine keys
        if key in self._keymap:
            old_key = self._keymap.get(key)
            self._origprops[old_key] = old_value.strip()
        else:
            self._origprops[old_key] = old_value.strip()
            # Store entry in keymap
            self._keymap[key] = old_key

        if key not in self._keyorder:
            self._keyorder.append(key)