https://t.me/RX1948
Server : Apache
System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64
User : dh_edsupp ( 6597262)
PHP Version : 8.2.26
Disable Function : NONE
Directory :  /lib/python3/dist-packages/trac/wiki/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/trac/wiki/__pycache__/api.cpython-310.pyc
o

�k�`�O�@s�ddlZddlmZddlmZmZddlTddlmZddl	m
Z
mZddlm
Z
ddlmZdd	lmZGd
d�de�ZGdd
�d
e�ZGdd�de�ZGdd�de�Zddd�Zdd�ZGdd�de�ZdS)�N)�cached)�
BoolOption�
ListOption)�*)�IResourceManager)�is_safe_origin�tag)�
unquote_label)�_)�
WikiParserc@s@eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dS)�IWikiChangeListenerz�Components that want to get notified about the creation,
    deletion and modification of wiki pages should implement that
    interface.
    cC�dS)z)Called whenever a new Wiki page is added.N���pagerr�//usr/lib/python3/dist-packages/trac/wiki/api.py�wiki_page_added%�z#IWikiChangeListener.wiki_page_addedcCr
)z%Called when a page has been modified.Nr)r�version�t�comment�authorrrr�wiki_page_changed(rz%IWikiChangeListener.wiki_page_changedcCr
)z$Called when a page has been deleted.Nrrrrr�wiki_page_deleted+rz%IWikiChangeListener.wiki_page_deletedcCr
)z1Called when a version of a page has been deleted.Nrrrrr�wiki_page_version_deleted.rz-IWikiChangeListener.wiki_page_version_deletedcCr
)z$Called when a page has been renamed.Nr)r�old_namerrr�wiki_page_renamed1rz%IWikiChangeListener.wiki_page_renamedcCr
)z-Called when a page comment has been modified.Nr)r�old_commentrrr�wiki_page_comment_modified4rz.IWikiChangeListener.wiki_page_comment_modifiedN)
�__name__�
__module__�__qualname__�__doc__rrrrrrrrrrrsrc@� eZdZdZdd�Zdd�ZdS)�IWikiPageManipulatorz�Components that need to do specific pre- and post- processing of
    wiki page changes have to implement this interface.

    Unlike change listeners, a manipulator can reject changes being
    committed to the database.
    cCr
)aXValidate a wiki page before rendering it.

        :param page: is the `WikiPage` being viewed.

        :param fields: is a dictionary which contains the wiki `text`
          of the page, initially identical to `page.text` but it can
          eventually be transformed in place before being used as
          input to the formatter.
        Nr)�reqr�fieldsrrr�prepare_wiki_page@rz&IWikiPageManipulator.prepare_wiki_pagecCr
)apValidate a wiki page after it's been populated from user input.

        :param page: is the `WikiPage` being edited.

        :return: a list of `(field, message)` tuples, one for each
          problem detected. `field` can be `None` to indicate an
          overall problem with the page. Therefore, a return value of
          `[]` means everything is OK.
        Nr)r%rrrr�validate_wiki_pageKrz'IWikiPageManipulator.validate_wiki_pageN)rr r!r"r'r(rrrrr$8sr$c@s2eZdZdZdd�Zdd�Zdd�Zdd	d
�ZdS)�IWikiMacroProviderz�Augment the Wiki markup with new Wiki macros.

    .. versionchanged :: 0.12
       new Wiki processors can also be added that way.
    cCr
)zKReturn an iterable that provides the names of the provided macros.
        Nrrrrr�
get_macros^rzIWikiMacroProvider.get_macroscCr
)a�Return a tuple of a domain name to translate and plain text
        description of the macro or only the description with the specified
        name.

        .. versionchanged :: 1.0
           `get_macro_description` can return a domain to translate the
           description.

        .. versionchanged :: 1.3.6
           the macro will be hidden from the macro index (`[[MacroList]]`)
           if `None` is returned.
        Nr)�namerrr�get_macro_descriptionbrz(IWikiMacroProvider.get_macro_descriptioncCr
)zkReturn `True` if the content generated is an inline XHTML element.

        .. versionadded :: 1.0
        Nr)�contentrrr�	is_inlineprzIWikiMacroProvider.is_inlineNcCr
)aMCalled by the formatter when rendering the parsed wiki text.

        .. versionadded:: 0.11

        .. versionchanged:: 0.12
           added the `args` parameter

        :param formatter: the wiki `Formatter` currently processing
          the wiki markup

        :param name: is the name by which the macro has been called;
          remember that via `get_macros`, multiple names could be
          associated to this macros. Note that the macro names are
          case sensitive.

        :param content: is the content of the macro call. When called
          using macro syntax (`[[Macro(content)]]`), this is the
          string contained between parentheses, usually containing
          macro arguments. When called using wiki processor syntax
          (`{{{!#Macro ...}}}`), it is the content of the processor
          block, that is, the text starting on the line following the
          macro name.

        :param args: will be a dictionary containing the named
          parameters passed when using the Wiki processor syntax.

          The named parameters can be specified when calling the macro
          using the wiki processor syntax::

            {{{#!Macro arg1=value1 arg2="value 2"`
            ... some content ...
            }}}

          In this example, `args` will be
          `{'arg1': 'value1', 'arg2': 'value 2'}`
          and `content` will be `"... some content ..."`.

          If no named parameters are given like in::

            {{{#!Macro
            ...
            }}}

          then `args` will be `{}`. That makes it possible to
          differentiate the above situation from a call
          made using the macro syntax::

             [[Macro(arg1=value1, arg2="value 2", ... some content...)]]

          in which case `args` will always be `None`.  Here `content`
          will be the
          `"arg1=value1, arg2="value 2", ... some content..."` string.
          If like in this example, `content` is expected to contain
          some arguments and named parameters, one can use the
          `parse_args` function to conveniently extract them.
        Nr)�	formatterr+r-�argsrrr�expand_macrovrzIWikiMacroProvider.expand_macro�N)rr r!r"r*r,r.r1rrrrr)Wsr)c@r#)�IWikiSyntaxProviderz'Enrich the Wiki syntax with new markup.cCr
)aAReturn an iterable that provides additional wiki syntax.

        Additional wiki syntax correspond to a pair of `(regexp, cb)`,
        the `regexp` for the additional syntax and the callback `cb`
        which will be called if there's a match.  That function is of
        the form `cb(formatter, ns, match)`.
        Nrrrrr�get_wiki_syntax�rz#IWikiSyntaxProvider.get_wiki_syntaxcCr
)a�Return an iterable over `(namespace, formatter)` tuples.

        Each formatter should be a function of the form::

          def format(formatter, ns, target, label, fullmatch=None):
              pass

        and should return some HTML fragment. The `label` is already
        HTML escaped, whereas the `target` is not. The `fullmatch`
        argument is optional, and is bound to the regexp match object
        for the link.
        Nrrrrr�get_link_resolvers�rz&IWikiSyntaxProvider.get_link_resolversN)rr r!r"r4r5rrrrr3�s	r3TcCs�gi}}|rCt�d|�D]5}|�dd�}|rt�d|�}nt�d|�}|r=|d|��d���}||��d�||<q
