neulab/docprompting-conala huggingface dataset:
class werkzeug.local.LocalManager(locals=None, ident_func=None)  
Local objects cannot manage themselves. For that you need a local manager. You can pass a local manager multiple locals or add them later y appending them to manager.locals. Every time the manager cleans up, it will clean up all the data left in the locals for this context.  Changed in version 2.0: ident_func is deprecated and will be removed in Werkzeug 2.1.   Changelog Changed in version 0.7: The ident_func parameter was added.   Changed in version 0.6.1: The release_local() function can be used instead of a manager.   Parameters 
 
locals (Optional[Iterable[Union[werkzeug.local.Local, werkzeug.local.LocalStack]]]) –  
ident_func (None) –    Return type 
None    
cleanup()  
Manually clean up the data in the locals for this context. Call this at the end of the request or use make_middleware().  Return type 
None   
  
get_ident()  
Return the context identifier the local objects use internally for this context. You cannot override this method to change the behavior but use it to link other context local objects (such as SQLAlchemy’s scoped sessions) to the Werkzeug locals.  Deprecated since version 2.0: Will be removed in Werkzeug 2.1.   Changelog Changed in version 0.7: You can pass a different ident function to the local manager that will then be propagated to all the locals passed to the constructor.   Return type 
int   
  
make_middleware(app)  
Wrap a WSGI application so that cleaning up happens after request end.  Parameters 
app (WSGIApplication) –   Return type 
WSGIApplication   
  
middleware(func)  
Like make_middleware but for decorating functions. Example usage: @manager.middleware
def application(environ, start_response):
    ...
 The difference to make_middleware is that the function passed will have all the arguments copied from the inner application (name, docstring, module).  Parameters 
func (WSGIApplication) –   Return type 
WSGIApplication
cleanup()  
Manually clean up the data in the locals for this context. Call this at the end of the request or use make_middleware().  Return type 
None
get_ident()  
Return the context identifier the local objects use internally for this context. You cannot override this method to change the behavior but use it to link other context local objects (such as SQLAlchemy’s scoped sessions) to the Werkzeug locals.  Deprecated since version 2.0: Will be removed in Werkzeug 2.1.   Changelog Changed in version 0.7: You can pass a different ident function to the local manager that will then be propagated to all the locals passed to the constructor.   Return type 
int
make_middleware(app)  
Wrap a WSGI application so that cleaning up happens after request end.  Parameters 
app (WSGIApplication) –   Return type 
WSGIApplication
middleware(func)  
Like make_middleware but for decorating functions. Example usage: @manager.middleware
def application(environ, start_response):
    ...
 The difference to make_middleware is that the function passed will have all the arguments copied from the inner application (name, docstring, module).  Parameters 
func (WSGIApplication) –   Return type 
WSGIApplication
class werkzeug.local.LocalProxy(local, name=None)  
A proxy to the object bound to a Local. All operations on the proxy are forwarded to the bound object. If no object is bound, a RuntimeError is raised. from werkzeug.local import Local
l = Local()

# a proxy to whatever l.user is set to
user = l("user")

from werkzeug.local import LocalStack
_request_stack = LocalStack()

# a proxy to _request_stack.top
request = _request_stack()

# a proxy to the session attribute of the request proxy
session = LocalProxy(lambda: request.session)
 __repr__ and __class__ are forwarded, so repr(x) and isinstance(x, cls) will look like the proxied object. Use issubclass(type(x), LocalProxy) to check if an object is a proxy. repr(user)  # <User admin>
isinstance(user, User)  # True
issubclass(type(user), LocalProxy)  # True
  Parameters 
 
local – The Local or callable that provides the proxied object. 
name – The attribute name to look up on a Local. Not used if a callable is given.     Changed in version 2.0: Updated proxied attributes and methods to reflect the current data model.   Changelog Changed in version 0.6.1: The class can be instantiated with a callable.   
_get_current_object()  
Return the current object. This is useful if you want the real object behind the proxy at a time for performance reasons or because you want to pass the object into a different context.  Return type 
Any
_get_current_object()  
Return the current object. This is useful if you want the real object behind the proxy at a time for performance reasons or because you want to pass the object into a different context.  Return type 
Any
class werkzeug.local.LocalStack  
This class works similar to a Local but keeps a stack of objects instead. This is best explained with an example: >>> ls = LocalStack()
>>> ls.push(42)
>>> ls.top
42
>>> ls.push(23)
>>> ls.top
23
>>> ls.pop()
23
>>> ls.top
42
 They can be force released by using a LocalManager or with the release_local() function but the correct way is to pop the item from the stack after using. When the stack is empty it will no longer be bound to the current context (and as such released). By calling the stack without arguments it returns a proxy that resolves to the topmost item on the stack.  Changelog New in version 0.6.1.   Return type 
