# Path: rosapi/src/rosapi/glob_helper.py
# def any_match(query, globs):
#     return (
#         globs is None or len(globs) == 0 or any(fnmatch.fnmatch(str(query), glob) for glob in globs)
#     )
# 
# def filter_globs(globs, full_list):
#     # If the globs are empty (weren't defined in the params), return the full list
#     if globs is not None and len(globs) > 0:
#         return list(filter(lambda x: any_match(x, globs), full_list))
#     else:
#         return full_list


from ros2node.api import (
    get_node_names,
    get_publisher_info,
    get_service_server_info,
    get_subscriber_info,
)
from ros2service.api import get_service_names, get_service_names_and_types
from ros2topic.api import get_topic_names, get_topic_names_and_types
from .glob_helper import any_match, filter_globs
                possibility = [0, 0]
            if possible_action_server == namespace and topic in action_topics:
                possibility[action_topics.index(topic)] = 1
            if all(p == 1 for p in possibility):
                action_servers.append(possible_action_server)
                possibility = [0, 0]

    return action_servers


def get_service_type(service, services_glob):
    """Returns the type of the specified ROS service,"""
    # Note: this doesn't consider hidden services.
    services, types = get_services_and_types(services_glob)
    try:
        return types[services.index(service)]
    except ValueError:
        # Return empty string if the service is not present.
        return ""


def get_channel_info(channel, channels_glob, getter_function, include_hidden=False):
    """Returns a list of node names that are publishing / subscribing to the specified topic,
    or advertising a given service."""
    if any_match(str(channel), channels_glob):
        channel_info_list = []
        node_list = get_nodes(include_hidden)
        for node in node_list:
            channel_info = getter_function(node)
            if channel in channel_info:

# Path: rosapi/src/rosapi/glob_helper.py
# def any_match(query, globs):
#     return (
#         globs is None or len(globs) == 0 or any(fnmatch.fnmatch(str(query), glob) for glob in globs)
#     )
# 
# def filter_globs(globs, full_list):
#     # If the globs are empty (weren't defined in the params), return the full list
#     if globs is not None and len(globs) > 0:
#         return list(filter(lambda x: any_match(x, globs), full_list))
#     else:
#         return full_list


# Path: rosapi/src/rosapi/proxy.py
from ros2node.api import (
    get_node_names,
    get_publisher_info,
    get_service_server_info,
    get_subscriber_info,
)
from ros2service.api import get_service_names, get_service_names_and_types
from ros2topic.api import get_topic_names, get_topic_names_and_types
from .glob_helper import any_match, filter_globs

                possibility = [0, 0]
            if possible_action_server == namespace and topic in action_topics:
                possibility[action_topics.index(topic)] = 1
            if all(p == 1 for p in possibility):
                action_servers.append(possible_action_server)
                possibility = [0, 0]

    return action_servers


def get_service_type(service, services_glob):
    """Returns the type of the specified ROS service,"""
    # Note: this doesn't consider hidden services.
    services, types = get_services_and_types(services_glob)
    try:
        return types[services.index(service)]
    except ValueError:
        # Return empty string if the service is not present.
        return ""


def get_channel_info(channel, channels_glob, getter_function, include_hidden=False):
    """Returns a list of node names that are publishing / subscribing to the specified topic,
    or advertising a given service."""
    if any_match(str(channel), channels_glob):
        channel_info_list = []
        node_list = get_nodes(include_hidden)
        for node in node_list:
            channel_info = getter_function(node)
            if channel in channel_info:

                channel_info_list.append(node)