neulab/docprompting-conala huggingface dataset:
setlistdefault(key, default_list=None)  
Like setdefault but sets multiple values. The list returned is not a copy, but the list that is actually used internally. This means that you can put new values into the dict by appending items to the list: >>> d = MultiDict({"foo": 1})
>>> d.setlistdefault("foo").extend([2, 3])
>>> d.getlist("foo")
[1, 2, 3]
  Parameters 
 
key – The key to be looked up. 
default_list – An iterable of default values. It is either copied (in case it was a list) or converted into a list before returned.   Returns 
a list
to_dict(flat=True)  
Return the contents as regular dict. If flat is True the returned dict will only have the first item present, if flat is False all values will be returned as lists.  Parameters 
flat – If set to False the dict returned will have lists with all the values in it. Otherwise it will only contain the first value for each key.  Returns 
a dict
update(mapping)  
update() extends rather than replaces existing key lists: >>> a = MultiDict({'x': 1})
>>> b = MultiDict({'x': 2, 'y': 3})
>>> a.update(b)
>>> a
MultiDict([('y', 3), ('x', 1), ('x', 2)])
 If the value list for a key in other_dict is empty, no new values will be added to the dict and the key will not be created: >>> x = {'empty_list': []}
>>> y = MultiDict()
>>> y.update(x)
>>> y
MultiDict([])
class werkzeug.datastructures.OrderedMultiDict(mapping=None)  
Works like a regular MultiDict but preserves the order of the fields. To convert the ordered multi dict into a list you can use the items() method and pass it multi=True. In general an OrderedMultiDict is an order of magnitude slower than a MultiDict.  note Due to a limitation in Python you cannot convert an ordered multi dict into a regular dict by using dict(multidict). Instead you have to use the to_dict() method, otherwise the internal bucket objects are exposed.
werkzeug.http.parse_accept_header(value[, class])  
Parses an HTTP Accept-* header. This does not implement a complete valid algorithm but one that supports at least value and quality extraction. Returns a new Accept object (basically a list of (value, quality) tuples sorted by the quality with some additional accessor methods). The second parameter can be a subclass of Accept that is created with the parsed values and returned.  Parameters 
 
value (Optional[str]) – the accept header string to be parsed. 
cls (Optional[Type[werkzeug.http._TAnyAccept]]) – the wrapper class for the return value (can be Accept or a subclass thereof)   Returns 
an instance of cls.  Return type 
werkzeug.http._TAnyAccept
werkzeug.http.parse_authorization_header(value)  
Parse an HTTP basic/digest authorization header transmitted by the web browser. The return value is either None if the header was invalid or not given, otherwise an Authorization object.  Parameters 
value (Optional[str]) – the authorization header to parse.  Returns 
a Authorization object or None.  Return type 
Optional[werkzeug.datastructures.Authorization]
werkzeug.http.parse_cache_control_header(value, on_update=None, cls=None)  
Parse a cache control header. The RFC differs between response and request cache control, this method does not. It’s your responsibility to not use the wrong control statements.  Changelog New in version 0.5: The cls was added. If not specified an immutable RequestCacheControl is returned.   Parameters 
 
value (Optional[str]) – a cache control header to be parsed. 
on_update (Optional[Callable[[werkzeug.http._TAnyCC], None]]) – an optional callable that is called every time a value on the CacheControl object is changed. 
cls (Optional[Type[werkzeug.http._TAnyCC]]) – the class for the returned object. By default RequestCacheControl is used.   Returns 
a cls object.  Return type 
werkzeug.http._TAnyCC
werkzeug.http.parse_content_range_header(value, on_update=None)  
Parses a range header into a ContentRange object or None if parsing is not possible.  Changelog New in version 0.7.   Parameters 
 
value (Optional[str]) – a content range header to be parsed. 
on_update (Optional[Callable[[werkzeug.datastructures.ContentRange], None]]) – an optional callable that is called every time a value on the ContentRange object is changed.   Return type 
Optional[werkzeug.datastructures.ContentRange]
werkzeug.http.parse_cookie(header, charset='utf-8', errors='replace', cls=None)  
Parse a cookie from a string or WSGI environ. The same key can be provided multiple times, the values are stored in-order. The default MultiDict will have the first value first, and all values can be retrieved with MultiDict.getlist().  Parameters 
 
