zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
U
Þ=®d²ã@súUddlmZddlZddlZddlZddlZddlmZej    rLddl
m Z Gdd„de ƒZ Gdd    „d    ƒZGd
d „d eƒZGd d „d eƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZeeeeeeedœZded<dS)é)Ú annotationsN)Úquoteé)ÚMapc@seZdZdZdS)ÚValidationErrorzˆValidation error.  If a rule converter raises this exception the rule
    does not match the current URL and the next URL is tried.
    N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__©r r úRd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\werkzeug/routing/converters.pyr srcsheZdZdZdZdZdZdddœ‡fdd    „ Zd
dddd œd d „Zdddœdd„Z    dddœdd„Z
‡Z S)Ú BaseConverterzBase class for all converters.
 
    .. versionchanged:: 2.3
        ``part_isolating`` defaults to ``False`` if ``regex`` contains a ``/``.
    z[^/]+édTút.AnyÚNone)ÚkwargsÚreturnc s2tƒjf|Žd|jkr.d|jkr.d|jk|_dS)NÚregexÚpart_isolatingú/)ÚsuperÚ__init_subclass__Ú__dict__rr)Úclsr©Ú    __class__r r rszBaseConverter.__init_subclass__r)ÚmapÚargsrrcOs
||_dS©N)r)Úselfrrrr r r Ú__init__&szBaseConverter.__init__Ústr©ÚvaluercCs|Srr ©rr#r r r Ú    to_python)szBaseConverter.to_pythoncCs@t|ttfƒr*tjdtddt|ddStt|ƒ|jj    ddS)NzUPassing bytes as a URL value is deprecated and will not be supported in Werkzeug 3.0.é)Ú
stacklevelz!$&'()*+,/:;=@)Úsafe)Úencodingr()
Ú
isinstanceÚbytesÚ    bytearrayÚwarningsÚwarnÚDeprecationWarningrr!rÚcharsetr$r r r Úto_url,sü zBaseConverter.to_url) rrr    r
rÚweightrrr r%r1Ú __classcell__r r rr r sr cs0eZdZdZd ddddddœ‡fd    d
„ Z‡ZS) ÚUnicodeConverteraThis converter is the default converter and accepts any string but
    only one path segment.  Thus the string can not include a slash.
 
    This is the default validator.
 
    Example::
 
        Rule('/pages/<page>'),
        Rule('/<string(length=2):lang_code>')
 
    :param map: the :class:`Map`.
    :param minlength: the minimum length of the string.  Must be greater
                      or equal 1.
    :param maxlength: the maximum length of the string.
    :param length: the exact length of the string.
    rNrÚintú
int | Noner)rÚ    minlengthÚ    maxlengthÚlengthrcsftƒ |¡|dk    r&dt|ƒ›d}n0|dkr4d}n tt|ƒƒ}dt|ƒ›d|›d}d|›|_dS)NÚ{Ú}Úú,z[^/])rr r5r!r)rrr7r8r9Z length_regexZmaxlength_valuerr r r Ls  zUnicodeConverter.__init__)rNN)rrr    r
r r3r r rr r4:s
ûr4cs:eZdZdZddddœ‡fdd„ Zddd    œd
d „Z‡ZS) Ú AnyConvertera€Matches one of the items provided.  Items can either be Python
    identifiers or strings::
 
        Rule('/<any(about, help, imprint, class, "foo,bar"):page_name>')
 
    :param map: the :class:`Map`.
    :param items: this function accepts the possible items as positional
                  arguments.
 
    .. versionchanged:: 2.2
        Value is validated when building a URL.
    rr!r)rÚitemsrcs8tƒ |¡t|ƒ|_dd dd„|Dƒ¡›d|_dS)Nz(?:ú|cSsg|]}t |¡‘qSr )ÚreÚescape)Ú.0Úxr r r Ú
<listcomp>psz)AnyConverter.__init__.<locals>.<listcomp>ú))rr Úsetr?Újoinr)rrr?rr r r ms 
zAnyConverter.__init__rr"cCsD||jkrt|ƒSd dd„t|jƒDƒ¡}td|›d|›ƒ‚dS)Nz, css|]}d|›dVqdS)ú'Nr )rCÚitemr r r Ú    <genexpr>vsz&AnyConverter.to_url.<locals>.<genexpr>rIz' is not one of )r?r!rHÚsortedÚ
ValueError)rr#Z valid_valuesr r r r1rs
zAnyConverter.to_url)rrr    r
r r1r3r r rr r>_s r>c@seZdZdZdZdZdS)Ú PathConverterzñLike the default :class:`UnicodeConverter`, but it also matches
    slashes.  This is useful for wikis and similar applications::
 
        Rule('/<path:wikipage>')
        Rule('/<path:wikipage>/edit')
 
    :param map: the :class:`Map`.
    z[^/].*?éÈN)rrr    r
