HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/__pycache__/_helper.cpython-310.pyc
o

�N�g�-�@s`dZddlZddlmZddlZddd�Zdd�Zdd	d
�Zdd�Z	Gd
d�de
�Zdd�ZdS)zHelper functions for CP apps.�N)�
text_or_bytescs���fdd�}ddl}ddl}|j|jtf}t||�r.�dur$d|_|S|�d�j�||�S|durF�dur>|�d�j�|S|�d�j�|S|�d�j�|�|S)zVExpose the function or class.

    Optionally provide an alias or set of aliases.
    csJd|_�dur#t�t�r|���dd�<|S�D]
}|�|�dd�<q|S)NT�.�_)�exposed�
isinstancer�replace)�func�a��alias�parents��D/opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/_helper.py�expose_s
�zexpose.<locals>.expose_rNT�)	�sys�types�FunctionType�
MethodType�typerr�	_getframe�f_locals)rrrrrZdecoratable_typesr
r
r�expose
s&

rcszd�d�|��D]\}}|dkr|�qd}t|�|���ddl��dur0t�d�s.����r0d�d
�����fdd	�	��S)atDecorate _cp_dispatch.

    (cherrypy.dispatch.Dispatcher.dispatch_method_name)

    Optional keyword argument: handler=(Object or Function)

    Provides a _cp_dispatch function that pops off path segments into
    cherrypy.request.params under the names specified.  The dispatch
    is then forwarded on to the next vpath element.

    Note that any existing (and exposed) member function of the class that
    popargs is applied to will override that value of the argument.  For
    instance, if you have a method named "list" on the class decorated with
    popargs, then accessing "/list" will call that function instead of popping
    it off as the requested parameter.  This restriction applies to all
    _cp_dispatch functions.  The only way around this restriction is to create
    a "blank class" whose only function is to provide _cp_dispatch.

    If there are path elements after the arguments, or more arguments
    are requested than are available in the vpath, then the 'handler'
    keyword argument specifies the next object to handle the parameterized
    request.  If handler is not specified or is None, then self is used.
    If handler is a function rather than an instance, then that function
    will be called with the args specified and the return value from that
    function used as the next object INSTEAD of adding the parameters to
    cherrypy.request.args.

    This decorator may be used in one of two ways:

    As a class decorator:

    .. code-block:: python

        @cherrypy.popargs('year', 'month', 'day')
        class Blog:
            def index(self, year=None, month=None, day=None):
                #Process the parameters here; any url like
                #/, /2009, /2009/12, or /2009/12/31
                #will fill in the appropriate parameters.

            def create(self):
                #This link will still be available at /create.
                #Defined functions take precedence over arguments.

    Or as a member of a class:

    .. code-block:: python

        class Blog:
            _cp_dispatch = cherrypy.popargs('year', 'month', 'day')
            #...

    The handler argument may be used to mix arguments with built in functions.
    For instance, the following setup allows different activities at the
    day, month, and year level:

    .. code-block:: python

        class DayHandler:
            def index(self, year, month, day):
                #Do something with this day; probably list entries

            def delete(self, year, month, day):
                #Delete all entries for this day

        @cherrypy.popargs('day', handler=DayHandler())
        class MonthHandler:
            def index(self, year, month):
                #Do something with this month; probably list entries

            def delete(self, year, month):
                #Delete all entries for this month

        @cherrypy.popargs('month', handler=MonthHandler())
        class YearHandler:
            def index(self, year):
                #Do something with this year

            #...

        @cherrypy.popargs('year', handler=YearHandler())
        class Root:
            def index(self):
                #...

    NF�handlerz;cherrypy.popargs() got an unexpected keyword argument '{0}'r�__call__Tcs���|�r|}tjjj}t||��|S|}i}�D]
}|s n|�d�||<q�dur>�r5�di|��Stjj�	|��Stjj�	|�|rPt
||�d�d�S|S)Nrr
)�isclass�cherrypy�dispatchZ
DispatcherZdispatch_method_name�setattr�pop�request�params�update�getattr)�cls_or_selfZvpath�cls�name�selfZparms�arg��args�	decoratedrZhandler_call�inspectr
rr+�s(

zpopargs.<locals>.decorated�NN)�items�	TypeError�formatr,�hasattrr)r*�kwargs�k�v�tmr
r)r�popargs7s Z��!r6�cCs�t|tttf�rtj�|�}|rd|}tjj	ro|�
d�sTtjj}tjjdur1|�
d�s0|d}ntjjdurF|�
d�rF|dkrF|dd�}|dkrM|}ntj�||�}|dur\tjj}|durdtjj}||t|�|}n|durxtj��}|p{d|}|t|�|}|dur�ttjj	dd�}|d	kr�dd�|�dd
�d
d��}|S|r�tdd��d�dd�}|�d�}|r�|r�|d|d}	}
|	|
kr�n|�d�|�d�|r�|s�d
gt|�|}d�|�}|S)a�Create an absolute URL for the given path.

    If 'path' starts with a slash ('/'), this will return
        (base + script_name + path + qs).
    If it does not start with a slash, this returns
        (base + script_name [+ request.path_info] + path + qs).

    If script_name is None, cherrypy.request will be used
    to find a script_name, if available.

    If base is None, cherrypy.request.base will be used (if available).
    Note that you can use cherrypy.tools.proxy to change this.

    Finally, note that this function can be used to obtain an absolute URL
    for the current request path (minus the querystring) by passing no args.
    If you call url(qs=cherrypy.request.query_string), you should get the
    original browser URL (assuming no internal redirections).

    If relative is None or not provided, request.app.relative_urls will
    be used (if available, else False). If False, the output will be an
    absolute URL (including the scheme, host, vhost, and script_name).
    If True, the output will instead be a URL that is relative to the
    current request path, perhaps including '..' atoms. If relative is
    the string 'server', the output will instead be a URL that is
    relative to the server root; i.e., it will start with a slash.
    �?�/TFN���r7Z
relative_urls�server�)�relativer�..)r�tuple�list�dict�urllib�parse�	urlencoderr Zapp�
startswithZ	path_infoZis_index�endswith�urljoin�script_name�base�normalize_pathr;r#�join�split�urlr�len)�path�qsrHrIr=�piZnewurl�old�newr	�br
r
rrM�sX

�
�


�
rMcCsnd|vr|Sg}|�d�D]}|dkrq
|dkr|r|��q
|r&|�|�q
d�|�}|�d�r5d|}|S)z4Resolve given path from relative into absolute form.z./r9rr>)rLr�appendrKrE)rOZatomsZatom�newpathr
r
rrJ#s"�
�

rJc@s$eZdZdZddd�Zddd�ZdS)�_ClassPropertyDescriptorz�Descript for read-only class-based property.

    Turns a classmethod-decorated func into a read-only property of that class
    type (means the value cannot be set).
    NcCs||_||_dS)zdInitialize a class property descriptor.

        Instantiated by ``_helper.classproperty``.
        N)�fget�fset)r'rXrYr
r
r�__init__Gs
z!_ClassPropertyDescriptor.__init__cCs |durt|�}|j�||��S)zReturn property value.N)rrX�__get__)r'�obj�klassr
r
rr[Osz _ClassPropertyDescriptor.__get__)N)�__name__�
__module__�__qualname__�__doc__rZr[r
r
r
rrW@s
rWcCst|ttf�st|�}t|�S)z@Decorator like classmethod to implement a static class property.)r�classmethod�staticmethodrW)rr
r
r�
classpropertyVsrdr-)r7r7NNN)
ra�urllib.parserBZcherrypy._cpcompatrrrr6rMrJ�objectrWrdr
r
r
r�<module>s
-
_