header (Optional[Union[WSGIEnvironment, str, bytes]]) – The cookie header as a string, or a WSGI environ dict with a HTTP_COOKIE key. 
charset (str) – The charset for the cookie values. 
errors (str) – The error behavior for the charset decoding. 
cls (Optional[Type[ds.MultiDict]]) – A dict-like class to store the parsed cookies in. Defaults to MultiDict.   Return type 
ds.MultiDict[str, str]    Changelog Changed in version 1.0.0: Returns a MultiDict instead of a TypeConversionDict.   Changed in version 0.5: Returns a TypeConversionDict instead of a regular dict. The cls parameter was added.
werkzeug.http.parse_date(value)  
Parse an RFC 2822 date into a timezone-aware datetime.datetime object, or None if parsing fails. This is a wrapper for email.utils.parsedate_to_datetime(). It returns None if parsing fails instead of raising an exception, and always returns a timezone-aware datetime object. If the string doesn’t have timezone information, it is assumed to be UTC.  Parameters 
value (Optional[str]) – A string with a supported date format.  Return type 
Optional[datetime.datetime]    Changed in version 2.0: Return a timezone-aware datetime object. Use email.utils.parsedate_to_datetime.
werkzeug.http.parse_dict_header(value, cls=<class 'dict'>)  
Parse lists of key, value pairs as described by RFC 2068 Section 2 and convert them into a python dict (or any other mapping object created from the type with a dict like interface provided by the cls argument): >>> d = parse_dict_header('foo="is a fish", bar="as well"')
>>> type(d) is dict
True
>>> sorted(d.items())
[('bar', 'as well'), ('foo', 'is a fish')]
 If there is no value for a key it will be None: >>> parse_dict_header('key_without_value')
{'key_without_value': None}
 To create a header from the dict again, use the dump_header() function.  Changelog Changed in version 0.9: Added support for cls argument.   Parameters 
 
value (str) – a string with a dict header. 
cls (Type[dict]) – callable to use for storage of parsed results.   Returns 
an instance of cls  Return type 
Dict[str, str]
werkzeug.http.parse_etags(value)  
Parse an etag header.  Parameters 
value (Optional[str]) – the tag header to parse  Returns 
an ETags object.  Return type 
werkzeug.datastructures.ETags
werkzeug.formparser.parse_form_data(environ, stream_factory=None, charset='utf-8', errors='replace', max_form_memory_size=None, max_content_length=None, cls=None, silent=True)  
Parse the form data in the environ and return it as tuple in the form (stream, form, files). You should only call this method if the transport method is POST, PUT, or PATCH. If the mimetype of the data transmitted is multipart/form-data the files multidict will be filled with FileStorage objects. If the mimetype is unknown the input stream is wrapped and returned as first argument, else the stream is empty. This is a shortcut for the common usage of FormDataParser. Have a look at Dealing with Request Data for more details.  Changelog New in version 0.5.1: The optional silent flag was added.   New in version 0.5: The max_form_memory_size, max_content_length and cls parameters were added.   Parameters 
 
environ (WSGIEnvironment) – the WSGI environment to be used for parsing. 
stream_factory (Optional[TStreamFactory]) – An optional callable that returns a new read and writeable file descriptor. This callable works the same as Response._get_file_stream(). 
charset (str) – The character set for URL and url encoded form data. 
errors (str) – The encoding error behavior. 
max_form_memory_size (Optional[int]) – the maximum number of bytes to be accepted for in-memory stored form data. If the data exceeds the value specified an RequestEntityTooLarge exception is raised. 
max_content_length (Optional[int]) – If this is provided and the transmitted data is longer than this value an RequestEntityTooLarge exception is raised. 
cls (Optional[Type[werkzeug.datastructures.MultiDict]]) – an optional dict class to use. If this is not specified or None the default MultiDict is used. 
silent (bool) – If set to False parsing errors will not be caught.   Returns 
A tuple in the form (stream, form, files).  Return type 
t_parse_result
werkzeug.http.parse_if_range_header(value)  
Parses an if-range header which can be an etag or a date. Returns a IfRange object.  Changed in version 2.0: If the value represents a datetime, it is timezone-aware.   Changelog New in version 0.7.   Parameters 
value (Optional[str]) –   Return type 
werkzeug.datastructures.IfRange
werkzeug.http.parse_list_header(value)  
Parse lists as described by RFC 2068 Section 2. In particular, parse comma-separated lists where the elements of the list may include quoted-strings. A quoted-string could contain a comma. A non-quoted string could have quotes in the middle. Quotes are removed automatically after parsing. It basically works like parse_set_header() just that items may appear multiple times and case sensitivity is preserved. The return value is a standard list: >>> parse_list_header('token, "quoted value"')
['token', 'quoted value']
 To create a header from the list again, use the dump_header() function.  Parameters 
