<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:

def pool_info(name=None, **kwargs):
    '''
    Return informations on a storage pool provided its name.

    :param name: libvirt storage pool name
    :param connection: libvirt connection URI, overriding defaults
    :param username: username to connect with, overriding defaults
    :param password: password to connect with, overriding defaults

    If no name is provided, return the infos for all defined storage pools.

    .. versionadded:: 2019.2.0

    CLI Example:

    .. code-block:: bash

        salt '*' virt.pool_info default
    '''
    result = {}
    conn = __get_conn(**kwargs)

    def _pool_extract_infos(pool):
        '''
        Format the pool info dictionary

        :param pool: the libvirt pool object
        '''
        states = ['inactive', 'building', 'running', 'degraded', 'inaccessible']
        infos = pool.info()
        state = states[infos[0]] if infos[0] < len(states) else 'unknown'
        desc = ElementTree.fromstring(pool.XMLDesc())
        path_node = desc.find('target/path')
        return {
            'uuid': pool.UUIDString(),
            'state': state,
            'capacity': infos[1],
            'allocation': infos[2],
            'free': infos[3],
            'autostart': pool.autostart(),
            'persistent': pool.isPersistent(),
            'target_path': path_node.text if path_node is not None else None,
            'type': desc.get('type')
        }

    try:
        pools = [pool for pool in conn.listAllStoragePools() if name is None or pool.name() == name]
        result = {pool.name(): _pool_extract_infos(pool) for pool in pools}
    except libvirt.libvirtError as err:
        log.debug('Silenced libvirt error: %s', str(err))
    finally:
        conn.close()
    return result