<commit_before># -*- coding: UTF-8 -*- 
'''
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
'''
import os
from robot.api import logger

from base64 import b64encode
from functools import wraps

import pycurl
from url import Url

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
execfile(os.path.join(THIS_DIR, 'version.py'))

__version__ = VERSION

__all__ = ['include', 'verbose', 'insecure', 'add_header', 'headers_file', 
           'post_fields', 'post_fields_file', 'request_method', 'data_file', 
           'set_url', 'ca_path', 'cert', 'key', 'perform', 'response', 
           'response_header'
          ]

class PycURLLibrary():
    """PycURLLibrary is a library for functional testing with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, 
    HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. 
    PycURLLibrary supports SSL certificates and more.

    PycURLLibrary is based on PycURL [http://pycurl.sourceforge.net/], 
    PycURL is a Python interface to libcurl [http://curl.haxx.se/libcurl/].
    """
    
    ROBOT_LIBRARY_VERSION = VERSION
    ROBOT_LIBRARY_SCOPE = "TEST CASE"
    ROBOT_LIBRARY_DOC_FORMAT = "ROBOT"

    def __init__(self):
        self._logger = logger
        self._url = Url()
        
    def verbose(self):
        """Makes the fetching more verbose/talkative.
        
        Mostly useful for debugging. A line starting with '>' means "header data" sent by curl, 
        '<' means "header data" received by curl that is hidden in normal cases, and a line starting with '*' means additional info provided by curl.
        
        Note that if you only want HTTP headers in the output, -i, --include might be the option you're looking for.
        
        If you think this option still doesn't give you enough details, consider using --trace or --trace-ascii instead.
        
        This option overrides previous uses of --trace-ascii or --trace.         
        """
        self._url.set_verbose(True)
        
#    def no_buffer(self):
#        """Disables the buffering of the output stream.
#        
#        In normal work situations, curl will use a standard buffered output stream that will have the effect that it will output the data in chunks, 
#        not necessarily exactly when the data arrives. Using this option will disable that buffering.
#        Note that this is the negated option name documented. You can thus use --buffer to enforce the buffering. 
#        """
        
    def insecure(self):
        """(SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers.
        
        All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. 
        This makes all connections considered "insecure" fail unless -k, --insecure is used. 
        """
        self._url.set_insecure(True)
        
    def request_method(self, requestMethod):
        """ Set's the request method. Default's to GET if Post Fields keyword is used POST is used
        | Method |
        | GET |
        | POST |
        | PUT |
        | DELETE |
        """
        self._url.get_context().set_request_method(requestMethod)
        
    def add_header(self, header):
        """(HTTP) Extra header to use when getting a web page.
        
        Each *Add Header* keyword is equivalent for one <-H, --header> argument with curl
        <commit_msg>Issue #12 implemented<commit_after># -*- coding: UTF-8 -*- 
'''
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

  http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
'''
import os
from robot.api import logger

from base64 import b64encode
from functools import wraps

import pycurl
from url import Url

THIS_DIR = os.path.dirname(os.path.abspath(__file__))
execfile(os.path.join(THIS_DIR, 'version.py'))

__version__ = VERSION

__all__ = ['include', 'verbose', 'insecure', 'add_header', 'headers_file', 
           'post_fields', 'post_fields_file', 'request_method', 'data_file', 
           'set_url', 'ca_path', 'cert', 'key', 'perform', 'response', 
           'response_header'
          ]

class PycURLLibrary():
    """PycURLLibrary is a library for functional testing with URL syntax, supporting DICT, FILE, FTP, FTPS, Gopher, HTTP, 
    HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMTP, SMTPS, Telnet and TFTP. 
    PycURLLibrary supports SSL certificates and more.

    PycURLLibrary is based on PycURL [http://pycurl.sourceforge.net/], 
    PycURL is a Python interface to libcurl [http://curl.haxx.se/libcurl/].
    """
    
    ROBOT_LIBRARY_VERSION = VERSION
    ROBOT_LIBRARY_SCOPE = "TEST CASE"
    ROBOT_LIBRARY_DOC_FORMAT = "ROBOT"

    def __init__(self):
        self._logger = logger
        self._url = Url()
        
    def verbose(self):
        """Makes the fetching more verbose/talkative.
        
        Mostly useful for debugging. A line starting with '>' means "header data" sent by curl, 
        '<' means "header data" received by curl that is hidden in normal cases, and a line starting with '*' means additional info provided by curl.
        
        Note that if you only want HTTP headers in the output, -i, --include might be the option you're looking for.
        
        If you think this option still doesn't give you enough details, consider using --trace or --trace-ascii instead.
        
        This option overrides previous uses of --trace-ascii or --trace.         
        """
        self._url.set_verbose(True)
        
#    def no_buffer(self):
#        """Disables the buffering of the output stream.
#        
#        In normal work situations, curl will use a standard buffered output stream that will have the effect that it will output the data in chunks, 
#        not necessarily exactly when the data arrives. Using this option will disable that buffering.
#        Note that this is the negated option name documented. You can thus use --buffer to enforce the buffering. 
#        """
        
    def insecure_ssl(self):
        """(SSL) This option explicitly allows curl to perform "insecure" SSL connections and transfers.
        
        All SSL connections are attempted to be made secure by using the CA certificate bundle installed by default. 
        This makes all connections considered "insecure" fail unless -k, --insecure is used. 
        """
        self._url.set_insecure(True)
        
    def request_method(self, requestMethod):
        """ Set's the request method. Default's to GET if Post Fields keyword is used POST is used
        | Method |
        | GET |
        | POST |
        | PUT |
        | DELETE |
        """
        self._url.get_context().set_request_method(requestMethod)
        
    def add_header(self, header):
        """(HTTP) Extra header to use when getting a web page.
        
        Each *Add Header* keyword is equivalent for one <-H, --header> argument with curl
        
{'fraction_non_alphanumeric': 0.08049424184261036, 'fraction_numerical': 0.0028790786948176585, 'mean_word_length': 2.780952380952381, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3925417', 'n_tokens_mistral': 2346, 'n_tokens_neox': 2235, 'n_words': 962}