Thanks @brunoszdl. It works with slight modifications.
{% macro check_source(source_name, table_name) %}
{%- if execute -%}
{% for source in graph.sources.values() %}
{%- if source.source_name == source_name and source.name == table_name -%}
{{ return(true) }}
{%- endif -%}
{%- endfor -%}
{{ return(false) }}
{%- endif -%}
{% endmacro %}