|�|�q
||fS)a%Utility for parsing macro "content" and splitting them into arguments.

    The content is split along commas, unless they are escaped with a
    backquote (see example below).

    :param args: a string containing macros arguments
    :param strict: if `True`, only Python-like identifiers will be
                   recognized as keyword arguments

    Example usage::

      >>> parse_args('')
      ([], {})
      >>> parse_args('Some text')
      (['Some text'], {})
      >>> parse_args(r'Some text, mode= 3, some other arg\, with a comma.')
      (['Some text', ' some other arg, with a comma.'], {'mode': ' 3'})
      >>> sorted(parse_args('milestone=milestone1,status!=closed',
      ...                   strict=False)[1].items())
      [('milestone', 'milestone1'), ('status!', 'closed')]

    z(?<!\\),z\,�,z\s*[a-zA-Z_]\w+=z	\s*[^=]+=N�)�re�split�replace�match�end�strip�append)r0�strict�largs�kwargs�arg�m�kwrrr�
parse_args�s
rEcCs|o
tdd�|�d�D��S)z\Utility for validating wiki page name.

    :param pagename: wiki page name to validate
    css�|]}|dvVqdS)���.�..Nr)�.0�partrrr�	<genexpr>�s�z%validate_page_name.<locals>.<genexpr>�/)�allr9)�pagenamerrr�validate_page_name�s�rPc@sLeZdZdZeee�ee�Z	ee
