<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def add_context( self, name, cluster_name=None, user_name=None, namespace_name=None, **attrs ):
 """Add a context to config."""

        if self.context_exists(name):
            raise KubeConfError("context with the given name already exists.")

        contexts = self.get_contexts()
        
        # Add parameters.
        new_context = {'name': name, 'context':{}}
        
        # Add attributes
        attrs_ = new_context['context']
        if cluster_name is not None:
            attrs_['cluster'] = cluster_name
        if user_name is not None:
            attrs_['user'] = user_name
        if namespace_name is not None:
            attrs_['namespace'] = namespace_name
        attrs_.update(attrs)

        contexts.append(new_context)