rr2r r r r rNzs    rNcsveZdZUdZdZeZded<ddd    d
d
d d d œ‡fdd„ Zdddœdd„Z    dddœdd„Z
e ddœdd„ƒZ ‡Z S)ÚNumberConverterzKBaseclass for `IntegerConverter` and `FloatConverter`.
 
    :internal:
    é2z
t.CallableÚ num_convertrNFrr5r6Úboolr)rÚ fixed_digitsÚminÚmaxÚsignedrcs4|r |j|_tƒ |¡||_||_||_||_dSr)Ú signed_regexrrr rTrUrVrW)rrrTrUrVrWrr r r ‘s zNumberConverter.__init__r!rr"cCsV|jrt|ƒ|jkrtƒ‚| |¡}|jdk    r8||jksL|jdk    rR||jkrRtƒ‚|Sr)rTÚlenrrRrUrVr$r r r r%¡s
ÿÿzNumberConverter.to_pythoncCs$t| |¡ƒ}|jr | |j¡}|Sr)r!rRrTÚzfillr$r r r r1«s zNumberConverter.to_url)rcCs d|j›S)Nz-?)r)rr r r rX±szNumberConverter.signed_regex)rNNF)rrr    r
r2r5rRÚ__annotations__r r%r1ÚpropertyrXr3r r rr rPˆs
 ú
rPc@seZdZdZdZdS)ÚIntegerConvertera­This converter only accepts integer values::
 
        Rule("/page/<int:page>")
 
    By default it only accepts unsigned, positive values. The ``signed``
    parameter will enable signed, negative values. ::
 
        Rule("/page/<int(signed=True):page>")
 
    :param map: The :class:`Map`.
    :param fixed_digits: The number of fixed digits in the URL. If you
        set this to ``4`` for example, the rule will only match if the
        URL looks like ``/0001/``. The default is variable length.
    :param min: The minimal value.
    :param max: The maximal value.
    :param signed: Allow signed (negative) values.
 
    .. versionadded:: 0.15
        The ``signed`` parameter.
    z\d+N)rrr    r
rr r r r r]¶sr]cs8eZdZdZdZeZd dddddd    œ‡fd
d „ Z‡ZS) ÚFloatConverteraùThis converter only accepts floating point values::
 
        Rule("/probability/<float:probability>")
 
    By default it only accepts unsigned, positive values. The ``signed``
    parameter will enable signed, negative values. ::
 
        Rule("/offset/<float(signed=True):offset>")
 
    :param map: The :class:`Map`.
    :param min: The minimal value.
    :param max: The maximal value.
    :param signed: Allow signed (negative) values.
 
    .. versionadded:: 0.15
        The ``signed`` parameter.
    z\d+\.\d+NFrz float | NonerSr)rrUrVrWrcstƒj||||ddS)N)rUrVrW)rr )rrrUrVrWrr r r åszFloatConverter.__init__)NNF)    rrr    r
rÚfloatrRr r3r r rr r^Ïsûr^c@s4eZdZdZdZdddœdd„Zdddœdd    „Zd
S) Ú UUIDConverterz™This converter only accepts UUID strings::
 
        Rule('/object/<uuid:identifier>')
 
    .. versionadded:: 0.10
 
    :param map: the :class:`Map`.
    zK[A-Fa-f0-9]{8}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{4}-[A-Fa-f0-9]{12}r!z    uuid.UUIDr"cCs
t |¡Sr)ÚuuidÚUUIDr$r r r r%þszUUIDConverter.to_pythoncCst|ƒSr)r!r$r r r r1szUUIDConverter.to_urlN)rrr    r
rr%r1r r r r r`ïs
 
ÿr`)ÚdefaultÚstringÚanyÚpathr5r_raz#t.Mapping[str, type[BaseConverter]]ÚDEFAULT_CONVERTERS)Ú
__future__rrAÚtypingÚtrar-Ú urllib.parserÚ TYPE_CHECKINGrrrMrr r4r>rNrPr]r^r`rgr[r r r r Ú<module>s2   '%. ù