�Zee�ZdZ
dZdZedddd�Zedddd	�Zedd
dd�Zeddd
dd�Zeddddd�Zedd��Zd:dd�Zdd�Zd:dd�Zdd�ZdZe�d�Z d �!d!d"�e"d#�D��Z#d �!d$d"�e"d#�D��Z$d;d&d'�Z%d(d)�Z&d*d+�Z'd,d-�Z(	d:d.d/�Z)d0d1�Z*d2d3�Z+d4d5�Z,d6d7�Z-d8d9�Z.dS)<�
WikiSystemzWiki system manager.�wiki�	WikiStart�
TitleIndex�ignore_missing_pages�falsezFEnable/disable highlighting CamelCase links to missing pages.
        �split_page_nameszJEnable/disable splitting the WikiPageNames with space characters.
        �render_unsafe_contenta	Enable/disable the use of unsafe HTML tags such as `<script>` or
        `<embed>` with the HTML [wiki:WikiProcessors WikiProcessor].

        For public sites where anonymous users can edit the wiki it is
        recommended to leave this option disabled.
        �safe_schemeszIcvs, file, ftp, git, irc, http, https, news, sftp, smb, ssh, svn, svn+sshz�List of URI schemes considered "safe", that will be rendered as
        external links even if `[wiki] render_unsafe_content` is `false`.
        )�doc�safe_originszdata:aFList of URIs considered "safe cross-origin", that will be
        rendered as `img` element without `crossorigin="anonymous"` attribute
        or used in `url()` of inline style attribute even if
        `[wiki] render_unsafe_content` is `false` (''since 1.0.15'').

        To make any origins safe, specify "*" in the list.cCsdd�|j�d�D�S)z,Return the names of all existing wiki pages.cSsh|]\}|�qSrr)rJr+rrr�	<setcomp>+sz#WikiSystem.pages.<locals>.<setcomp>zSELECT DISTINCT name FROM wiki)�env�db_query��selfrrr�pages(s
�zWikiSystem.pagesNccs&�|jD]}|r
|�|�r|VqdS)z�Iterate over the names of existing Wiki pages.

        :param prefix: if given, only names that start with that
          prefix are included.
        N)ra�
startswith)r`�prefixrrrr�	get_pages0s�
��zWikiSystem.get_pagescCs|�d�|jvS)z.Whether a page with the specified name exists.rM)�rstripra)r`rOrrr�has_page:szWikiSystem.has_pagecCst|j||d�S)N)r%)rr[)r`�urir%rrrr>szWikiSystem.is_safe_origincCs"|�d�s	|dvr|�||�S|S)z4Resolves a pagename relative to a referrer pagename.�z./z../�rHrI)rb�_resolve_relative_name)r`rO�referrerrrr�resolve_relative_nameAsz WikiSystem.resolve_relative_namez[\w:](?<!\d)(?:[\w:.-]*[\w-])?z([a-z])([A-Z])(?=[a-z])rGcc�$�|]
}t|���rt|�VqdSr2)�chr�isupper�rJ�crrrrLO��"zWikiSystem.<genexpr>iccrmr2)rn�islowerrprrrrLPrrFcCs|s|jr|j�d|�S|S)Nz\1 \2)rW�
PAGE_SPLIT_RE�sub)r`rr9rrr�format_page_nameRs
zWikiSystem.format_page_namecCsh|�dd�d�dd�d}|s|S|�d�}t|�D]\}}|dvr.d�||d��}nq|�|�S)a(Create a label from a wiki target.

        A trailing fragment and query string is stripped. Then, leading ./,
        ../ and / elements are stripped, except when this would lead to an
        empty label. Finally, if `split_page_names` is true, the label
        is split accordingly.
        �#r7r�?rMrFN)r9�	enumerate�joinrv)r`�target�label�
components�i�comprrr�make_label_from_targetWs
�
z!WikiSystem.make_label_from_targetc#sx�d�j�j�jd�}�fdd�}d||fV�fdd�}d|tjf|fV�fd	d
�}dtjtjf|fVdS)Nzk(?:[%(upper)s](?:[%(lower)s])+/?){2,}(?:@[0-9]+)?(?:#%(xml)s)?(?=:(?:\Z|\s)|[^:\w%(upper)s%(lower)s]|\s|\Z))�upper�lower�xmlcs��|d|��|��j|�S)NrR)�_format_linkrvrU)r/r;�	fullmatchr_rr�wikipagename_linkss
�z5WikiSystem.get_wiki_syntax.<locals>.wikipagename_linkz!?(?<![\w/])(?:\.?\.?/)*cs.|�d�}|�d�}��|d||���j|�S)N�	wiki_page�
wiki_labelrR)�groupr�r=rU)r/r;r�rr|r_rr�wikipagename_with_label_link~s


�z@WikiSystem.get_wiki_syntax.<locals>.wikipagename_with_label_linkz3!?\[(?P<wiki_page>%s)\s+(?P<wiki_label>%s|[^\]]+)\]csD|�d�dd�}|�d�}|dur��|�}��|d||��d�S)N�ifl_pager7����	ifl_labelrRF)r�r�r�r=)�fmtrCr�rr|r_rr�internal_free_link�s


