<commit_before># pylint: disable-msg=W0402,W0231,W0141,R0903,C0321,W0701,R0904,C0103,W0201,W0102,R0913,W0622,E1101,C0111,C0121,R0901
# DAV client library
#
# Copyright (C) 1998-2000 <NAME>. All Rights Reserved.
# Written by <NAME>. Given to Guido. Licensed using the Python license.
#
# This module is maintained by Greg and is available at:
#    http://www.lyra.org/greg/python/davlib.py
#
# Since this isn't in the Python distribution yet, we'll use the CVS ID
# for tracking:
#   $Id: davlib.py 3182 2008-02-22 15:57:55 +0000 (Fr, 22 Feb 2008) schlauch $
#

import httplib
import urllib
import string
import types
import mimetypes
import qp_xml


INFINITY = 'infinity'
XML_DOC_HEADER = '<?xml version="1.0" encoding="utf-8"?>'
XML_CONTENT_TYPE = 'text/xml; charset="utf-8"'

# block size for copying files up to the server
BLOCKSIZE = 16384


class HTTPProtocolChooser(httplib.HTTPSConnection):
    def __init__(self, *args, **kw):
        self.protocol = kw.pop('protocol')
        if self.protocol == "https":
            self.default_port = 443
        else:
            self.default_port = 80
            
        apply(httplib.HTTPSConnection.__init__, (self,) + args, kw)

    def connect(self):
        if self.protocol == "https":
            httplib.HTTPSConnection.connect(self)
        else:
            httplib.HTTPConnection.connect(self)


class HTTPConnectionAuth(HTTPProtocolChooser):
    def __init__(self, *args, **kw):
        apply(HTTPProtocolChooser.__init__, (self,) + args, kw)

        self.__username = None
        self.__password = None
        self.__nonce = None
        self.__opaque = None

    def setauth(self, username, password):
        self.__username = username
        self.__password = password

<commit_msg>made davlib work also when SSL is not available, HTTPS connections are aborted then but plain HTTP works. for running on windows in debugmode when _ssl_d.pyd (dll) is not there.<commit_after># pylint: disable-msg=W0402,W0231,W0141,R0903,C0321,W0701,R0904,C0103,W0201,W0102,R0913,W0622,E1101,C0111,C0121,R0901
# DAV client library
#
# Copyright (C) 1998-2000 <NAME>. All Rights Reserved.
# Written by <NAME>. Given to Guido. Licensed using the Python license.
#
# This module is maintained by Greg and is available at:
#    http://www.lyra.org/greg/python/davlib.py
#
# Since this isn't in the Python distribution yet, we'll use the CVS ID
# for tracking:
#   $Id: davlib.py 3182 2008-02-22 15:57:55 +0000 (Fr, 22 Feb 2008) schlauch $
#

import httplib
import urllib
import string
import types
import mimetypes
import qp_xml


INFINITY = 'infinity'
XML_DOC_HEADER = '<?xml version="1.0" encoding="utf-8"?>'
XML_CONTENT_TYPE = 'text/xml; charset="utf-8"'

# block size for copying files up to the server
BLOCKSIZE = 16384

#a trick to support running without _ssl module,
#when running in windows in debugmode without _ssl_d.pyd built
Connection = None #the connection class used, either the HTTP or HTTPS version
has_ssl = None
if not hasattr(httplib, 'HTTPSConnection'):
    Connection = httplib.HTTPConnection
    has_ssl = False
else:
    Connection = httplib.HTTPSConnection
    has_ssl = True

class HTTPProtocolChooser(Connection):
    def __init__(self, *args, **kw):
        self.protocol = kw.pop('protocol')
        if self.protocol == "https":
            if not has_ssl:
                raise RuntimeError, "Running without SSL, HTTPS not supported, aborting connecting."
            self.default_port = 443
        else:
            self.default_port = 80
            
        apply(Connection.__init__, (self,) + args, kw)

    def connect(self):
        if self.protocol == "https":
            if not has_ssl:
                raise RuntimeError, "Running without SSL, HTTPS not supported, aborting connecting."
            httplib.HTTPSConnection.connect(self)
        else:
            httplib.HTTPConnection.connect(self)


class HTTPConnectionAuth(HTTPProtocolChooser):
    def __init__(self, *args, **kw):
        apply(HTTPProtocolChooser.__init__, (self,) + args, kw)

        self.__username = None
        self.__password = None
        self.__nonce = None
        self.__opaque = None

    def setauth(self, username, password):
        self.__username = username
        self.__password = password


{'fraction_non_alphanumeric': 0.10079513564078578, 'fraction_numerical': 0.05332086061739944, 'mean_word_length': 3.193137254901961, 'pattern_counts': {'":': 4, '<': 9, '<?xml version=': 2, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, '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': '2331439', 'n_tokens_mistral': 1509, 'n_tokens_neox': 1319, 'n_words': 393}