'Fetch the pidmap, src_pid and version for a given src_id, optionally
creating new CLIENTPIDMAP entries on demand.'

def get_pidmap(self, src_id, create=False):

    with self._lock:
        cpm = self.get_clientpidmap()
        pidmap = cpm.get(src_id, False)
        if pidmap:
            src_pid = pidmap['pid']
            is_new = False
        elif create:
            pids = [p['pid'] for p in cpm.values()]
            src_pid = None
            for pid in range(1, self.MAX_SRC_PID):
                if (pid not in pids):
                    src_pid = pid
                    break
            if (src_pid is None):
                raise ValueError('Client    PID    map    is    too    big')
            self.add(VCardLine(name='clientpidmap', value=('%s;%s' % (src_pid, src_id))))
            pidmap = cpm[src_pid] = cpm[src_id] = {'lines': []}
            is_new = True
        else:
            raise KeyError(('No    such    CLIENTPIDMAP:    %s' % src_id))
        version = 0
        for (ver, ol) in pidmap['lines'][:]:
            version = max(ver, version)
        return (src_pid, pidmap, version, is_new)