z6WikiSystem.get_wiki_syntax.<locals>.internal_free_linkz6!?\[(?P<ifl_page>%s)(?:\s+(?P<ifl_label>%s|[^\]]+))?\])�Lu�Ll�XML_NAMEr�
QUOTED_STRING)r`�wiki_page_namer�r�r�rr_rr4is.���	����
�
�zWikiSystem.get_wiki_syntaxc#s�d�fdd�	}d|fVdS)Ncs@|dur|��}|�d�r|�d�s��|�}��||||d�S)N�lnsr|F)�	groupdict�getr�r�)r/�nsr{r|r��groupsr_rr�
link_resolver�s

z4WikiSystem.get_link_resolvers.<locals>.link_resolverrRr2r)r`r�rr_rr5�s�	zWikiSystem.get_link_resolverscCsn|�|�\}}}d}	d|vr|�dd�\}}	|	r"|r"d|dd�}|�d�p)|j}d}
|jr:|jj|jkr:|jj}
|�d�rE|�d�}n|�d�sN|dvrU|�	||
�}n|�
||
�}t|�}d|�|j||	�vr�|j
j||	d	�||}|�|�r�tj||d
d�S|r�|p�|Sd|�|j||	�vr�tj|d
|dd�Stj|d
d�S|r�|�|�s�|p�|Stj|dtd�d�S)N�@r7�&rMrGrhri�	WIKI_VIEW)rrR)�href�class_�WIKI_CREATEzmissing wiki�nofollow)r�r��rel)r�zforbidden wikiz$no permission to view this wiki page)r��title)�
split_linkr9re�
START_PAGE�resource�realm�idrb�lstriprj�_resolve_scoped_namer	�permr�rRrfr�ar
)r`r/r�rOr|�ignore_missing�original_label�query�fragmentrrkr�rrrr��sH
�
���zWikiSystem._format_linkcCsd|�d�}|�d�}t|�D]\}}|dkr|r|��q|dkr,|�||d��nqd�|�S)NrMrIrH)r9ry�pop�extendrz)r`rOrk�baser}r~rrrrrj�s

��
z!WikiSystem._resolve_relative_namec	Cs�|�d�}t|�dkr
|Stt|�ddd�D]}d�|d|��d|}|�|�r/|Sq|�|�r7|Sd|vrh|�dd�\}}t|�D] \}}||krgd�|d|d��}|�|�rg|d|SqGd�|dd��d|S)NrMr7rr�)r9�len�rangerzrfry)	r`rOrkr~r+�first�restrK�anchorrrrr��s&

�

�zWikiSystem._resolve_scoped_nameccs�|jVdSr2)r�r_rrr�get_resource_realms�s�zWikiSystem.get_resource_realmscKs|�|j�S)a_
        >>> from trac.test import EnvironmentStub
        >>> from trac.resource import Resource, get_resource_description
        >>> env = EnvironmentStub()
        >>> main = Resource('wiki', 'WikiStart')
        >>> get_resource_description(env, main)
        'WikiStart'

        >>> get_resource_description(env, main(version=3))
        'WikiStart'

        >>> get_resource_description(env, main(version=3), format='summary')
        'WikiStart'

        >>> env.config['wiki'].set('split_page_names', 'true')
        >>> get_resource_description(env, main(version=3))
        'Wiki Start'
        )rvr�)r`r��formatrArrr�get_resource_description�sz#WikiSystem.get_resource_descriptioncCs0|jdur|j|jvSt|j�d|j|jf��S)a�
        >>> from trac.test import EnvironmentStub
        >>> from trac.resource import Resource, resource_exists
        >>> env = EnvironmentStub()

        >>> resource_exists(env, Resource('wiki', 'WikiStart'))
        False

        >>> from trac.wiki.model import WikiPage
        >>> main = WikiPage(env, 'WikiStart')
        >>> main.text = 'some content'
        >>> main.save('author', 'no comment')
        >>> resource_exists(env, main.resource)
        True
        Nz2SELECT name FROM wiki WHERE name=%s AND version=%s)rr�ra�boolr]r^)r`r�rrr�resource_existss

�zWikiSystem.resource_existsr2)F)/rr r!r"�
implementsrr3�ExtensionPointr�change_listenersr)�macro_providers�syntax_providersr�r��TITLE_INDEX_PAGErrUrWrXrrYr[rrardrfrrlr�r8�compilertrzr�r�r�rvr�r4r5r�rjr�r�r�r�rrrrrQ�s^
�����	





)
�'rQ)T)r8�
trac.cacher�trac.configrr�	trac.core�
trac.resourcer�trac.util.htmlrr�trac.util.textr	�trac.util.translationr
�trac.wiki.parserr�	Interfacerr$r)r3rErP�	ComponentrQrrrr�<module>s Z
'	

https://t.me/RX1948 - 2025