<commit_before>import urllib
import urlparse

from . import getLogger
import requests

logger = getLogger(__name__)

class HTTPError(Exception):
    pass

class HTTPClient(object):
    user_agent = "Happy SOAP (from http://nicolasmendoza.org/happy-SOAP/) "

    def __init__(self, url, **kwargs):
        self.url = url
        self.scheme, self.netloc, self.uri, self.params, self.query, self.fragment = urlparse.urlparse(self.url)

        logger.info(
            'Scheme --> %s, '
            'host --> %s, '
            'url --> %s, '
            'params --> %s, '
            'query --> %s, fragment: %s', self.scheme, self.netloc, self.uri, self.params, self.query, self.fragment)

        if kwargs:
            logger.info('kwargs -->%s', kwargs)

    def read_wsdl(self):
        try:
            if self.query == 'wsdl':
                logger.info('WSDL present..')
            else:
                logger.warning('Missed WSDL path in your URL..trying resolve adding ?wsdl query')
                self.url += '?wsdl'

            wsdl = urllib.urlopen(self.url).read()

            logger.info("WSDL Data --> %s", wsdl)

        except IOError:
            raise HTTPError("Cannot open WSDL, please verify that WSDl url is valid -->" + self.url)<commit_msg>[experiment] detecting namespaces..<commit_after># -*- coding: utf8 -*-

from StringIO import StringIO
import urllib
from xml.etree import ElementTree as ET
import urlparse

from . import getLogger

logger = getLogger(__name__)

class HTTPError(Exception):
    pass

class HTTPClient(object):
    user_agent = "Happy SOAP (from http://nicolasmendoza.org/happy-SOAP/) "

    def __init__(self, url, **kwargs):
        self.url = url
        self.scheme, self.netloc, self.uri, self.params, self.query, self.fragment = urlparse.urlparse(self.url)

        logger.info(
            'Scheme --> %s, '
            'host --> %s, '
            'url --> %s, '
            'params --> %s, '
            'query --> %s, fragment: %s', self.scheme, self.netloc, self.uri, self.params, self.query, self.fragment)

        if kwargs:
            logger.info('kwargs -->%s', kwargs)

    def read_wsdl(self):
        try:
            if self.query == 'wsdl':
                logger.info('WSDL present..')
            else:
                logger.warning('Missed WSDL path in your URL..trying resolve adding ?wsdl query')
                self.url += '?wsdl'

            wsdl = urllib.urlopen(self.url).read()

            _file = StringIO(wsdl)

            namespaces = []

            for event, element in ET.iterparse(_file, events=('start-ns','end')):
                logger.debug('event -->%s, element -->%s', event, element)

                if event == 'start-ns':
                    namespaces.append(element)

            logger.info('Namespaces -->%s', namespaces)

        except IOError:
            raise HTTPError("Cannot open WSDL, please verify that WSDl url is valid -->" + self.url)
{'fraction_non_alphanumeric': 0.1376394994927291, 'fraction_numerical': 0.00033818058843422386, 'mean_word_length': 1.958, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 1}, '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': '4846389', 'n_tokens_mistral': 920, 'n_tokens_neox': 878, 'n_words': 228}