value (str) – a string with a list header.  Returns 
list  Return type 
List[str]
werkzeug.http.parse_options_header(value, multiple=False)  
Parse a Content-Type like header into a tuple with the content type and the options: >>> parse_options_header('text/html; charset=utf8')
('text/html', {'charset': 'utf8'})
 This should not be used to parse Cache-Control like headers that use a slightly different format. For these headers use the parse_dict_header() function.  Changelog Changed in version 0.15: RFC 2231 parameter continuations are handled.   New in version 0.5.   Parameters 
 
value (Optional[str]) – the header to parse. 
multiple (bool) – Whether try to parse and return multiple MIME types   Returns 
(mimetype, options) or (mimetype, options, mimetype, options, …) if multiple=True  Return type 
Union[Tuple[str, Dict[str, str]], Tuple[Any, …]]
werkzeug.http.parse_range_header(value, make_inclusive=True)  
Parses a range header into a Range object. If the header is missing or malformed None is returned. ranges is a list of (start, stop) tuples where the ranges are non-inclusive.  Changelog New in version 0.7.   Parameters 
 
value (Optional[str]) –  
make_inclusive (bool) –    Return type 
Optional[werkzeug.datastructures.Range]
werkzeug.http.parse_set_header(value, on_update=None)  
Parse a set-like header and return a HeaderSet object: >>> hs = parse_set_header('token, "quoted value"')
 The return value is an object that treats the items case-insensitively and keeps the order of the items: >>> 'TOKEN' in hs
True
>>> hs.index('quoted value')
1
>>> hs
HeaderSet(['token', 'quoted value'])
 To create a header from the HeaderSet again, use the dump_header() function.  Parameters 
 
value (Optional[str]) – a set header to be parsed. 
on_update (Optional[Callable[[werkzeug.datastructures.HeaderSet], None]]) – an optional callable that is called every time a value on the HeaderSet object is changed.   Returns 
a HeaderSet  Return type 
werkzeug.datastructures.HeaderSet
werkzeug.http.parse_www_authenticate_header(value, on_update=None)  
Parse an HTTP WWW-Authenticate header into a WWWAuthenticate object.  Parameters 
 
value (Optional[str]) – a WWW-Authenticate header to parse. 
on_update (Optional[Callable[[werkzeug.datastructures.WWWAuthenticate], None]]) – an optional callable that is called every time a value on the WWWAuthenticate object is changed.   Returns 
a WWWAuthenticate object.  Return type 
werkzeug.datastructures.WWWAuthenticate
class werkzeug.routing.PathConverter(map, *args, **kwargs)  
Like the default UnicodeConverter, but it also matches slashes. This is useful for wikis and similar applications: Rule('/<path:wikipage>')
Rule('/<path:wikipage>/edit')
  Parameters 
 
map (Map) – the Map. 
args (Any) –  
kwargs (Any) –    Return type 
None
werkzeug.security.pbkdf2_bin(data, salt, iterations=260000, keylen=None, hashfunc=None)  
Returns a binary digest for the PBKDF2 hash algorithm of data with the given salt. It iterates iterations times and produces a key of keylen bytes. By default, SHA-256 is used as hash function; a different hashlib hashfunc can be provided.  Parameters 
 
data (Union[str, bytes]) – the data to derive. 
salt (Union[str, bytes]) – the salt for the derivation. 
iterations (int) – the number of iterations. 
keylen (Optional[int]) – the length of the resulting key. If not provided the digest size will be used. 
hashfunc (Optional[Union[str, Callable]]) – the hash function to use. This can either be the string name of a known hash function or a function from the hashlib module. Defaults to sha256.   Return type 
bytes    Deprecated since version 2.0: Will be removed in Werkzeug 2.1. Use hashlib.pbkdf2_hmac() instead.   Changelog New in version 0.9.
werkzeug.security.pbkdf2_hex(data, salt, iterations=260000, keylen=None, hashfunc=None)  
Like pbkdf2_bin(), but returns a hex-encoded string.  Parameters 
 
data (Union[str, bytes]) – the data to derive. 
salt (Union[str, bytes]) – the salt for the derivation. 
iterations (int) – the number of iterations. 
keylen (Optional[int]) – the length of the resulting key. If not provided, the digest size will be used. 
hashfunc (Optional[Union[str, Callable]]) – the hash function to use. This can either be the string name of a known hash function, or a function from the hashlib module. Defaults to sha256.   Return type 
str    Deprecated since version 2.0: Will be removed in Werkzeug 2.1. Use hashlib.pbkdf2_hmac() instead.   Changelog New in version 0.9.
werkzeug.wsgi.peek_path_info(environ, charset='utf-8', errors='replace')  
Returns the next segment on the PATH_INFO or None if there is none. Works like pop_path_info() without modifying the environment: >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'}
>>> peek_path_info(env)
'a'
>>> peek_path_info(env)
'a'
 If the charset is set to None bytes are returned.  Changelog Changed in version 0.9: The path is now decoded and a charset and encoding parameter can be provided.   New in version 0.5.   Parameters 
 
