index
int64
0
731k
package
stringlengths
2
98
name
stringlengths
1
76
docstring
stringlengths
0
281k
code
stringlengths
4
1.07M
signature
stringlengths
2
42.8k
5,591
meld3
sharedlineage
null
def sharedlineage(srcelement, tgtelement): srcparent = srcelement.parent tgtparent = tgtelement.parent srcparenttag = getattr(srcparent, 'tag', None) tgtparenttag = getattr(tgtparent, 'tag', None) if srcparenttag != tgtparenttag: return False elif tgtparenttag is None and srcparenttag is...
(srcelement, tgtelement)
5,593
gptfunction.GPTFunction
GPTFunction
A class representing a GPT callable function. GPT functions are defined using a JSON schema which GPT uses to make a call. GPT functions created using this wrapper must follow a strict definition. 1. Parameters should use type hinting, and can only be of the following types: 1. str 2. ...
class GPTFunction: """ A class representing a GPT callable function. GPT functions are defined using a JSON schema which GPT uses to make a call. GPT functions created using this wrapper must follow a strict definition. 1. Parameters should use type hinting, and can only be of the following types: ...
(func: Callable[..., Any]) -> None
5,594
gptfunction.GPTFunction
__call__
null
@no_type_check def __call__(self, *args, **kwargs) -> Optional[str]: result = self.func(*args, **kwargs) # GPT expects function calls to return a string. if isinstance(result, str): return result if getattr(result, "__str__"): return str(result) return ""
(self, *args, **kwargs) -> Optional[str]
5,595
gptfunction.GPTFunction
__init__
null
def __init__(self, func: Callable[..., Any]) -> None: self.func = func
(self, func: Callable[..., Any]) -> NoneType
5,596
gptfunction.GPTFunction
_create_function_params
Combines annotation data with param documentation into a unified data storing the GPT function's parameters in order. :param annotations: The type annotation of the function. :param docstring_params: The docstring of the parameters of the function. :return: An list of the unifi...
@staticmethod def _create_function_params( annotations: Dict[str, type], docstring_params: List[DocstringParam] ) -> List[_FunctionParam]: """ Combines annotation data with param documentation into a unified data storing the GPT function's parameters in order. :param annotations: The type annotation...
(annotations: Dict[str, type], docstring_params: List[docstring_parser.common.DocstringParam]) -> List[gptfunction.GPTFunction.GPTFunction._FunctionParam]
5,597
gptfunction.GPTFunction
_parse_param_type
Converts a `typing` hint into a param object used by the function calling schema. :param param_type: The type of the parameter. :return: The parameter part of the function calling schema. Example1 ```python def my_func(a: int, b: str) -> None: pass ...
@staticmethod def _parse_param_type( param_type: Union[type, object], ) -> Dict[str, Union[str, List[str]]]: """ Converts a `typing` hint into a param object used by the function calling schema. :param param_type: The type of the parameter. :return: The parameter part of the function calling schema....
(param_type: Union[type, object]) -> Dict[str, Union[str, List[str]]]
5,598
gptfunction.GPTFunction
_parse_params
Converts a function's params into a 'parameters' object used by the function calling schema. :param params: The function parameters to parse into the schema. :return: The parameters part of the function calling schema.
@staticmethod def _parse_params(params: List[_FunctionParam]) -> Dict[str, Any]: """ Converts a function's params into a 'parameters' object used by the function calling schema. :param params: The function parameters to parse into the schema. :return: The parameters part of the function calling schema. ...
(params: List[gptfunction.GPTFunction.GPTFunction._FunctionParam]) -> Dict[str, Any]
5,599
gptfunction.GPTFunction
description
Get the description of this function. :return: The function description
def description(self) -> str: """ Get the description of this function. :return: The function description """ return docstring_parser.parse(self.func.__doc__).short_description
(self) -> str
5,600
gptfunction.GPTFunction
name
Get the name of this function. :return: The function name.
def name(self) -> str: """ Get the name of this function. :return: The function name. """ return self.func.__name__
(self) -> str
5,601
gptfunction.GPTFunction
schema
Generates the schema required for passing a function to GPT.
def schema(self) -> object: """ Generates the schema required for passing a function to GPT. """ docstring = docstring_parser.parse(self.func.__doc__) return { "type": "function", "function": { "name": self.func.__name__, "description": docstring.short_descrip...
(self) -> object
5,602
gptfunction.GPTFunction
gptfunction
null
def gptfunction(func: Callable[..., Any]) -> GPTFunction: return GPTFunction(func)
(func: Callable[..., Any]) -> gptfunction.GPTFunction.GPTFunction
5,603
flask.blueprints
Blueprint
null
class Blueprint(SansioBlueprint): def __init__( self, name: str, import_name: str, static_folder: str | os.PathLike[str] | None = None, static_url_path: str | None = None, template_folder: str | os.PathLike[str] | None = None, url_prefix: str | None = None, ...
(name: 'str', import_name: 'str', static_folder: 'str | os.PathLike[str] | None' = None, static_url_path: 'str | None' = None, template_folder: 'str | os.PathLike[str] | None' = None, url_prefix: 'str | None' = None, subdomain: 'str | None' = None, url_defaults: 'dict[str, t.Any] | None' = None, root_path: 'str | None'...
5,604
flask.blueprints
__init__
null
def __init__( self, name: str, import_name: str, static_folder: str | os.PathLike[str] | None = None, static_url_path: str | None = None, template_folder: str | os.PathLike[str] | None = None, url_prefix: str | None = None, subdomain: str | None = None, url_defaults: dict[str, t.Any]...
(self, name: str, import_name: str, static_folder: Union[str, os.PathLike[str], NoneType] = None, static_url_path: Optional[str] = None, template_folder: Union[str, os.PathLike[str], NoneType] = None, url_prefix: Optional[str] = None, subdomain: Optional[str] = None, url_defaults: Optional[dict[str, Any]] = None, root_...
5,605
flask.sansio.scaffold
__repr__
null
def __repr__(self) -> str: return f"<{type(self).__name__} {self.name!r}>"
(self) -> str
5,606
flask.sansio.blueprints
_check_setup_finished
null
def _check_setup_finished(self, f_name: str) -> None: if self._got_registered_once: raise AssertionError( f"The setup method '{f_name}' can no longer be called on the blueprint" f" '{self.name}'. It has already been registered at least once, any" " changes will not be app...
(self, f_name: str) -> NoneType
5,607
flask.sansio.scaffold
_get_exc_class_and_code
Get the exception class being handled. For HTTP status codes or ``HTTPException`` subclasses, return both the exception and status code. :param exc_class_or_code: Any exception class, or an HTTP status code as an integer.
@staticmethod def _get_exc_class_and_code( exc_class_or_code: type[Exception] | int, ) -> tuple[type[Exception], int | None]: """Get the exception class being handled. For HTTP status codes or ``HTTPException`` subclasses, return both the exception and status code. :param exc_class_or_code: Any exce...
(exc_class_or_code: type[Exception] | int) -> tuple[type[Exception], int | None]
5,608
flask.sansio.blueprints
_merge_blueprint_funcs
null
def _merge_blueprint_funcs(self, app: App, name: str) -> None: def extend( bp_dict: dict[ft.AppOrBlueprintKey, list[t.Any]], parent_dict: dict[ft.AppOrBlueprintKey, list[t.Any]], ) -> None: for key, values in bp_dict.items(): key = name if key is None else f"{name}.{key}" ...
(self, app: 'App', name: 'str') -> 'None'
5,609
flask.sansio.scaffold
_method_route
null
def _method_route( self, method: str, rule: str, options: dict[str, t.Any], ) -> t.Callable[[T_route], T_route]: if "methods" in options: raise TypeError("Use the 'route' decorator to use the 'methods' argument.") return self.route(rule, methods=[method], **options)
(self, method: str, rule: str, options: dict[str, typing.Any]) -> Callable[[~T_route], ~T_route]
5,610
flask.sansio.blueprints
add_app_template_filter
Register a template filter, available in any template rendered by the application. Works like the :meth:`app_template_filter` decorator. Equivalent to :meth:`.Flask.add_template_filter`. :param name: the optional name of the filter, otherwise the function name will be used....
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: Callable[..., Any], name: str | None = None) -> NoneType
5,611
flask.sansio.blueprints
add_app_template_global
Register a template global, available in any template rendered by the application. Works like the :meth:`app_template_global` decorator. Equivalent to :meth:`.Flask.add_template_global`. .. versionadded:: 0.10 :param name: the optional name of the global, otherwise the ...
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: Callable[..., Any], name: str | None = None) -> NoneType
5,612
flask.sansio.blueprints
add_app_template_test
Register a template test, available in any template rendered by the application. Works like the :meth:`app_template_test` decorator. Equivalent to :meth:`.Flask.add_template_test`. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the fun...
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: Callable[..., bool], name: str | None = None) -> NoneType
5,613
flask.sansio.blueprints
add_url_rule
Register a URL rule with the blueprint. See :meth:`.Flask.add_url_rule` for full documentation. The URL rule is prefixed with the blueprint's URL prefix. The endpoint name, used with :func:`url_for`, is prefixed with the blueprint's name.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, rule: 'str', endpoint: 'str | None' = None, view_func: 'ft.RouteCallable | None' = None, provide_automatic_options: 'bool | None' = None, **options: 't.Any') -> 'None'
5,614
flask.sansio.blueprints
after_app_request
Like :meth:`after_request`, but after every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.after_request`.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: ~T_after_request) -> ~T_after_request
5,615
flask.sansio.scaffold
after_request
Register a function to run after each request to this object. The function is called with the response object, and must return a response object. This allows the functions to modify or replace the response before it is sent. If a function raises an exception, any remaining ``af...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, f: ~T_after_request) -> ~T_after_request
5,616
flask.sansio.blueprints
app_context_processor
Like :meth:`context_processor`, but for templates rendered by every view, not only by the blueprint. Equivalent to :meth:`.Flask.context_processor`.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: ~T_template_context_processor) -> ~T_template_context_processor
5,617
flask.sansio.blueprints
app_errorhandler
Like :meth:`errorhandler`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.errorhandler`.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, code: type[Exception] | int) -> Callable[[~T_error_handler], ~T_error_handler]
5,618
flask.sansio.blueprints
app_template_filter
Register a template filter, available in any template rendered by the application. Equivalent to :meth:`.Flask.template_filter`. :param name: the optional name of the filter, otherwise the function name will be used.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, name: str | None = None) -> Callable[[~T_template_filter], ~T_template_filter]
5,619
flask.sansio.blueprints
app_template_global
Register a template global, available in any template rendered by the application. Equivalent to :meth:`.Flask.template_global`. .. versionadded:: 0.10 :param name: the optional name of the global, otherwise the function name will be used.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, name: str | None = None) -> Callable[[~T_template_global], ~T_template_global]
5,620
flask.sansio.blueprints
app_template_test
Register a template test, available in any template rendered by the application. Equivalent to :meth:`.Flask.template_test`. .. versionadded:: 0.10 :param name: the optional name of the test, otherwise the function name will be used.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, name: str | None = None) -> Callable[[~T_template_test], ~T_template_test]
5,621
flask.sansio.blueprints
app_url_defaults
Like :meth:`url_defaults`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.url_defaults`.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: ~T_url_defaults) -> ~T_url_defaults
5,622
flask.sansio.blueprints
app_url_value_preprocessor
Like :meth:`url_value_preprocessor`, but for every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.url_value_preprocessor`.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: ~T_url_value_preprocessor) -> ~T_url_value_preprocessor
5,623
flask.sansio.blueprints
before_app_request
Like :meth:`before_request`, but before every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.before_request`.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: ~T_before_request) -> ~T_before_request
5,624
flask.sansio.scaffold
before_request
Register a function to run before each request. For example, this can be used to open a database connection, or to load the logged in user from the session. .. code-block:: python @app.before_request def load_user(): if "user_id" in session: ...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, f: ~T_before_request) -> ~T_before_request
5,625
flask.sansio.scaffold
context_processor
Registers a template context processor function. These functions run before rendering a template. The keys of the returned dict are added as variables available in the template. This is available on both app and blueprint objects. When used on an app, this is called for every rendered t...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, f: ~T_template_context_processor) -> ~T_template_context_processor
5,626
flask.sansio.scaffold
delete
Shortcut for :meth:`route` with ``methods=["DELETE"]``. .. versionadded:: 2.0
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, rule: str, **options: Any) -> Callable[[~T_route], ~T_route]
5,627
flask.sansio.scaffold
endpoint
Decorate a view function to register it for the given endpoint. Used if a rule is added without a ``view_func`` with :meth:`add_url_rule`. .. code-block:: python app.add_url_rule("/ex", endpoint="example") @app.endpoint("example") def example(): ...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, endpoint: str) -> Callable[[~F], ~F]
5,628
flask.sansio.scaffold
errorhandler
Register a function to handle errors by code or exception class. A decorator that is used to register a function given an error code. Example:: @app.errorhandler(404) def page_not_found(error): return 'This page does not exist', 404 You can also regist...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, code_or_exception: type[Exception] | int) -> Callable[[~T_error_handler], ~T_error_handler]
5,629
flask.sansio.scaffold
get
Shortcut for :meth:`route` with ``methods=["GET"]``. .. versionadded:: 2.0
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, rule: str, **options: Any) -> Callable[[~T_route], ~T_route]
5,630
flask.blueprints
get_send_file_max_age
Used by :func:`send_file` to determine the ``max_age`` cache value for a given file path if it wasn't passed. By default, this returns :data:`SEND_FILE_MAX_AGE_DEFAULT` from the configuration of :data:`~flask.current_app`. This defaults to ``None``, which tells the browser to use condit...
def get_send_file_max_age(self, filename: str | None) -> int | None: """Used by :func:`send_file` to determine the ``max_age`` cache value for a given file path if it wasn't passed. By default, this returns :data:`SEND_FILE_MAX_AGE_DEFAULT` from the configuration of :data:`~flask.current_app`. This defa...
(self, filename: str | None) -> int | None
5,631
flask.sansio.blueprints
make_setup_state
Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState` object that is later passed to the register callback functions. Subclasses can override this to return a subclass of the setup state.
def make_setup_state( self, app: App, options: dict[str, t.Any], first_registration: bool = False ) -> BlueprintSetupState: """Creates an instance of :meth:`~flask.blueprints.BlueprintSetupState` object that is later passed to the register callback functions. Subclasses can override this to return a sub...
(self, app: 'App', options: 'dict[str, t.Any]', first_registration: 'bool' = False) -> 'BlueprintSetupState'
5,632
flask.blueprints
open_resource
Open a resource file relative to :attr:`root_path` for reading. For example, if the file ``schema.sql`` is next to the file ``app.py`` where the ``Flask`` app is defined, it can be opened with: .. code-block:: python with app.open_resource("schema.sql") as f: ...
def open_resource(self, resource: str, mode: str = "rb") -> t.IO[t.AnyStr]: """Open a resource file relative to :attr:`root_path` for reading. For example, if the file ``schema.sql`` is next to the file ``app.py`` where the ``Flask`` app is defined, it can be opened with: .. code-block:: python ...
(self, resource: str, mode: str = 'rb') -> IO[~AnyStr]
5,633
flask.sansio.scaffold
patch
Shortcut for :meth:`route` with ``methods=["PATCH"]``. .. versionadded:: 2.0
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, rule: str, **options: Any) -> Callable[[~T_route], ~T_route]
5,634
flask.sansio.scaffold
post
Shortcut for :meth:`route` with ``methods=["POST"]``. .. versionadded:: 2.0
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, rule: str, **options: Any) -> Callable[[~T_route], ~T_route]
5,635
flask.sansio.scaffold
put
Shortcut for :meth:`route` with ``methods=["PUT"]``. .. versionadded:: 2.0
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, rule: str, **options: Any) -> Callable[[~T_route], ~T_route]
5,636
flask.sansio.blueprints
record
Registers a function that is called when the blueprint is registered on the application. This function is called with the state as argument as returned by the :meth:`make_setup_state` method.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, func: Callable[[flask.sansio.blueprints.BlueprintSetupState], NoneType]) -> NoneType
5,637
flask.sansio.blueprints
record_once
Works like :meth:`record` but wraps the function in another function that will ensure the function is only called once. If the blueprint is registered a second time on the application, the function passed is not called.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, func: Callable[[flask.sansio.blueprints.BlueprintSetupState], NoneType]) -> NoneType
5,638
flask.sansio.blueprints
register
Called by :meth:`Flask.register_blueprint` to register all views and callbacks registered on the blueprint with the application. Creates a :class:`.BlueprintSetupState` and calls each :meth:`record` callback with it. :param app: The application this blueprint is being registered ...
def register(self, app: App, options: dict[str, t.Any]) -> None: """Called by :meth:`Flask.register_blueprint` to register all views and callbacks registered on the blueprint with the application. Creates a :class:`.BlueprintSetupState` and calls each :meth:`record` callback with it. :param app: The...
(self, app: 'App', options: 'dict[str, t.Any]') -> 'None'
5,639
flask.sansio.blueprints
register_blueprint
Register a :class:`~flask.Blueprint` on this blueprint. Keyword arguments passed to this method will override the defaults set on the blueprint. .. versionchanged:: 2.0.1 The ``name`` option can be used to change the (pre-dotted) name the blueprint is registered with. Th...
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, blueprint: flask.sansio.blueprints.Blueprint, **options: Any) -> NoneType
5,640
flask.sansio.scaffold
register_error_handler
Alternative error attach function to the :meth:`errorhandler` decorator that is more straightforward to use for non decorator usage. .. versionadded:: 0.7
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, code_or_exception: 'type[Exception] | int', f: 'ft.ErrorHandlerCallable') -> 'None'
5,641
flask.sansio.scaffold
route
Decorate a view function to register it with the given URL rule and options. Calls :meth:`add_url_rule`, which has more details about the implementation. .. code-block:: python @app.route("/") def index(): return "Hello, World!" See :ref:`url-ro...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, rule: str, **options: Any) -> Callable[[~T_route], ~T_route]
5,642
flask.blueprints
send_static_file
The view function used to serve files from :attr:`static_folder`. A route is automatically registered for this view at :attr:`static_url_path` if :attr:`static_folder` is set. Note this is a duplicate of the same method in the Flask class. .. versionadded:: 0.5 ...
def send_static_file(self, filename: str) -> Response: """The view function used to serve files from :attr:`static_folder`. A route is automatically registered for this view at :attr:`static_url_path` if :attr:`static_folder` is set. Note this is a duplicate of the same method in the Flask class...
(self, filename: 'str') -> 'Response'
5,643
flask.sansio.blueprints
teardown_app_request
Like :meth:`teardown_request`, but after every request, not only those handled by the blueprint. Equivalent to :meth:`.Flask.teardown_request`.
def __init__( self, blueprint: Blueprint, app: App, options: t.Any, first_registration: bool, ) -> None: #: a reference to the current application self.app = app #: a reference to the blueprint that created this setup state. self.blueprint = blueprint #: a dictionary with all opt...
(self, f: ~T_teardown) -> ~T_teardown
5,644
flask.sansio.scaffold
teardown_request
Register a function to be called when the request context is popped. Typically this happens at the end of each request, but contexts may be pushed manually as well during testing. .. code-block:: python with app.test_request_context(): ... When the ``with``...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, f: ~T_teardown) -> ~T_teardown
5,645
flask.sansio.scaffold
url_defaults
Callback function for URL defaults for all view functions of the application. It's called with the endpoint and values and should update the values passed in place. This is available on both app and blueprint objects. When used on an app, this is called for every request. When used on ...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, f: ~T_url_defaults) -> ~T_url_defaults
5,646
flask.sansio.scaffold
url_value_preprocessor
Register a URL value preprocessor function for all view functions in the application. These functions will be called before the :meth:`before_request` functions. The function can modify the values captured from the matched url before they are passed to the view. For example, this can be...
def setupmethod(f: F) -> F: f_name = f.__name__ def wrapper_func(self: Scaffold, *args: t.Any, **kwargs: t.Any) -> t.Any: self._check_setup_finished(f_name) return f(self, *args, **kwargs) return t.cast(F, update_wrapper(wrapper_func, f))
(self, f: ~T_url_value_preprocessor) -> ~T_url_value_preprocessor
5,647
flask_bower
Bower
null
class Bower(object): def __init__(self, app=None): if app is not None: self.init_app(app) def init_app(self, app): app.config.setdefault('BOWER_COMPONENTS_ROOT', 'bower_components') app.config.setdefault('BOWER_KEEP_DEPRECATED', True) app.config.setdefault('BOWER_QUE...
(app=None)
5,648
flask_bower
__init__
null
def __init__(self, app=None): if app is not None: self.init_app(app)
(self, app=None)
5,649
flask_bower
init_app
null
def init_app(self, app): app.config.setdefault('BOWER_COMPONENTS_ROOT', 'bower_components') app.config.setdefault('BOWER_KEEP_DEPRECATED', True) app.config.setdefault('BOWER_QUERYSTRING_REVVING', True) app.config.setdefault('BOWER_REPLACE_URL_FOR', False) app.config.setdefault('BOWER_SUBDOMAIN', Non...
(self, app)
5,650
flask.helpers
abort
Raise an :exc:`~werkzeug.exceptions.HTTPException` for the given status code. If :data:`~flask.current_app` is available, it will call its :attr:`~flask.Flask.aborter` object, otherwise it will use :func:`werkzeug.exceptions.abort`. :param code: The status code for the exception, which must be ...
def abort(code: int | BaseResponse, *args: t.Any, **kwargs: t.Any) -> t.NoReturn: """Raise an :exc:`~werkzeug.exceptions.HTTPException` for the given status code. If :data:`~flask.current_app` is available, it will call its :attr:`~flask.Flask.aborter` object, otherwise it will use :func:`werkzeug....
(code: int | werkzeug.wrappers.response.Response, *args: Any, **kwargs: Any) -> NoReturn
5,651
flask_bower
bower_url_for
DEPRECATED This function provides backward compatibility - please migrate to the approach using "bower.static" :param component: bower component (package) :type component: str :param filename: filename in bower component - can contain directories (like dist/jquery.js) :type filename: str :...
def bower_url_for(component, filename, **values): """ DEPRECATED This function provides backward compatibility - please migrate to the approach using "bower.static" :param component: bower component (package) :type component: str :param filename: filename in bower component - can contain direct...
(component, filename, **values)
5,652
flask_bower
build_url
search bower asset and build url :param component: bower component (package) :type component: str :param filename: filename in bower component - can contain directories (like dist/jquery.js) :type filename: str :param values: additional url parameters :type values: dict[str, str] :retu...
def build_url(component, filename, **values): """ search bower asset and build url :param component: bower component (package) :type component: str :param filename: filename in bower component - can contain directories (like dist/jquery.js) :type filename: str :param values: additional url ...
(component, filename, **values)
5,653
flask_bower
handle_url_error
Intercept BuildErrors of url_for() using flasks build_error_handler API
def handle_url_error(error, endpoint, values): """ Intercept BuildErrors of url_for() using flasks build_error_handler API """ url = overlay_url_for(endpoint, **values) if url is None: exc_type, exc_value, tb = sys.exc_info() if exc_value is error: raise exc_type(exc_valu...
(error, endpoint, values)
5,656
flask_bower
overlay_url_for
Replace flasks url_for() function to allow usage without template changes If the requested endpoint is static or ending in .static, it tries to serve a bower asset, otherwise it will pass the arguments to flask.url_for() See http://flask.pocoo.org/docs/0.10/api/#flask.url_for
def overlay_url_for(endpoint, filename=None, **values): """ Replace flasks url_for() function to allow usage without template changes If the requested endpoint is static or ending in .static, it tries to serve a bower asset, otherwise it will pass the arguments to flask.url_for() See http://flask....
(endpoint, filename=None, **values)
5,657
flask_bower
replaced_url_for
This function acts as "replacement" for the default url_for() and intercepts if it is a request for bower assets If the file is not available in bower, the result is passed to flasks url_for(). This is useful - but not recommended - for "overlaying" the static directory (see README.rst).
def replaced_url_for(endpoint, filename=None, **values): """ This function acts as "replacement" for the default url_for() and intercepts if it is a request for bower assets If the file is not available in bower, the result is passed to flasks url_for(). This is useful - but not recommended - for "over...
(endpoint, filename=None, **values)
5,658
flask.helpers
send_file
Send the contents of a file to the client. The first argument can be a file path or a file-like object. Paths are preferred in most cases because Werkzeug can manage the file and get extra information from the path. Passing a file-like object requires that the file is opened in binary mode, and is most...
def send_file( path_or_file: os.PathLike[t.AnyStr] | str | t.BinaryIO, mimetype: str | None = None, as_attachment: bool = False, download_name: str | None = None, conditional: bool = True, etag: bool | str = True, last_modified: datetime | int | float | None = None, max_age: None | (int ...
(path_or_file: 'os.PathLike[t.AnyStr] | str | t.BinaryIO', mimetype: 'str | None' = None, as_attachment: 'bool' = False, download_name: 'str | None' = None, conditional: 'bool' = True, etag: 'bool | str' = True, last_modified: 'datetime | int | float | None' = None, max_age: 'None | (int | t.Callable[[str | None], int ...
5,659
flask_bower
serve
null
def serve(component, filename): validate_parameter(component) validate_parameter(filename) root = current_app.config['BOWER_COMPONENTS_ROOT'] return send_file(os.path.join(root, component, filename), conditional=True)
(component, filename)
5,661
flask.helpers
url_for
Generate a URL to the given endpoint with the given values. This requires an active request or application context, and calls :meth:`current_app.url_for() <flask.Flask.url_for>`. See that method for full documentation. :param endpoint: The endpoint name associated with the URL to generate. If ...
def url_for( endpoint: str, *, _anchor: str | None = None, _method: str | None = None, _scheme: str | None = None, _external: bool | None = None, **values: t.Any, ) -> str: """Generate a URL to the given endpoint with the given values. This requires an active request or application ...
(endpoint: str, *, _anchor: Optional[str] = None, _method: Optional[str] = None, _scheme: Optional[str] = None, _external: Optional[bool] = None, **values: Any) -> str
5,662
flask_bower
validate_parameter
null
def validate_parameter(param): if '..' in param or param.startswith('/'): abort(404)
(param)
5,663
builtins
CozoDbMulTx
null
from builtins import CozoDbMulTx
null
5,664
builtins
CozoDbPy
from builtins import CozoDbPy
(engine, path, options)
5,666
wordcloud.color_from_image
ImageColorGenerator
Color generator based on a color image. Generates colors based on an RGB image. A word will be colored using the mean color of the enclosing rectangle in the color image. After construction, the object acts as a callable that can be passed as color_func to the word cloud constructor or to the recolor ...
class ImageColorGenerator(object): """Color generator based on a color image. Generates colors based on an RGB image. A word will be colored using the mean color of the enclosing rectangle in the color image. After construction, the object acts as a callable that can be passed as color_func to the...
(image, default_color=None)
5,667
wordcloud.color_from_image
__call__
Generate a color for a given word using a fixed image.
def __call__(self, word, font_size, font_path, position, orientation, **kwargs): """Generate a color for a given word using a fixed image.""" # get the font to get the box size font = ImageFont.truetype(font_path, font_size) transposed_font = ImageFont.TransposedFont(font, ...
(self, word, font_size, font_path, position, orientation, **kwargs)
5,668
wordcloud.color_from_image
__init__
null
def __init__(self, image, default_color=None): if image.ndim not in [2, 3]: raise ValueError("ImageColorGenerator needs an image with ndim 2 or" " 3, got %d" % image.ndim) if image.ndim == 3 and image.shape[2] not in [3, 4]: raise ValueError("A color image needs to have ...
(self, image, default_color=None)
5,669
wordcloud.wordcloud
WordCloud
Word cloud object for generating and drawing. Parameters ---------- font_path : string Font path to the font that will be used (OTF or TTF). Defaults to DroidSansMono path on a Linux machine. If you are on another OS or don't have this font, you need to adjust this path. width ...
class WordCloud(object): r"""Word cloud object for generating and drawing. Parameters ---------- font_path : string Font path to the font that will be used (OTF or TTF). Defaults to DroidSansMono path on a Linux machine. If you are on another OS or don't have this font, you need...
(font_path=None, width=400, height=200, margin=2, ranks_only=None, prefer_horizontal=0.9, mask=None, scale=1, color_func=None, max_words=200, min_font_size=4, stopwords=None, random_state=None, background_color='black', max_font_size=None, font_step=1, mode='RGB', relative_scaling='auto', regexp=None, collocations=True...
5,670
wordcloud.wordcloud
__array__
Convert to numpy array. Returns ------- image : nd-array size (width, height, 3) Word cloud image as numpy matrix.
def __array__(self): """Convert to numpy array. Returns ------- image : nd-array size (width, height, 3) Word cloud image as numpy matrix. """ return self.to_array()
(self)
5,671
wordcloud.wordcloud
__init__
null
def __init__(self, font_path=None, width=400, height=200, margin=2, ranks_only=None, prefer_horizontal=.9, mask=None, scale=1, color_func=None, max_words=200, min_font_size=4, stopwords=None, random_state=None, background_color='black', max_font_size=None, font_step=1...
(self, font_path=None, width=400, height=200, margin=2, ranks_only=None, prefer_horizontal=0.9, mask=None, scale=1, color_func=None, max_words=200, min_font_size=4, stopwords=None, random_state=None, background_color='black', max_font_size=None, font_step=1, mode='RGB', relative_scaling='auto', regexp=None, collocation...
5,672
wordcloud.wordcloud
_check_generated
Check if ``layout_`` was computed, otherwise raise error.
def _check_generated(self): """Check if ``layout_`` was computed, otherwise raise error.""" if not hasattr(self, "layout_"): raise ValueError("WordCloud has not been calculated, call generate" " first.")
(self)
5,673
wordcloud.wordcloud
_draw_contour
Draw mask contour on a pillow image.
def _draw_contour(self, img): """Draw mask contour on a pillow image.""" if self.mask is None or self.contour_width == 0: return img mask = self._get_bolean_mask(self.mask) * 255 contour = Image.fromarray(mask.astype(np.uint8)) contour = contour.resize(img.size) contour = contour.filter(...
(self, img)
5,674
wordcloud.wordcloud
_get_bolean_mask
Cast to two dimensional boolean mask.
def _get_bolean_mask(self, mask): """Cast to two dimensional boolean mask.""" if mask.dtype.kind == 'f': warnings.warn("mask image should be unsigned byte between 0" " and 255. Got a float array") if mask.ndim == 2: boolean_mask = mask == 255 elif mask.ndim == 3: ...
(self, mask)
5,675
wordcloud.wordcloud
fit_words
Create a word_cloud from words and frequencies. Alias to generate_from_frequencies. Parameters ---------- frequencies : dict from string to float A contains words and associated frequency. Returns ------- self
def fit_words(self, frequencies): """Create a word_cloud from words and frequencies. Alias to generate_from_frequencies. Parameters ---------- frequencies : dict from string to float A contains words and associated frequency. Returns ------- self """ return self.generate_...
(self, frequencies)
5,676
wordcloud.wordcloud
generate
Generate wordcloud from text. The input "text" is expected to be a natural text. If you pass a sorted list of words, words will appear in your output twice. To remove this duplication, set ``collocations=False``. Alias to generate_from_text. Calls process_text and generate_fro...
def generate(self, text): """Generate wordcloud from text. The input "text" is expected to be a natural text. If you pass a sorted list of words, words will appear in your output twice. To remove this duplication, set ``collocations=False``. Alias to generate_from_text. Calls process_text and ge...
(self, text)
5,677
wordcloud.wordcloud
generate_from_frequencies
Create a word_cloud from words and frequencies. Parameters ---------- frequencies : dict from string to float A contains words and associated frequency. max_font_size : int Use this font-size instead of self.max_font_size Returns ------- ...
def generate_from_frequencies(self, frequencies, max_font_size=None): # noqa: C901 """Create a word_cloud from words and frequencies. Parameters ---------- frequencies : dict from string to float A contains words and associated frequency. max_font_size : int Use this font-size inste...
(self, frequencies, max_font_size=None)
5,678
wordcloud.wordcloud
generate_from_text
Generate wordcloud from text. The input "text" is expected to be a natural text. If you pass a sorted list of words, words will appear in your output twice. To remove this duplication, set ``collocations=False``. Calls process_text and generate_from_frequencies. ..versionchang...
def generate_from_text(self, text): """Generate wordcloud from text. The input "text" is expected to be a natural text. If you pass a sorted list of words, words will appear in your output twice. To remove this duplication, set ``collocations=False``. Calls process_text and generate_from_frequencies...
(self, text)
5,679
wordcloud.wordcloud
process_text
Splits a long text into words, eliminates the stopwords. Parameters ---------- text : string The text to be processed. Returns ------- words : dict (string, int) Word tokens with associated frequency. ..versionchanged:: 1.2.2 ...
def process_text(self, text): """Splits a long text into words, eliminates the stopwords. Parameters ---------- text : string The text to be processed. Returns ------- words : dict (string, int) Word tokens with associated frequency. ..versionchanged:: 1.2.2 Chang...
(self, text)
5,680
wordcloud.wordcloud
recolor
Recolor existing layout. Applying a new coloring is much faster than generating the whole wordcloud. Parameters ---------- random_state : RandomState, int, or None, default=None If not None, a fixed random state is used. If an int is given, this is used ...
def recolor(self, random_state=None, color_func=None, colormap=None): """Recolor existing layout. Applying a new coloring is much faster than generating the whole wordcloud. Parameters ---------- random_state : RandomState, int, or None, default=None If not None, a fixed random state is ...
(self, random_state=None, color_func=None, colormap=None)
5,681
wordcloud.wordcloud
to_array
Convert to numpy array. Returns ------- image : nd-array size (width, height, 3) Word cloud image as numpy matrix.
def to_array(self): """Convert to numpy array. Returns ------- image : nd-array size (width, height, 3) Word cloud image as numpy matrix. """ return np.array(self.to_image())
(self)
5,682
wordcloud.wordcloud
to_file
Export to image file. Parameters ---------- filename : string Location to write to. Returns ------- self
def to_file(self, filename): """Export to image file. Parameters ---------- filename : string Location to write to. Returns ------- self """ img = self.to_image() img.save(filename, optimize=True) return self
(self, filename)
5,683
wordcloud.wordcloud
to_image
null
def to_image(self): self._check_generated() if self.mask is not None: width = self.mask.shape[1] height = self.mask.shape[0] else: height, width = self.height, self.width img = Image.new(self.mode, (int(width * self.scale), int(height * self.scale)...
(self)
5,684
wordcloud.wordcloud
to_svg
Export to SVG. Font is assumed to be available to the SVG reader. Otherwise, text coordinates may produce artifacts when rendered with replacement font. It is also possible to include a subset of the original font in WOFF format using ``embed_font`` (requires `fontTools`). Note...
def to_svg(self, embed_font=False, optimize_embedded_font=True, embed_image=False): """Export to SVG. Font is assumed to be available to the SVG reader. Otherwise, text coordinates may produce artifacts when rendered with replacement font. It is also possible to include a subset of the original font in ...
(self, embed_font=False, optimize_embedded_font=True, embed_image=False)
5,687
wordcloud.wordcloud
get_single_color_func
Create a color function which returns a single hue and saturation with. different values (HSV). Accepted values are color strings as usable by PIL/Pillow. >>> color_func1 = get_single_color_func('deepskyblue') >>> color_func2 = get_single_color_func('#00b4d2')
def get_single_color_func(color): """Create a color function which returns a single hue and saturation with. different values (HSV). Accepted values are color strings as usable by PIL/Pillow. >>> color_func1 = get_single_color_func('deepskyblue') >>> color_func2 = get_single_color_func('#00b4d2') ...
(color)
5,689
wordcloud.wordcloud
random_color_func
Random hue color generation. Default coloring method. This just picks a random hue with value 80% and lumination 50%. Parameters ---------- word, font_size, position, orientation : ignored. random_state : random.Random object or None, (default=None) If a random object is given, this ...
def random_color_func(word=None, font_size=None, position=None, orientation=None, font_path=None, random_state=None): """Random hue color generation. Default coloring method. This just picks a random hue with value 80% and lumination 50%. Parameters ---------- word, font_...
(word=None, font_size=None, position=None, orientation=None, font_path=None, random_state=None)
5,693
simple_di
Provider
the base class for Provider implementations. Could be used as the type annotations of all the implementations.
class Provider(Generic[VT]): """ the base class for Provider implementations. Could be used as the type annotations of all the implementations. """ STATE_FIELDS: Tuple[str, ...] = ("_override",) def __init__(self) -> None: self._override: Union[_SentinelClass, VT] = sentinel def _...
() -> None
5,694
simple_di
__getstate__
null
def __getstate__(self) -> Dict[str, Any]: return {f: getattr(self, f) for f in self.STATE_FIELDS}
(self) -> Dict[str, Any]
5,695
simple_di
__init__
null
def __init__(self) -> None: self._override: Union[_SentinelClass, VT] = sentinel
(self) -> NoneType
5,696
simple_di
__setstate__
null
def __setstate__(self, state: Dict[str, Any]) -> None: for i in self.STATE_FIELDS: setattr(self, i, state[i])
(self, state: Dict[str, Any]) -> NoneType
5,697
simple_di
_provide
null
def _provide(self) -> VT: raise NotImplementedError
(self) -> ~VT
5,698
simple_di
get
get the value of this provider
def get(self) -> VT: """ get the value of this provider """ if not isinstance(self._override, _SentinelClass): return self._override return self._provide()
(self) -> ~VT
5,699
simple_di
patch
patch the value of this provider, restoring the original value after the context
null
(self, value: Union[simple_di._SentinelClass, ~VT]) -> Generator[NoneType, NoneType, NoneType]
5,700
simple_di
reset
remove the overriding and restore the original value
def reset(self) -> None: """ remove the overriding and restore the original value """ self._override = sentinel
(self) -> NoneType
5,701
simple_di
set
set the value to this provider, overriding the original values
def set(self, value: Union[_SentinelClass, VT]) -> None: """ set the value to this provider, overriding the original values """ if isinstance(value, _SentinelClass): return self._override = value
(self, value: Union[simple_di._SentinelClass, ~VT]) -> NoneType