None    
pop()  
Removes the topmost item from the stack, will return the old value or None if the stack was already empty.  Return type 
Any   
  
push(obj)  
Pushes a new item to the stack  Parameters 
obj (Any) –   Return type 
List[Any]   
  
property top: Any  
The topmost item on the stack. If the stack is empty, None is returned.
pop()  
Removes the topmost item from the stack, will return the old value or None if the stack was already empty.  Return type 
Any
push(obj)  
Pushes a new item to the stack  Parameters 
obj (Any) –   Return type 
List[Any]
werkzeug.wsgi.make_chunk_iter(stream, separator, limit=None, buffer_size=10240, cap_at_buffer=False)  
Works like make_line_iter() but accepts a separator which divides chunks. If you want newline based processing you should use make_line_iter() instead as it supports arbitrary newline markers.  Changelog New in version 0.11.10: added support for the cap_at_buffer parameter.   New in version 0.9: added support for iterators as input stream.   New in version 0.8.   Parameters 
 
stream (Union[Iterable[bytes], BinaryIO]) – the stream or iterate to iterate over. 
separator (bytes) – the separator that divides chunks. 
limit (Optional[int]) – the limit in bytes for the stream. (Usually content length. Not necessary if the stream is otherwise already limited). 
buffer_size (int) – The optional buffer size. 
cap_at_buffer (bool) – if this is set chunks are split if they are longer than the buffer size. Internally this is implemented that the buffer size might be exhausted by a factor of two however.   Return type 
Iterator[bytes]
werkzeug.wsgi.make_line_iter(stream, limit=None, buffer_size=10240, cap_at_buffer=False)  
Safely iterates line-based over an input stream. If the input stream is not a LimitedStream the limit parameter is mandatory. This uses the stream’s read() method internally as opposite to the readline() method that is unsafe and can only be used in violation of the WSGI specification. The same problem applies to the __iter__ function of the input stream which calls readline() without arguments. If you need line-by-line processing it’s strongly recommended to iterate over the input stream using this helper function.  Changelog New in version 0.11.10: added support for the cap_at_buffer parameter.   New in version 0.9: added support for iterators as input stream.   Changed in version 0.8: This function now ensures that the limit was reached.   Parameters 
 
