def METHOD_NAME(conn, netname):
    try:
        return conn.networkLookupByName(netname)
    except libvirtError as e:
        if e.get_error_code() == VIR_ERR_NO_NETWORK:
            return None
        raise