<commit_before>#    Copyright 2012 ClusterPoint, SIA
#
#    This file is part of Pycps.
#
#    Pycps is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Pycps is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with Pycps.  If not, see <http://www.gnu.org/licenses/>.

import httplib
import urlparse
import socket

from request import *


class Connection(object):
    """ Connection object class to hold connections with CPS and use them.

    .. note:: For now only http protocol suported!

    """

    def __init__(self, url, storage, user, password,
                    document_root_xpath = 'document', document_id_xpath = './id',
                    selector_url = '/cgi-bin/cps2-cgi', application='PYCPS',  reply_charset=None):
        """ Create a new connection to CPS.

            Args:
                host -- A host address string.
                port -- A host port number.
                url -- The connection string containing host, port and scheme of connection.
                        Example: 'tcp://127.0.0.1:5550'.
                storage -- A CPS storage name string.
                user -- A user name string.
                password -- A user password string.

            Keyword args:
                document_root_tag -- A custum document root tag. Default is 'document'.
                document_id_tag -- A custum document id xpath relative document root. Default is './id'.
                selector_urli -- A nonstandart selector url for xml requests. Default is '/cgi-bin/cps2-cgi'.
                application -- Optional application string. Default is 'PYCPS'.
                reply_charset -- Optional reply charset string.
        """
        self._storage = storage
        self._user = user
        self._password = password
        self._selector_url = selector_url

        self.document_root_xpath = document_root_xpath
        self.document_id_xpath = document_id_xpath
        self.application = application
        self.reply_charset = reply_charset

        self._set_url(url)<commit_msg>Fix comment<commit_after>#    Copyright 2012 ClusterPoint, SIA
#
#    This file is part of Pycps.
#
#    Pycps is free software: you can redistribute it and/or modify
#    it under the terms of the GNU Affero General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    Pycps is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU Affero General Public License for more details.
#
#    You should have received a copy of the GNU Affero General Public License
#    along with Pycps.  If not, see <http://www.gnu.org/licenses/>.

import httplib
import urlparse
import socket

from request import *


class Connection(object):
    """ Connection object class to hold connections with CPS and use them.

    .. note:: For now only http protocol suported!

    """

    def __init__(self, url, storage, user, password,
                    document_root_xpath = 'document', document_id_xpath = './id',
                    selector_url = '/cgi-bin/cps2-cgi', application='PYCPS',  reply_charset=None):
        """ Create a new connection to CPS.

            Args:
                url -- The connection string containing host, port and scheme of connection.
                        Example: 'tcp://127.0.0.1:5550'.
                storage -- A CPS storage name string.
                user -- A user name string.
                password -- A user password string.

            Keyword args:
                document_root_tag -- A custum document root tag. Default is 'document'.
                document_id_tag -- A custum document id xpath relative document root. Default is './id'.
                selector_urli -- A nonstandart selector url for xml requests. Default is '/cgi-bin/cps2-cgi'.
                application -- Optional application string. Default is 'PYCPS'.
                reply_charset -- Optional reply charset string.
        """
        self._storage = storage
        self._user = user
        self._password = password
        self._selector_url = selector_url

        self.document_root_xpath = document_root_xpath
        self.document_id_xpath = document_id_xpath
        self.application = application
        self.reply_charset = reply_charset

        self._set_url(url)
{'fraction_non_alphanumeric': 0.0722502522704339, 'fraction_numerical': 0.0068617558022199794, 'mean_word_length': 2.1810012836970474, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 2, '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': '5353310', 'n_tokens_mistral': 1320, 'n_tokens_neox': 1236, 'n_words': 514}