neulab/docprompting-conala huggingface dataset:
exception urllib.error.HTTPError  
Though being an exception (a subclass of URLError), an HTTPError can also function as a non-exceptional file-like return value (the same thing that urlopen() returns). This is useful when handling exotic HTTP errors, such as requests for authentication.  
code  
An HTTP status code as defined in RFC 2616. This numeric value corresponds to a value found in the dictionary of codes as found in http.server.BaseHTTPRequestHandler.responses. 
  
reason  
This is usually a string explaining the reason for this error. 
  
headers  
The HTTP response headers for the HTTP request that caused the HTTPError.  New in version 3.4.
code  
An HTTP status code as defined in RFC 2616. This numeric value corresponds to a value found in the dictionary of codes as found in http.server.BaseHTTPRequestHandler.responses.
headers  
The HTTP response headers for the HTTP request that caused the HTTPError.  New in version 3.4.
exception urllib.error.URLError  
The handlers raise this exception (or derived exceptions) when they run into a problem. It is a subclass of OSError.  
reason  
The reason for this error. It can be a message string or another exception instance. 
  Changed in version 3.3: URLError has been made a subclass of OSError instead of IOError.
class urllib.parse.DefragResult(url, fragment)  
Concrete class for urldefrag() results containing str data. The encode() method returns a DefragResultBytes instance.  New in version 3.2.
class urllib.parse.DefragResultBytes(url, fragment)  
Concrete class for urldefrag() results containing bytes data. The decode() method returns a DefragResult instance.  New in version 3.2.
class urllib.parse.ParseResult(scheme, netloc, path, params, query, fragment)  
Concrete class for urlparse() results containing str data. The encode() method returns a ParseResultBytes instance.
class urllib.parse.ParseResultBytes(scheme, netloc, path, params, query, fragment)  
Concrete class for urlparse() results containing bytes data. The decode() method returns a ParseResult instance.  New in version 3.2.
urllib.parse.parse_qs(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&')  
Parse a query string given as a string argument (data of type application/x-www-form-urlencoded). Data are returned as a dictionary. The dictionary keys are the unique query variable names and the values are lists of values for each name. The optional argument keep_blank_values is a flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. The optional argument strict_parsing is a flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. The optional argument max_num_fields is the maximum number of fields to read. If set, then throws a ValueError if there are more than max_num_fields fields read. The optional argument separator is the symbol to use for separating the query arguments. It defaults to &. Use the urllib.parse.urlencode() function (with the doseq parameter set to True) to convert such dictionaries into query strings.  Changed in version 3.2: Add encoding and errors parameters.   Changed in version 3.8: Added max_num_fields parameter.   Changed in version 3.9.2: Added separator parameter with the default value of &. Python versions earlier than Python 3.9.2 allowed using both ; and & as query parameter separator. This has been changed to allow only a single separator key, with & as the default separator.
urllib.parse.parse_qsl(qs, keep_blank_values=False, strict_parsing=False, encoding='utf-8', errors='replace', max_num_fields=None, separator='&')  
Parse a query string given as a string argument (data of type application/x-www-form-urlencoded). Data are returned as a list of name, value pairs. The optional argument keep_blank_values is a flag indicating whether blank values in percent-encoded queries should be treated as blank strings. A true value indicates that blanks should be retained as blank strings. The default false value indicates that blank values are to be ignored and treated as if they were not included. The optional argument strict_parsing is a flag indicating what to do with parsing errors. If false (the default), errors are silently ignored. If true, errors raise a ValueError exception. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. The optional argument max_num_fields is the maximum number of fields to read. If set, then throws a ValueError if there are more than max_num_fields fields read. The optional argument separator is the symbol to use for separating the query arguments. It defaults to &. Use the urllib.parse.urlencode() function to convert such lists of pairs into query strings.  Changed in version 3.2: Add encoding and errors parameters.   Changed in version 3.8: Added max_num_fields parameter.   Changed in version 3.9.2: Added separator parameter with the default value of &. Python versions earlier than Python 3.9.2 allowed using both ; and & as query parameter separator. This has been changed to allow only a single separator key, with & as the default separator.
urllib.parse.quote(string, safe='/', encoding=None, errors=None)  
Replace special characters in string using the %xx escape. Letters, digits, and the characters '_.-~' are never quoted. By default, this function is intended for quoting the path section of a URL. The optional safe parameter specifies additional ASCII characters that should not be quoted — its default value is '/'. string may be either a str or a bytes object.  Changed in version 3.7: Moved from RFC 2396 to RFC 3986 for quoting URL strings. “~” is now included in the set of unreserved characters.  The optional encoding and errors parameters specify how to deal with non-ASCII characters, as accepted by the str.encode() method. encoding defaults to 'utf-8'. errors defaults to 'strict', meaning unsupported characters raise a UnicodeEncodeError. encoding and errors must not be supplied if string is a bytes, or a TypeError is raised. Note that quote(string, safe, encoding, errors) is equivalent to quote_from_bytes(string.encode(encoding, errors), safe). Example: quote('/El Niño/') yields '/El%20Ni%C3%B1o/'.
urllib.parse.quote_from_bytes(bytes, safe='/')  
Like quote(), but accepts a bytes object rather than a str, and does not perform string-to-bytes encoding. Example: quote_from_bytes(b'a&\xef') yields 'a%26%EF'.
urllib.parse.quote_plus(string, safe='', encoding=None, errors=None)  
Like quote(), but also replace spaces with plus signs, as required for quoting HTML form values when building up a query string to go into a URL. Plus signs in the original string are escaped unless they are included in safe. It also does not have safe default to '/'. Example: quote_plus('/El Niño/') yields '%2FEl+Ni%C3%B1o%2F'.
class urllib.parse.SplitResult(scheme, netloc, path, query, fragment)  
Concrete class for urlsplit() results containing str data. The encode() method returns a SplitResultBytes instance.
class urllib.parse.SplitResultBytes(scheme, netloc, path, query, fragment)  
Concrete class for urlsplit() results containing bytes data. The decode() method returns a SplitResult instance.  New in version 3.2.
urllib.parse.unquote(string, encoding='utf-8', errors='replace')  
Replace %xx escapes with their single-character equivalent. The optional encoding and errors parameters specify how to decode percent-encoded sequences into Unicode characters, as accepted by the bytes.decode() method. string may be either a str or a bytes object. encoding defaults to 'utf-8'. errors defaults to 'replace', meaning invalid sequences are replaced by a placeholder character. Example: unquote('/El%20Ni%C3%B1o/') yields '/El Niño/'.  Changed in version 3.9: string parameter supports bytes and str objects (previously only str).
urllib.parse.unquote_plus(string, encoding='utf-8', errors='replace')  
Like unquote(), but also replace plus signs with spaces, as required for unquoting HTML form values. string must be a str. Example: unquote_plus('/El+Ni%C3%B1o/') yields '/El Niño/'.
urllib.parse.unquote_to_bytes(string)  
Replace %xx escapes with their single-octet equivalent, and return a bytes object. string may be either a str or a bytes object. If it is a str, unescaped non-ASCII characters in string are encoded into UTF-8 bytes. Example: unquote_to_bytes('a%26%EF') yields b'a&\xef'.
urllib.parse.unwrap(url)  
Extract the url from a wrapped URL (that is, a string formatted as <URL:scheme://host/path>, <scheme://host/path>, URL:scheme://host/path or scheme://host/path). If url is not a wrapped URL, it is returned without changes.
urllib.parse.urldefrag(url)  
If url contains a fragment identifier, return a modified version of url with no fragment identifier, and the fragment identifier as a separate string. If there is no fragment identifier in url, return url unmodified and an empty string. The return value is a named tuple, its items can be accessed by index or as named attributes:   
Attribute Index Value Value if not present   
url 0 URL with no fragment empty string  
fragment 1 Fragment identifier empty string   See section Structured Parse Results for more information on the result object.  Changed in version 3.2: Result is a structured object rather than a simple 2-tuple.
urllib.parse.urlencode(query, doseq=False, safe='', encoding=None, errors=None, quote_via=quote_plus)  
Convert a mapping object or a sequence of two-element tuples, which may contain str or bytes objects, to a percent-encoded ASCII text string. If the resultant string is to be used as a data for POST operation with the urlopen() function, then it should be encoded to bytes, otherwise it would result in a TypeError. The resulting string is a series of key=value pairs separated by '&' characters, where both key and value are quoted using the quote_via function. By default, quote_plus() is used to quote the values, which means spaces are quoted as a '+' character and ‘/’ characters are encoded as %2F, which follows the standard for GET requests (application/x-www-form-urlencoded). An alternate function that can be passed as quote_via is quote(), which will encode spaces as %20 and not encode ‘/’ characters. For maximum control of what is quoted, use quote and specify a value for safe. When a sequence of two-element tuples is used as the query argument, the first element of each tuple is a key and the second is a value. The value element in itself can be a sequence and in that case, if the optional parameter doseq evaluates to True, individual key=value pairs separated by '&' are generated for each element of the value sequence for the key. The order of parameters in the encoded string will match the order of parameter tuples in the sequence. The safe, encoding, and errors parameters are passed down to quote_via (the encoding and errors parameters are only passed when a query element is a str). To reverse this encoding process, parse_qs() and parse_qsl() are provided in this module to parse query strings into Python data structures. Refer to urllib examples to find out how the urllib.parse.urlencode() method can be used for generating the query string of a URL or data for a POST request.  Changed in version 3.2: query supports bytes and string objects.   New in version 3.5: quote_via parameter.
urllib.parse.urljoin(base, url, allow_fragments=True)  
Construct a full (“absolute”) URL by combining a “base URL” (base) with another URL (url). Informally, this uses components of the base URL, in particular the addressing scheme, the network location and (part of) the path, to provide missing components in the relative URL. For example: >>> from urllib.parse import urljoin
>>> urljoin('http://www.cwi.nl/%7Eguido/Python.html', 'FAQ.html')
'http://www.cwi.nl/%7Eguido/FAQ.html'
 The allow_fragments argument has the same meaning and default as for urlparse().  Note If url is an absolute URL (that is, it starts with // or scheme://), the url’s hostname and/or scheme will be present in the result. For example: >>> urljoin('http://www.cwi.nl/%7Eguido/Python.html',
...         '//www.python.org/%7Eguido')
'http://www.python.org/%7Eguido'
 If you do not want that behavior, preprocess the url with urlsplit() and urlunsplit(), removing possible scheme and netloc parts.   Changed in version 3.5: Behavior updated to match the semantics defined in RFC 3986.
urllib.parse.SplitResult.geturl()  
Return the re-combined version of the original URL as a string. This may differ from the original URL in that the scheme may be normalized to lower case and empty components may be dropped. Specifically, empty parameters, queries, and fragment identifiers will be removed. For urldefrag() results, only empty fragment identifiers will be removed. For urlsplit() and urlparse() results, all noted changes will be made to the URL returned by this method. The result of this method remains unchanged if passed back through the original parsing function: >>> from urllib.parse import urlsplit
>>> url = 'HTTP://www.Python.org/doc/#'
>>> r1 = urlsplit(url)
>>> r1.geturl()
'http://www.Python.org/doc/'
>>> r2 = urlsplit(r1.geturl())
>>> r2.geturl()
'http://www.Python.org/doc/'
urllib.parse.urlsplit(urlstring, scheme='', allow_fragments=True)  
This is similar to urlparse(), but does not split the params from the URL. This should generally be used instead of urlparse() if the more recent URL syntax allowing parameters to be applied to each segment of the path portion of the URL (see RFC 2396) is wanted. A separate function is needed to separate the path segments and parameters. This function returns a 5-item named tuple: (addressing scheme, network location, path, query, fragment identifier).
 The return value is a named tuple, its items can be accessed by index or as named attributes:   
Attribute Index Value Value if not present   
scheme 0 URL scheme specifier scheme parameter  
netloc 1 Network location part empty string  
path 2 Hierarchical path empty string  
query 3 Query component empty string  
fragment 4 Fragment identifier empty string  
username  User name None  
password  Password None  
hostname  Host name (lower case) None  
port  Port number as integer, if present None   Reading the port attribute will raise a ValueError if an invalid port is specified in the URL. See section Structured Parse Results for more information on the result object. Unmatched square brackets in the netloc attribute will raise a ValueError. Characters in the netloc attribute that decompose under NFKC normalization (as used by the IDNA encoding) into any of /, ?, #, @, or : will raise a ValueError. If the URL is decomposed before parsing, no error will be raised.  Changed in version 3.6: Out-of-range port numbers now raise ValueError, instead of returning None.   Changed in version 3.8: Characters that affect netloc parsing under NFKC normalization will now raise ValueError.
urllib.parse.urlunparse(parts)  
Construct a URL from a tuple as returned by urlparse(). The parts argument can be any six-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent).
urllib.parse.urlunsplit(parts)  
Combine the elements of a tuple as returned by urlsplit() into a complete URL as a string. The parts argument can be any five-item iterable. This may result in a slightly different, but equivalent URL, if the URL that was parsed originally had unnecessary delimiters (for example, a ? with an empty query; the RFC states that these are equivalent).
class urllib.request.AbstractBasicAuthHandler(password_mgr=None)  
This is a mixin class that helps with HTTP authentication, both to the remote host and to a proxy. password_mgr, if given, should be something that is compatible with HTTPPasswordMgr; refer to section HTTPPasswordMgr Objects for information on the interface that must be supported. If passwd_mgr also provides is_authenticated and update_authenticated methods (see HTTPPasswordMgrWithPriorAuth Objects), then the handler will use the is_authenticated result for a given URI to determine whether or not to send authentication credentials with the request. If is_authenticated returns True for the URI, credentials are sent. If is_authenticated is False, credentials are not sent, and then if a 401 response is received the request is re-sent with the authentication credentials. If authentication succeeds, update_authenticated is called to set is_authenticated True for the URI, so that subsequent requests to the URI or any of its super-URIs will automatically include the authentication credentials.  New in version 3.5: Added is_authenticated support.
AbstractBasicAuthHandler.http_error_auth_reqed(authreq, host, req, headers)  
Handle an authentication request by getting a user/password pair, and re-trying the request. authreq should be the name of the header where the information about the realm is included in the request, host specifies the URL and path to authenticate for, req should be the (failed) Request object, and headers should be the error headers. host is either an authority (e.g. "python.org") or a URL containing an authority component (e.g. "http://python.org/"). In either case, the authority must not contain a userinfo component (so, "python.org" and "python.org:80" are fine, "joe:password@python.org" is not).
class urllib.request.AbstractDigestAuthHandler(password_mgr=None)  
This is a mixin class that helps with HTTP authentication, both to the remote host and to a proxy. password_mgr, if given, should be something that is compatible with HTTPPasswordMgr; refer to section HTTPPasswordMgr Objects for information on the interface that must be supported.
AbstractDigestAuthHandler.http_error_auth_reqed(authreq, host, req, headers)  
authreq should be the name of the header where the information about the realm is included in the request, host should be the host to authenticate to, req should be the (failed) Request object, and headers should be the error headers.
class urllib.request.BaseHandler  
This is the base class for all registered handlers — and handles only the simple mechanics of registration.
BaseHandler.default_open(req)  
This method is not defined in BaseHandler, but subclasses should define it if they want to catch all URLs. This method, if implemented, will be called by the parent OpenerDirector. It should return a file-like object as described in the return value of the open() of OpenerDirector, or None. It should raise URLError, unless a truly exceptional thing happens (for example, MemoryError should not be mapped to URLError). This method will be called before any protocol-specific open method.
BaseHandler.http_error_default(req, fp, code, msg, hdrs)  
This method is not defined in BaseHandler, but subclasses should override it if they intend to provide a catch-all for otherwise unhandled HTTP errors. It will be called automatically by the OpenerDirector getting the error, and should not normally be called in other circumstances. req will be a Request object, fp will be a file-like object with the HTTP error body, code will be the three-digit code of the error, msg will be the user-visible explanation of the code and hdrs will be a mapping object with the headers of the error. Return values and exceptions raised should be the same as those of urlopen().
BaseHandler.parent  
A valid OpenerDirector, which can be used to open using a different protocol, or handle errors.
BaseHandler.unknown_open(req)  
This method is not defined in BaseHandler, but subclasses should define it if they want to catch all URLs with no specific registered handler to open it. This method, if implemented, will be called by the parent OpenerDirector. Return values should be the same as for default_open().
urllib.request.build_opener([handler, ...])  
Return an OpenerDirector instance, which chains the handlers in the order given. handlers can be either instances of BaseHandler, or subclasses of BaseHandler (in which case it must be possible to call the constructor without any parameters). Instances of the following classes will be in front of the handlers, unless the handlers contain them, instances of them or subclasses of them: ProxyHandler (if proxy settings are detected), UnknownHandler, HTTPHandler, HTTPDefaultErrorHandler, HTTPRedirectHandler, FTPHandler, FileHandler, HTTPErrorProcessor. If the Python installation has SSL support (i.e., if the ssl module can be imported), HTTPSHandler will also be added. A BaseHandler subclass may also change its handler_order attribute to modify its position in the handlers list.
class urllib.request.CacheFTPHandler  
Open FTP URLs, keeping a cache of open FTP connections to minimize delays.
CacheFTPHandler.setMaxConns(m)  
Set maximum number of cached connections to m.
class urllib.request.DataHandler  
Open data URLs.  New in version 3.4.
DataHandler.data_open(req)  
Read a data URL. This kind of URL contains the content encoded in the URL itself. The data URL syntax is specified in RFC 2397. This implementation ignores white spaces in base64 encoded data URLs so the URL may be wrapped in whatever source file it comes from. But even though some browsers don’t mind about a missing padding at the end of a base64 encoded data URL, this implementation will raise an ValueError in that case.
class urllib.request.FancyURLopener(...)  
 Deprecated since version 3.3.  FancyURLopener subclasses URLopener providing default handling for the following HTTP response codes: 301, 302, 303, 307 and 401. For the 30x response codes listed above, the Location header is used to fetch the actual URL. For 401 response codes (authentication required), basic HTTP authentication is performed. For the 30x response codes, recursion is bounded by the value of the maxtries attribute, which defaults to 10. For all other response codes, the method http_error_default() is called which you can override in subclasses to handle the error appropriately.  Note According to the letter of RFC 2616, 301 and 302 responses to POST requests must not be automatically redirected without confirmation by the user. In reality, browsers do allow automatic redirection of these responses, changing the POST to a GET, and urllib reproduces this behaviour.  The parameters to the constructor are the same as those for URLopener.  Note When performing basic authentication, a FancyURLopener instance calls its prompt_user_passwd() method. The default implementation asks the users for the required information on the controlling terminal. A subclass may override this method to support more appropriate behavior if needed.  The FancyURLopener class offers one additional method that should be overloaded to provide the appropriate behavior:  
prompt_user_passwd(host, realm)  
Return information needed to authenticate the user at the given host in the specified security realm. The return value should be a tuple, (user,
password), which can be used for basic authentication. The implementation prompts for this information on the terminal; an application should override this method to use an appropriate interaction model in the local environment.
prompt_user_passwd(host, realm)  
Return information needed to authenticate the user at the given host in the specified security realm. The return value should be a tuple, (user,
password), which can be used for basic authentication. The implementation prompts for this information on the terminal; an application should override this method to use an appropriate interaction model in the local environment.
FileHandler.file_open(req)  
Open the file locally, if there is no host name, or the host name is 'localhost'.  Changed in version 3.2: This method is applicable only for local hostnames. When a remote hostname is given, an URLError is raised.