<commit_before>"""
    ulmo.cuahsi.his_central.core
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    This module provides direct access to the `CUAHSI HIS Central`_ web service.


    .. _CUAHSI HIS Central: http://his.cuahsi.org/hiscentral.html
"""
import suds

from ulmo import util


HIS_CENTRAL_WSDL_URL = 'http://hiscentral.cuahsi.org/webservices/hiscentral.asmx?WSDL'


def get_services(bbox=None):
    """Retrieves a list of services.


    Parameters
    ----------
    bbox : ``None`` or 4-tuple
        Optional argument for a bounding box that covers the area you want to
        look for services in. This should be a tuple containing min_latitude,
        min_longitude, max_latitude, and max_longitude with these values in
        decimal degrees. If not provided then the full set of services will be
        queried from HIS Central.


    Returns
    -------
    services_dicts : list
        A list of dicts that each contain information on an individual service.
    """
    suds_client = suds.client.Client(HIS_CENTRAL_WSDL_URL)

    if bbox is None:
        services = suds_client.service.GetWaterOneFlowServiceInfo()
    else:
        x_min, y_min, x_max, y_max = bbox
        services = suds_client.service.GetServicesInBox2(
            xmin=x_min, ymin=y_min, xmax=x_max, ymax=y_max)

    services = [
        _service_dict(service_info)
        for service_info in services.ServiceInfo
    ]
    return services


def _cast_if_text(obj):
    """casts sax.text.Text objects to regular python strings, but leaves other<commit_msg>docfix: correct bbox order in docstring for his_central.get_services; fixes #61<commit_after>"""
    ulmo.cuahsi.his_central.core
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    This module provides direct access to the `CUAHSI HIS Central`_ web service.


    .. _CUAHSI HIS Central: http://his.cuahsi.org/hiscentral.html
"""
import suds

from ulmo import util


HIS_CENTRAL_WSDL_URL = 'http://hiscentral.cuahsi.org/webservices/hiscentral.asmx?WSDL'


def get_services(bbox=None):
    """Retrieves a list of services.


    Parameters
    ----------
    bbox : ``None`` or 4-tuple
        Optional argument for a bounding box that covers the area you want to
        look for services in. This should be a tuple containing (min_longitude,
        min_latitude, max_longitude, and max_latitude) with these values in
        decimal degrees. If not provided then the full set of services will be
        queried from HIS Central.


    Returns
    -------
    services_dicts : list
        A list of dicts that each contain information on an individual service.
    """
    suds_client = suds.client.Client(HIS_CENTRAL_WSDL_URL)

    if bbox is None:
        services = suds_client.service.GetWaterOneFlowServiceInfo()
    else:
        x_min, y_min, x_max, y_max = bbox
        services = suds_client.service.GetServicesInBox2(
            xmin=x_min, ymin=y_min, xmax=x_max, ymax=y_max)

    services = [
        _service_dict(service_info)
        for service_info in services.ServiceInfo
    ]
    return services


def _cast_if_text(obj):
    """casts sax.text.Text objects to regular python strings, but leaves other
{'fraction_non_alphanumeric': 0.09701965757767914, 'fraction_numerical': 0.0019023462270133164, 'mean_word_length': 2.8902589395807645, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7636781', 'n_tokens_mistral': 1009, 'n_tokens_neox': 953, 'n_words': 292}