stream (Union[Iterable[bytes], BinaryIO]) – the stream or iterate to iterate over. 
limit (Optional[int]) – the limit in bytes for the stream. (Usually content length. Not necessary if the stream is a LimitedStream. 
buffer_size (int) – The optional buffer size. 
cap_at_buffer (bool) – if this is set chunks are split if they are longer than the buffer size. Internally this is implemented that the buffer size might be exhausted by a factor of two however.   Return type 
Iterator[bytes]
werkzeug.serving.make_ssl_devcert(base_path, host=None, cn=None)  
Creates an SSL key for development. This should be used instead of the 'adhoc' key which generates a new cert on each server start. It accepts a path for where it should store the key and cert and either a host or CN. If a host is given it will use the CN *.host/CN=host. For more information see run_simple().  Changelog New in version 0.9.   Parameters 
 
base_path (str) – the path to the certificate and key. The extension .crt is added for the certificate, .key is added for the key. 
host (Optional[str]) – the name of the host. This can be used as an alternative for the cn. 
cn (Optional[str]) – the CN to use.   Return type 
Tuple[str, str]
add(rulefactory)  
Add a new rule or factory to the map and bind it. Requires that the rule is not bound to another map.  Parameters 
rulefactory (werkzeug.routing.RuleFactory) – a Rule or RuleFactory  Return type 
None
bind(server_name, script_name=None, subdomain=None, url_scheme='http', default_method='GET', path_info=None, query_args=None)  
Return a new MapAdapter with the details specified to the call. Note that script_name will default to '/' if not further specified or None. The server_name at least is a requirement because the HTTP RFC requires absolute URLs for redirects and so all redirect exceptions raised by Werkzeug will contain the full canonical URL. If no path_info is passed to match() it will use the default path info passed to bind. While this doesn’t really make sense for manual bind calls, it’s useful if you bind a map to a WSGI environment which already contains the path info. subdomain will default to the default_subdomain for this map if no defined. If there is no default_subdomain you cannot use the subdomain feature.  Changelog Changed in version 1.0: If url_scheme is ws or wss, only WebSocket rules will match.   Changed in version 0.15: path_info defaults to '/' if None.   Changed in version 0.8: query_args can be a string.   Changed in version 0.7: Added query_args.   Parameters 
 
server_name (str) –  
script_name (Optional[str]) –  
subdomain (Optional[str]) –  
url_scheme (str) –  
default_method (str) –  
path_info (Optional[str]) –  
query_args (Optional[Union[Mapping[str, Any], str]]) –    Return type 
werkzeug.routing.MapAdapter
bind_to_environ(environ, server_name=None, subdomain=None)  
Like bind() but you can pass it an WSGI environment and it will fetch the information from that dictionary. Note that because of limitations in the protocol there is no way to get the current subdomain and real server_name from the environment. If you don’t provide it, Werkzeug will use SERVER_NAME and SERVER_PORT (or HTTP_HOST if provided) as used server_name with disabled subdomain feature. If subdomain is None but an environment and a server name is provided it will calculate the current subdomain automatically. Example: server_name is 'example.com' and the SERVER_NAME in the wsgi environ is 'staging.dev.example.com' the calculated subdomain will be 'staging.dev'. If the object passed as environ has an environ attribute, the value of this attribute is used instead. This allows you to pass request objects. Additionally PATH_INFO added as a default of the MapAdapter so that you don’t have to pass the path info to the match method.  Changelog Changed in version 1.0.0: If the passed server name specifies port 443, it will match if the incoming scheme is https without a port.   Changed in version 1.0.0: A warning is shown when the passed server name does not match the incoming WSGI server name.   Changed in version 0.8: This will no longer raise a ValueError when an unexpected server name was passed.   Changed in version 0.5: previously this method accepted a bogus calculate_subdomain parameter that did not have any effect. It was removed because of that.   Parameters 
 
environ (WSGIEnvironment) – a WSGI environment. 
server_name (Optional[str]) – an optional server name hint (see above). 
subdomain (Optional[str]) – optionally the current subdomain (see above).   Return type 
MapAdapter
converters  
The dictionary of converters. This can be modified after the class was created, but will only affect rules added after the modification. If the rules are defined with the list passed to the class, the converters parameter to the constructor has to be used instead.
default_converters = {'any': <class 'werkzeug.routing.AnyConverter'>, 'default': <class 'werkzeug.routing.UnicodeConverter'>, 'float': <class 'werkzeug.routing.FloatConverter'>, 'int': <class 'werkzeug.routing.IntegerConverter'>, 'path': <class 'werkzeug.routing.PathConverter'>, 'string': <class 'werkzeug.routing.UnicodeConverter'>, 'uuid': <class 'werkzeug.routing.UUIDConverter'>}  
A dict of default converters to be used.
is_endpoint_expecting(endpoint, *arguments)  
Iterate over all rules and check if the endpoint expects the arguments provided. This is for example useful if you have some URLs that expect a language code and others that do not and you want to wrap the builder a bit so that the current language code is automatically added if not provided but endpoints expect it.  Parameters 
 
endpoint (str) – the endpoint to check. 
arguments (str) – this function accepts one or more arguments as positional arguments. Each one of them is checked.   Return type 
bool
iter_rules(endpoint=None)  
Iterate over all rules or the rules of an endpoint.  Parameters 
endpoint (Optional[str]) – if provided only the rules for that endpoint are returned.  Returns 
an iterator  Return type 
Iterator[werkzeug.routing.Rule]
lock_class()  
The type of lock to use when updating.  Changelog New in version 1.0.
update()  
Called before matching and building to keep the compiled rules in the correct order after things changed.  Return type 
None
allowed_methods(path_info=None)  
Returns the valid methods that match for a given path.  Changelog New in version 0.7.   Parameters 
path_info (Optional[str]) –   Return type 
Iterable[str]
build(endpoint, values=None, method=None, force_external=False, append_unknown=True, url_scheme=None)  
Building URLs works pretty much the other way round. Instead of match you call build and pass it the endpoint and a dict of arguments for the placeholders. The build function also accepts an argument called force_external which, if you set it to True will force external URLs. Per default external URLs (include the server name) will only be used if the target URL is on a different subdomain. >>> m = Map([
...     Rule('/', endpoint='index'),
...     Rule('/downloads/', endpoint='downloads/index'),
...     Rule('/downloads/<int:id>', endpoint='downloads/show')
... ])
>>> urls = m.bind("example.com", "/")
>>> urls.build("index", {})
'/'
>>> urls.build("downloads/show", {'id': 42})
'/downloads/42'
>>> urls.build("downloads/show", {'id': 42}, force_external=True)
'http://example.com/downloads/42'
 Because URLs cannot contain non ASCII data you will always get bytes back. Non ASCII characters are urlencoded with the charset defined on the map instance. Additional values are converted to strings and appended to the URL as URL querystring parameters: >>> urls.build("index", {'q': 'My Searchstring'})
'/?q=My+Searchstring'
 When processing those additional values, lists are furthermore interpreted as multiple values (as per werkzeug.datastructures.MultiDict): >>> urls.build("index", {'q': ['a', 'b', 'c']})
'/?q=a&q=b&q=c'
 Passing a MultiDict will also add multiple values: >>> urls.build("index", MultiDict((('p', 'z'), ('q', 'a'), ('q', 'b'))))
'/?p=z&q=a&q=b'
 If a rule does not exist when building a BuildError exception is raised. The build method accepts an argument called method which allows you to specify the method you want to have an URL built for if you have different methods for the same endpoint specified.  Parameters 
 
endpoint (str) – the endpoint of the URL to build. 
values (Optional[Mapping[str, Any]]) – the values for the URL to build. Unhandled values are appended to the URL as query parameters. 
method (Optional[str]) – the HTTP method for the rule if there are different URLs for different methods on the same endpoint. 
force_external (bool) – enforce full canonical external URLs. If the URL scheme is not provided, this will generate a protocol-relative URL. 
append_unknown (bool) – unknown parameters are appended to the generated URL as query string argument. Disable this if you want the builder to ignore those. 
url_scheme (Optional[str]) – Scheme to use in place of the bound url_scheme.   Return type 
str    Changed in version 2.0: Added the url_scheme parameter.   Changelog New in version 0.6: Added the append_unknown parameter.
dispatch(view_func, path_info=None, method=None, catch_http_exceptions=False)  
Does the complete dispatching process. view_func is called with the endpoint and a dict with the values for the view. It should look up the view function, call it, and return a response object or WSGI application. http exceptions are not caught by default so that applications can display nicer error messages by just catching them by hand. If you want to stick with the default error messages you can pass it catch_http_exceptions=True and it will catch the http exceptions. Here a small example for the dispatch usage: from werkzeug.wrappers import Request, Response
from werkzeug.wsgi import responder
from werkzeug.routing import Map, Rule

def on_index(request):
    return Response('Hello from the index')

url_map = Map([Rule('/', endpoint='index')])
views = {'index': on_index}

@responder
def application(environ, start_response):
    request = Request(environ)
    urls = url_map.bind_to_environ(environ)
    return urls.dispatch(lambda e, v: views[e](request, **v),
                         catch_http_exceptions=True)
 Keep in mind that this method might return exception objects, too, so use Response.force_type to get a response object.  Parameters 
 
view_func (Callable[[str, Mapping[str, Any]], WSGIApplication]) – a function that is called with the endpoint as first argument and the value dict as second. Has to dispatch to the actual view function with this information. (see above) 
path_info (Optional[str]) – the path info to use for matching. Overrides the path info specified on binding. 
method (Optional[str]) – the HTTP method used for matching. Overrides the method specified on binding. 
catch_http_exceptions (bool) – set to True to catch any of the werkzeug HTTPExceptions.   Return type 
WSGIApplication
get_host(domain_part)  
Figures out the full host name for the given domain part. The domain part is a subdomain in case host matching is disabled or a full host name.  Parameters 
domain_part (Optional[str]) –   Return type 
str
make_alias_redirect_url(path, endpoint, values, method, query_args)  
Internally called to make an alias redirect URL.  Parameters 
 
path (str) –  
endpoint (str) –  
values (Mapping[str, Any]) –  
method (str) –  
query_args (Union[Mapping[str, Any], str]) –    Return type 
str
test(path_info=None, method=None)  
Test if a rule would match. Works like match but returns True if the URL matches, or False if it does not exist.  Parameters 
 
path_info (Optional[str]) – the path info to use for matching. Overrides the path info specified on binding. 
method (Optional[str]) – the HTTP method used for matching. Overrides the method specified on binding.   Return type 
bool
Middleware A WSGI middleware is a WSGI application that wraps another application in order to observe or change its behavior. Werkzeug provides some middleware for common use cases.  X-Forwarded-For Proxy Fix Serve Shared Static Files Application Dispatcher Basic HTTP Proxy WSGI Protocol Linter Application Profiler  The interactive debugger is also a middleware that can be applied manually, although it is typically used automatically with the development server.
class werkzeug.datastructures.MIMEAccept(values=())  
Like Accept but with special methods and behavior for mimetypes.  
property accept_html  
True if this object accepts HTML. 
  
property accept_json  
True if this object accepts JSON. 
  
property accept_xhtml  
True if this object accepts XHTML.
add(key, value)  
Adds a new value for the key.  Changelog New in version 0.6.   Parameters 
 
key – the key for the value. 
value – the value to add.
fromkeys(value=None, /)  
Create a new dictionary with keys from iterable and values set to value.
get(key, default=None, type=None)  
Return the default value if the requested data doesn’t exist. If type is provided and is a callable it should convert the value, return it or raise a ValueError if that is not possible. In this case the function will return the default as if the value was not found: >>> d = TypeConversionDict(foo='42', bar='blub')
>>> d.get('foo', type=int)
42
>>> d.get('bar', -1, type=int)
-1
  Parameters 
 
key – The key to be looked up. 
default – The default value to be returned if the key can’t be looked up. If not further specified None is returned. 
type – A callable that is used to cast the value in the MultiDict. If a ValueError is raised by this callable the default value is returned.
getlist(key, type=None)  
Return the list of items for a given key. If that key is not in the MultiDict, the return value will be an empty list. Just like get, getlist accepts a type parameter. All items will be converted with the callable defined there.  Parameters 
 
key – The key to be looked up. 
type – A callable that is used to cast the value in the MultiDict. If a ValueError is raised by this callable the value will be removed from the list.   Returns 
a list of all the values for the key.
items(multi=False)  
Return an iterator of (key, value) pairs.  Parameters 
multi – If set to True the iterator returned will have a pair for each value of each key. Otherwise it will only contain pairs for the first value of each key.
lists()  
Return a iterator of (key, values) pairs, where values is the list of all values associated with the key.
listvalues()  
Return an iterator of all values associated with a key. Zipping keys() and this is the same as calling lists(): >>> d = MultiDict({"foo": [1, 2, 3]})
>>> zip(d.keys(), d.listvalues()) == d.lists()
True
pop(key, default=no value)  
Pop the first item for a list on the dict. Afterwards the key is removed from the dict, so additional values are discarded: >>> d = MultiDict({"foo": [1, 2, 3]})
>>> d.pop("foo")
1
>>> "foo" in d
False
  Parameters 
 
key – the key to pop. 
default – if provided the value to return if the key was not in the dictionary.
poplist(key)  
Pop the list for a key from the dict. If the key is not in the dict an empty list is returned.  Changelog Changed in version 0.5: If the key does no longer exist a list is returned instead of raising an error.
setdefault(key, default=None)  
Returns the value for the key if it is in the dict, otherwise it returns default and sets that value for key.  Parameters 
 
key – The key to be looked up. 
default – The default value to be returned if the key is not in the dict. If not further specified it’s None.
setlist(key, new_list)  
Remove the old values for a key and add new ones. Note that the list you pass the values in will be shallow-copied before it is inserted in the dictionary. >>> d = MultiDict()
>>> d.setlist('foo', ['1', '2'])
>>> d['foo']
'1'
>>> d.getlist('foo')
['1', '2']
  Parameters 
 
key – The key for which the values are set. 
new_list – An iterable with the new values for the key. Old values are removed first.