environ (WSGIEnvironment) – the WSGI environment that is checked. 
charset (str) –  
errors (str) –    Return type 
Optional[str]
werkzeug.wsgi.pop_path_info(environ, charset='utf-8', errors='replace')  
Removes and returns the next segment of PATH_INFO, pushing it onto SCRIPT_NAME. Returns None if there is nothing left on PATH_INFO. If the charset is set to None bytes are returned. If there are empty segments ('/foo//bar) these are ignored but properly pushed to the SCRIPT_NAME: >>> env = {'SCRIPT_NAME': '/foo', 'PATH_INFO': '/a/b'}
>>> pop_path_info(env)
'a'
>>> env['SCRIPT_NAME']
'/foo/a'
>>> pop_path_info(env)
'b'
>>> env['SCRIPT_NAME']
'/foo/a/b'
  Changelog Changed in version 0.9: The path is now decoded and a charset and encoding parameter can be provided.   New in version 0.5.   Parameters 
 
environ (WSGIEnvironment) – the WSGI environment that is modified. 
charset (str) – The encoding parameter passed to bytes.decode(). 
errors (str) – The errors paramater passed to bytes.decode().   Return type 
Optional[str]
class werkzeug.middleware.profiler.ProfilerMiddleware(app, stream=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='UTF-8'>, sort_by=('time', 'calls'), restrictions=(), profile_dir=None, filename_format='{method}.{path}.{elapsed:.0f}ms.{time:.0f}.prof')  
Wrap a WSGI application and profile the execution of each request. Responses are buffered so that timings are more exact. If stream is given, pstats.Stats are written to it after each request. If profile_dir is given, cProfile data files are saved to that directory, one file per request. The filename can be customized by passing filename_format. If it is a string, it will be formatted using str.format() with the following fields available:  
{method} - The request method; GET, POST, etc. 
{path} - The request path or ‘root’ should one not exist. 
{elapsed} - The elapsed time of the request. 
{time} - The time of the request.  If it is a callable, it will be called with the WSGI environ dict and should return a filename.  Parameters 
 
app (WSGIApplication) – The WSGI application to wrap. 
stream (TextIO) – Write stats to this stream. Disable with None. 
sort_by (Iterable[str]) – A tuple of columns to sort stats by. See pstats.Stats.sort_stats(). 
restrictions (Iterable[Union[str, int, float]]) – A tuple of restrictions to filter stats by. See pstats.Stats.print_stats(). 
profile_dir (Optional[str]) – Save profile data files to this directory. 
filename_format (str) – Format string for profile data file names, or a callable returning a name. See explanation above.   Return type 
None   from werkzeug.middleware.profiler import ProfilerMiddleware
app = ProfilerMiddleware(app)
  Changelog Changed in version 0.15: Stats are written even if profile_dir is given, and can be disable by passing stream=None.   New in version 0.15: Added filename_format.   New in version 0.9: Added restrictions and profile_dir.
class werkzeug.middleware.proxy_fix.ProxyFix(app, x_for=1, x_proto=1, x_host=0, x_port=0, x_prefix=0)  
Adjust the WSGI environ based on X-Forwarded- that proxies in front of the application may set.  
X-Forwarded-For sets REMOTE_ADDR. 
X-Forwarded-Proto sets wsgi.url_scheme. 
X-Forwarded-Host sets HTTP_HOST, SERVER_NAME, and SERVER_PORT. 
X-Forwarded-Port sets HTTP_HOST and SERVER_PORT. 
X-Forwarded-Prefix sets SCRIPT_NAME.  You must tell the middleware how many proxies set each header so it knows what values to trust. It is a security issue to trust values that came from the client rather than a proxy. The original values of the headers are stored in the WSGI environ as werkzeug.proxy_fix.orig, a dict.  Parameters 
 
app (WSGIApplication) – The WSGI application to wrap. 
x_for (int) – Number of values to trust for X-Forwarded-For. 
x_proto (int) – Number of values to trust for X-Forwarded-Proto. 
x_host (int) – Number of values to trust for X-Forwarded-Host. 
x_port (int) – Number of values to trust for X-Forwarded-Port. 
x_prefix (int) – Number of values to trust for X-Forwarded-Prefix.   Return type 
None   from werkzeug.middleware.proxy_fix import ProxyFix
# App is behind one proxy that sets the -For and -Host headers.
app = ProxyFix(app, x_for=1, x_host=1)
  Changelog Changed in version 1.0: Deprecated code has been removed:  The num_proxies argument and attribute. The get_remote_addr method. The environ keys orig_remote_addr, orig_wsgi_url_scheme, and orig_http_host.    Changed in version 0.15: All headers support multiple values. The num_proxies argument is deprecated. Each header is configured with a separate number of trusted proxies.   Changed in version 0.15: Original WSGI environ values are stored in the werkzeug.proxy_fix.orig dict. orig_remote_addr, orig_wsgi_url_scheme, and orig_http_host are deprecated and will be removed in 1.0.   Changed in version 0.15: Support X-Forwarded-Port and X-Forwarded-Prefix.   Changed in version 0.15: X-Forwarded-Host and X-Forwarded-Port modify SERVER_NAME and SERVER_PORT.
class werkzeug.middleware.http_proxy.ProxyMiddleware(app, targets, chunk_size=16384, timeout=10)  
Proxy requests under a path to an external server, routing other requests to the app. This middleware can only proxy HTTP requests, as HTTP is the only protocol handled by the WSGI server. Other protocols, such as WebSocket requests, cannot be proxied at this layer. This should only be used for development, in production a real proxy server should be used. The middleware takes a dict mapping a path prefix to a dict describing the host to be proxied to: app = ProxyMiddleware(app, {
    "/static/": {
        "target": "http://127.0.0.1:5001/",
    }
})
 Each host has the following options:  
target: 

The target URL to dispatch to. This is required.  
remove_prefix: 

Whether to remove the prefix from the URL before dispatching it to the target. The default is False.  
host: 

 
"<auto>" (default): 

The host header is automatically rewritten to the URL of the target.  
None: 

The host header is unmodified from the client request.  Any other value:

The host header is overwritten with the value.    
headers: 

A dictionary of headers to be sent with the request to the target. The default is {}.  
ssl_context: 

A ssl.SSLContext defining how to verify requests if the target is HTTPS. The default is None.   In the example above, everything under "/static/" is proxied to the server on port 5001. The host header is rewritten to the target, and the "/static/" prefix is removed from the URLs.  Parameters 
 
app (WSGIApplication) – The WSGI application to wrap. 
targets (Mapping[str, Dict[str, Any]]) – Proxy target configurations. See description above. 
chunk_size (int) – Size of chunks to read from input stream and write to target. 
timeout (int) – Seconds before an operation to a target fails.   Return type 
None    Changelog New in version 0.14.
Quickstart This part of the documentation shows how to use the most important parts of Werkzeug. It’s intended as a starting point for developers with basic understanding of PEP 3333 (WSGI) and RFC 2616 (HTTP).
werkzeug.http.quote_etag(etag, weak=False)  
Quote an etag.  Parameters 
 
etag (str) – the etag to quote. 
weak (bool) – set to True to tag it “weak”.   Return type 
str
werkzeug.http.quote_header_value(value, extra_chars='', allow_token=True)  
Quote a header value if necessary.  Changelog New in version 0.5.   Parameters 
 
value (Union[str, int]) – the value to quote. 
extra_chars (str) – a list of extra characters to skip quoting. 
allow_token (bool) – if this is enabled token values are returned unchanged.   Return type 
str
class werkzeug.datastructures.Range(units, ranges)  
Represents a Range header. All methods only support only bytes as the unit. Stores a list of ranges if given, but the methods only work if only one range is provided.  Raises 
ValueError – If the ranges provided are invalid.    Changelog Changed in version 0.15: The ranges passed in are validated.   New in version 0.7.   
make_content_range(length)  
Creates a ContentRange object from the current range and given content length. 
  
range_for_length(length)  
If the range is for bytes, the length is not None and there is exactly one range and it is satisfiable it returns a (start, stop) tuple, otherwise None. 
  
ranges  
A list of (begin, end) tuples for the range header provided. The ranges are non-inclusive. 
  
to_content_range_header(length)  
Converts the object into Content-Range HTTP header, based on given length 
  
to_header()  
Converts the object back into an HTTP header. 
  
units  
The units of this range. Usually “bytes”.
make_content_range(length)  
Creates a ContentRange object from the current range and given content length.
ranges  
A list of (begin, end) tuples for the range header provided. The ranges are non-inclusive.
range_for_length(length)  
If the range is for bytes, the length is not None and there is exactly one range and it is satisfiable it returns a (start, stop) tuple, otherwise None.
to_content_range_header(length)  
Converts the object into Content-Range HTTP header, based on given length