def _pgpass_content(record: Dict[str, Any]) -> Optional[str]:
        """Generate content of `pgpassfile` based on connection parameters.

        .. note::
            In case if ``host`` is a comma separated string we generate one line per host.

        :param record: :class:`dict` object with connection parameters.
        :returns: a string with generated content of pgpassfile or ``None`` if there is no ``password``.
        """
        if 'password' in record:
            def escape(value: Any) -> str:
                return re.sub(r'([:\\])', r'\\\1', str(value))

            # 'host' could be several comma-separated hostnames, in this case we need to write on pgpass line per host
            hosts = [escape(host) for host in filter(None, map(str.strip,
                     (record.get('host', '') or '*').split(',')))]  # pyright: ignore [reportUnknownArgumentType]
            if any(host.startswith('/') for host in hosts) and 'localhost' not in hosts:
                hosts.append('localhost')
            record = {n: escape(record.get(n) or '*') for n in ('port', 'user', 'password')}
            return ''.join('{host}:{port}:*:{user}:{password}\n'.format(**record, host=host) for host in hosts)
Generate content of `pgpassfile` based on connection parameters.

        .. note::
            In case if ``host`` is a comma separated string we generate one line per host.

        :param record: :class:`dict` object with connection parameters.
        :returns: a string with generated content of pgpassfile or ``None`` if there is no ``password``.
        
patroni/postgresql/config.py