6V=jvddlmZddlZddlZddlZddlZddlZddl m Z ddl m Z ddl mZddl mZddlmZddlmZdd lmZd d lmZd d lmZd d lmZejrddlmZeZej dej!dej"fZ#ej dej$ej"Z%ej dej&Z'ej dej(Z)ej dej*Z+ej dej,Z-ej dej.Z/ej dej0Z1ej dej2Z3d'dZ4GddZ5d(d"Z6d)d$Z7d*d&Z8dS)+) annotationsN) defaultdict)update_wrapper) BaseLoader)FileSystemLoader)default_exceptions) HTTPException)cached_property)typing) get_root_path)_default_template_ctx_processor)GroupF.)boundT_after_requestT_before_requestT_error_handler T_teardownT_template_context_processorT_url_defaultsT_url_value_preprocessorT_routefreturncrjdfd }tjtt |S) NselfScaffoldargst.AnykwargsrcF||g|Ri|SN)_check_setup_finished)rrr!rf_names CC:\PYTHON\_runtimes\venv\Lib\site-packages\flask/sansio/scaffold.py wrapper_funcz!setupmethod..wrapper_func-s7 ""6***q''''''')rrrr r!r rr )__name__tcastrr)rr'r%s` @r& setupmethodr,*sL ZF((((((( 6!^L!44 5 55r(ceZdZUdZded<ded<dZded<dZded < dJdKdZdLdZdMdZ e dNdZ e j dOdZ e dPdZ e dNdZej dQdZedRdZdSd$ZedTd&ZedTd'ZedTd(ZedTd)ZedTd*ZedTd+Ze dUdVd1ZedWd3ZedXd6ZedYd8ZedZd:Zed[d<Zed\d>Zed]d@Z ed^dDZ!ed_dFZ"e#d`dIZ$dS)araCommon behavior shared between :class:`~flask.Flask` and :class:`~flask.blueprints.Blueprint`. :param import_name: The import name of the module where this object is defined. Usually :attr:`__name__` should be used. :param static_folder: Path to a folder of static files to serve. If this is set, a static route will be added. :param static_url_path: URL prefix for the static route. :param template_folder: Path to a folder containing template files. for rendering. If this is set, a Jinja loader will be added. :param root_path: The path that static, template, and resource files are relative to. Typically not set, it is discovered based on the ``import_name``. .. versionadded:: 2.0 rclistrnameN str | None_static_folder_static_url_path import_name static_folderstr | os.PathLike[str] | Nonestatic_url_pathtemplate_folder root_pathc||_||_||_||_|t |j}||_i|_td|_tt|_ tt|_ tt|_ ttdtgi|_tt|_tt|_dS)Nc*ttSr#)rdictr(r&z#Scaffold.__init__..~s D 1 1r()r4r5r7r8r r9view_functionsrerror_handler_speclistbefore_request_funcsafter_request_funcsteardown_request_funcsrtemplate_context_processorsurl_value_preprocessorsurl_default_functions)rr4r5r7r8r9s r&__init__zScaffold.__init__Ks'*. /  %d&677I#<>$ 11 2 2 "    !     "    #" t&E%FG H H ($    $$    """r(rcBdt|jd|jdS)N< >)typer)r0rs r&__repr__zScaffold.__repr__s&74::&777777r(r%Nonectr#NotImplementedError)rr%s r&r$zScaffold._check_setup_finisheds!!r(ch|j*tj|j|jSdS)zhThe absolute path to the configured static folder. ``None`` if no static folder is set. N)r2ospathjoinr9rNs r&r5zScaffold.static_folders-   *7<<0CDD D4r(valuecf|'tj|d}||_dS)Nz\/)rUfspathrstripr2rrXs r&r5zScaffold.static_folders3  Ie$$++E22E#r(boolc|jduS)zQ``True`` if :attr:`static_folder` is set. .. versionadded:: 0.5 N)r5rNs r&has_static_folderzScaffold.has_static_folders !--r(c|j|jS|j>((-- -tr(cB||d}||_dS)Nra)r[r3r\s r&r7zScaffold.static_url_paths'  LL%%E %r(BaseLoader | Nonec|j7ttj|j|jSdS)zThe Jinja loader for this object's templates. By default this is a class :class:`jinja2.loaders.FileSystemLoader` to :attr:`template_folder` if it is set. .. versionadded:: 0.5 N)r8rrUrVrWr9rNs r& jinja_loaderzScaffold.jinja_loaders5   +#BGLLAU$V$VWW W4r(methodruleoptionsdict[str, t.Any]t.Callable[[T_route], T_route]cJd|vrtd|j|fd|gi|S)Nmethodsz8Use the 'route' decorator to use the 'methods' argument.) TypeErrorroute)rrgrhris r& _method_routezScaffold._method_routes?   VWW Wtz$<<.decoratorhs:{{:t44H D dHa ; ;7 ; ; ;Hr()rrrrr=)rrhrirs``` r&rozScaffold.routeOs52         r(r view_funcft.RouteCallable | Noneprovide_automatic_options bool | Nonec t)a;Register a rule for routing incoming requests and building URLs. The :meth:`route` decorator is a shortcut to call this with the ``view_func`` argument. These are equivalent: .. code-block:: python @app.route("/") def index(): ... .. code-block:: python def index(): ... app.add_url_rule("/", view_func=index) See :ref:`url-route-registrations`. The endpoint name for the route defaults to the name of the view function if the ``endpoint`` parameter isn't passed. An error will be raised if a function has already been registered for the endpoint. The ``methods`` parameter defaults to ``["GET"]``. ``HEAD`` is always added automatically, and ``OPTIONS`` is added automatically by default. ``view_func`` does not necessarily need to be passed, but if the rule should participate in routing an endpoint name must be associated with a view function at some point with the :meth:`endpoint` decorator. .. code-block:: python app.add_url_rule("/", endpoint="index") @app.endpoint("index") def index(): ... If ``view_func`` has a ``required_methods`` attribute, those methods are added to the passed and automatic methods. If it has a ``provide_automatic_methods`` attribute, it is used as the default if the parameter is not passed. :param rule: The URL rule string. :param endpoint: The endpoint name to associate with the rule and view function. Used when routing and building URLs. Defaults to ``view_func.__name__``. :param view_func: The view function to associate with the endpoint name. :param provide_automatic_options: Add the ``OPTIONS`` method and respond to ``OPTIONS`` requests automatically. :param options: Extra options passed to the :class:`~werkzeug.routing.Rule` object. rR)rrhrrrris r&rzScaffold.add_url_ruleos D"!r(t.Callable[[F], F]cdfd }|S)aDecorate 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(): ... :param endpoint: The endpoint name to associate with the view function. rrrc|j<|Sr#)r?)rrrs r&rz$Scaffold.endpoint..decorators,-D  )Hr(rrrrr=)rrrs`` r&rzScaffold.endpoints/$       r(rrcb|jdg||S)aRegister 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: g.user = db.session.get(session["user_id"]) The function will be called without any arguments. If it returns a non-``None`` value, the value is handled as if it was the return value from the view, and further request handling is stopped. This is available on both app and blueprint objects. When used on an app, this executes before every request. When used on a blueprint, this executes before every request that the blueprint handles. To register with a blueprint and execute before every request, use :meth:`.Blueprint.before_app_request`. N)rB setdefaultappendrrs r&before_requestzScaffold.before_requests00 !,,T266==a@@@r(rcb|jdg||S)aWRegister 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 ``after_request`` functions will not be called. Therefore, this should not be used for actions that must execute, such as to close resources. Use :meth:`teardown_request` for that. This is available on both app and blueprint objects. When used on an app, this executes after every request. When used on a blueprint, this executes after every request that the blueprint handles. To register with a blueprint and execute after every request, use :meth:`.Blueprint.after_app_request`. N)rCrrrs r& after_requestzScaffold.after_requests0$  ++D"55< #..tR88??BBBr(rcF|jd||S)a#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 template. When used on a blueprint, this is called for templates rendered from the blueprint's views. To register with a blueprint and affect every template, use :meth:`.Blueprint.app_context_processor`. N)rErrs r&context_processorzScaffold.context_processors% (.55a888r(rcF|jd||S)alRegister 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 used to pop a common language code value and place it in ``g`` rather than pass it to every view. The function is passed the endpoint name and values dict. The return value is ignored. This is available on both app and blueprint objects. When used on an app, this is called for every request. When used on a blueprint, this is called for requests that the blueprint handles. To register with a blueprint and affect every request, use :meth:`.Blueprint.app_url_value_preprocessor`. N)rFrrs r&url_value_preprocessorzScaffold.url_value_preprocessor.s%, $T*11!444r(rcF|jd||S)aCallback 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 a blueprint, this is called for requests that the blueprint handles. To register with a blueprint and affect every request, use :meth:`.Blueprint.app_url_defaults`. N)rGrrs r& url_defaultszScaffold.url_defaultsGs% "4(//222r(code_or_exceptiontype[Exception] | int.t.Callable[[T_error_handler], T_error_handler]cdfd }|S)aRegister 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 register handlers for arbitrary exceptions:: @app.errorhandler(DatabaseError) def special_exception_handler(error): return 'Database connection failed', 500 This is available on both app and blueprint objects. When used on an app, this can handle errors from every request. When used on a blueprint, this can handle errors from requests that the blueprint handles. To register with a blueprint and affect every request, use :meth:`.Blueprint.app_errorhandler`. .. versionadded:: 0.7 Use :meth:`register_error_handler` instead of modifying :attr:`error_handler_spec` directly, for application wide error handlers. .. versionadded:: 0.7 One can now additionally also register custom exception types that do not necessarily have to be a subclass of the :class:`~werkzeug.exceptions.HTTPException` class. :param code_or_exception: the code as integer for the handler, or an arbitrary exception rrrc4||Sr#)register_error_handler)rrrs r&rz(Scaffold.errorhandler..decorator{s  ' '(91 = = =Hr()rrrrr=)rrrs`` r& errorhandlerzScaffold.errorhandlerUs0L       r(ft.ErrorHandlerCallablecb||\}}||jd||<dS)zAlternative error attach function to the :meth:`errorhandler` decorator that is more straightforward to use for non decorator usage. .. versionadded:: 0.7 N)_get_exc_class_and_coder@)rrr exc_classcodes r&rzScaffold.register_error_handlers9667HII 49:%d+I666r(exc_class_or_code"tuple[type[Exception], int | None]c~t|tr1 t|}n$#t$rt d|ddwxYw|}t|t rt |dt|t st d|jdt|tr ||j fS|dfS)a 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. 'z^' is not a recognized HTTP error code. Use a subclass of HTTPException with that code instead.Nzh is an instance, not a class. Handlers can only be registered for Exception classes or HTTP error codes.zl' is not a subclass of Exception. Handlers can only be registered for Exception classes or HTTP error codes.) isinstanceintrKeyError ValueError Exceptionrn issubclassr)r r)rrs r&rz Scaffold._get_exc_class_and_codes ' - - * ./@A     *)***  *I i + +      )Y// (I&(((  i / / #in, ,d? "s %A)NNNN) r4r/r5r6r7r1r8r6r9r1)rr/)r%r/rrP)rr1)rXr6rrP)rr])rXr1rrP)rrd)rgr/rhr/rirjrrk)rhr/rir rrk)NNN) rhr/rr1rrrrrir rrP)rr/rr)rrrr)rrrr)rrrr)rrrr)rrrr)rrrr)rrrr)rrrrrrP)rrrr)%r) __module__ __qualname____doc____annotations__r2r3rHrOr$propertyr5setterr_r7r rfrpr,ruryr|rrrorrrrrrrrrr staticmethodrr=r(r&rr4s"JJJ III!%N%%%%#''''' 8<&*9= $ LLLLL\8888""""X$$$$ ...X.   X &&&&    _  = = = =888[8999[9888[8;;;[;:::[:[> $-115 A"A"A"A"[A"F[.[4[([B[ [0   [ )))[)V ; ; ;[ ;)#)#)#\)#)#)#r(rrft.RouteCallabler/c(| Jd|jS)zsInternal helper that returns the default endpoint for a given function. This always is the function name. Nz/expected view func if endpoint is not provided.)r))rs r&_endpoint_from_view_funcrs"  "S  r(r4c@|d\}}} tj|}|t dn*#t tf$rt jcYSwxYw|jr|j |j dkrtj|}|^|jrWtj t j |jtfd|jD}n |jd}t j |St j t j |j St j |j S)z2Find the path that contains the package or module..Nz not found namespacec3FK|]}||VdSr#)is_relative_to).0location package_paths r& z%_find_package_path..sK'' #228<<'''''''r(r) partition importlibutil find_specr ImportErrorrUgetcwdsubmodule_search_locationsoriginpathlibPathrV commonpathnextdirname)r4 root_mod_name_ root_spec package_specsearch_locationrs @r&_find_package_pathrs%//44M1a N,,];;  [)) )   $ y{{ +1   #y'7;'F'F$>33K@@L'L,S'&|G&&|'NOO   #'''''$-$H'''###,"Fq"I7???33 37??27??93C#D#DEE Ewy/000s0A $A43A4tuple[str | None, str]ctt|}tjtj}t j||r||fStj |\}}| dkrtj |\}}| dkr||fStj | dkr!tj ||fS||fSd|fS)aFind the prefix that a package is installed under, and the path that it would be imported from. The prefix is the directory containing the standard directory hierarchy (lib, bin, etc.). If the package is not installed to the system (:attr:`sys.prefix`) or a virtualenv (``site-packages``), ``None`` is returned. The path is the entry in :attr:`sys.path` that contains the package for import. If the package is not installed, it's assumed that the package was imported from the current working directory. z site-packageslibN) rrUrVabspathsysprefixrPurePathrsplitlowerrbr)r4r py_prefix site_parent site_folderparentfolders r& find_packagers&k22L ++I %%44Y??',&&!w}}\::Ko--{33 <<>>U " "<' ' 7  F # # ) ) + +u 4 47??6**L8 8L((  r(r)rrrr/)r4r/rr/)r4r/rr)9 __future__rimportlib.utilrrUrrr r* collectionsr functoolsrjinja2rrwerkzeug.exceptionsrr werkzeug.utilsr fthelpersr templatingr TYPE_CHECKINGclickrobject _sentinelTypeVarCallableAnyrAfterRequestCallablerBeforeRequestCallablerErrorHandlerCallablerTeardownCallabler TemplateContextProcessorCallablerURLDefaultCallablerURLValuePreprocessorCallabler RouteCallablerr,rrrrr=r(r&rs""""""  ######$$$$$$######222222------******######888888? FHH  AIcCJ/000!)-R5LQU5STTT19/r7OPPP!)-R5LMMM QY|2+> ? ? ? (qy""*M   +23HIII$19b&E !)IR%5 6 6 66666F #F #F #F #F #F #F #F #R*1*1*1*1Z&&&&&&r(