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__/admin.cpython-310.pyc
o

�k�`�*�@s�ddlZddlZddlZddlTddlmZddlTddlmZddl	m
Z
ddlmZm
Z
ddlmZmZddlmZmZmZmZmZmZdd	lmZGd
d�de�ZdS)�N)�*)�IEnvironmentSetupParticipant)�model)�
WikiSystem)�lazy�	read_file)�format_datetime�from_utimestamp)�path_to_unicode�print_table�printout�
to_unicode�
unicode_quote�unicode_unquote)�_c@s�eZdZdZeee�dd�Zedd��Z	d4dd�Z
d	d
�Zgdfdd
�Zggdfdd�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zd4dd�Zd4d d!�Zd"d#�Zd$d%�Zd&d'�Zd(d)�Zd5d*d+�Zd,d-�Zd.d/�Zd0d1�Zd2d3�ZdS)6�	WikiAdminz4trac-admin command provider for wiki administration.ccs��dddd|jfVddd|j|jfVddd	|j|jfVd
dd|j|jfVd
dd|j|jfVddd|j|jfVddd|j	|j
fVddd|j	|jfVdddd|jfVdS)Nz	wiki list�zList wiki pageszwiki renamez<page> <new_name>zRename wiki pagezwiki removez<page>zRemove wiki pagezwiki exportz
<page> [file]z"Export wiki page to file or stdoutzwiki importz#Import wiki page from file or stdinz	wiki dumpz<directory> [page] [...]a8Export wiki pages to files named by title

               Individual wiki page names can be specified after the directory.
               A name ending with a * means that all wiki pages starting with
               that prefix should be dumped. If no name is specified, all wiki
               pages are dumped.z	wiki loadz<path> [...]z�Import wiki pages from files

               If a given path is a file, it is imported as a page with the
               name of the file. If a path is a directory, all files in that
               directory are imported.zwiki replacea�Replace content of wiki pages from files (DANGEROUS!)

               This command replaces the content of the last version of one
               or more wiki pages with new content. The previous content is
               lost, and no new entry is created in the page history. The
               metadata of the page (time, author) is not changed either.

               If a given path is a file, it is imported as a page with the
               name of the file. If a path is a directory, all files in that
               directory are imported.

               WARNING: This operation results in the loss of the previous
               content and cannot be undone. It may be advisable to backup
               the current content using "wiki dump" beforehand.zwiki upgradez-Upgrade default wiki pages to current version)
�_do_list�_complete_page�
_do_rename�
_do_remove�_complete_import_export�
_do_export�
_do_import�_complete_dump�_do_dump�_complete_load_replace�_do_load�_do_replace�_do_upgrade��self�r"�1/usr/lib/python3/dist-packages/trac/wiki/admin.py�get_admin_commands%sJ���������
�zWikiAdmin.get_admin_commandscCst�dd�S)Nz	trac.wikiz
default-pages)�
pkg_resources�resource_filenamer r"r"r#�default_pages_dirXszWikiAdmin.default_pages_dirNcCstt|j��|��S�N)�sortedr�env�	get_pages)r!�prefixr"r"r#�
get_wiki_list\szWikiAdmin.get_wiki_listcCs�t�|j|�}|jrC|st|j�dStj�|�r#t	t
dt|�d���t|ddd��}|�
|j�Wd�dS1s<wYdSt	t
d|d���)NzFile '%(name)s' exists��name�w�utf-8)�encodingzPage '%(page)s' not found��page)r�WikiPager*�existsr�text�os�path�isfile�AdminCommandErrorrr
�open�write)r!r4�filename�wikipage�fr"r"r#�export_page_s�"�zWikiAdmin.export_pageFc	
Cs�|rtj�|�sttdt|�d���t|�}ntj�	�}t
|d�}t|�d��}t
�|j|�}|jrM||vr?|j�d|�dS||jkrM|j�d|�dS||_z
|jdd|d�Wntyk}zt|�|�d}~ww|j�d	|t|��d
S)Nz'%(name)s' is not a filer.r1z%s already existsFz%s is already up to date�trac��replacez%s imported from %sT)r8r9r:r;rr
r�sys�stdin�readr
r�encoderr5r*r6�log�infor7�save�	TracError)	r!r>�title�create_onlyrD�datar/r4�er"r"r#�import_pagems4�




��zWikiAdmin.import_pagecCs�g}|jj�9tt�|��D](}||vrqtj�||�}tj�|�r6t|�	d��}|�
||||�r6|�|�qWd�|S1sBwY|S)Nr1)r*�db_transactionr)r8�listdirr9�joinr:rrHrQ�append)r!�dir�ignorerNrD�loadedr4r>r"r"r#�
load_pages�s 

��
�	�	zWikiAdmin.load_pagescCst|�dkr
|��SdS)N�)�lenr-�r!�argsr"r"r#r�s�zWikiAdmin._complete_pagecCs0t|�dkr
|��St|�dkrt|d�SdS)NrZ����)r[r-�get_dir_listr\r"r"r#r�s
�z!WikiAdmin._complete_import_exportcCs4t|�dkrt|ddd�St|�dkr|��SdS)NrZr_T)�	dirs_onlyr^)r[r`r-r\r"r"r#r�s
�zWikiAdmin._complete_dumpcCst|�dkrt|d�SdS)NrZr_)r[r`r\r"r"r#r�s�z WikiAdmin._complete_load_replacecCs2tdd�|j�d�D�td�td�td�g�dS)NcSs*g|]\}}}|t|�tt|�t�f�qSr")�intrr	�console_datetime_format)�.0rM�edits�modifiedr"r"r#�
<listcomp>�s
�
�z&WikiAdmin._do_list.<locals>.<listcomp>zs
                    SELECT name, max(version), max(time)
                    FROM wiki GROUP BY name ORDER BY name�Title�Edits�Modified)rr*�db_queryrr r"r"r#r�s
��zWikiAdmin._do_listc
CsVt�|j|�}z|�|�Wnty}zt|�|�d}~wwttd||d��dS)Nz# '%(name1)s' renamed to '%(name2)s')�name1�name2)rr5r*�renamerLr;rr)r!r/�new_namer4rPr"r"r#r�s
���zWikiAdmin._do_renamecCs�|jj�Q|�d�r2|�|�d�pd�}|D]
}t�|j|�}|��qtdd�|D�t	d�g�nt�|j|�}|��t
t	d|d��Wd�dSWd�dS1sXwYdS)Nrcss�|]}|fVqdSr(r")rd�pr"r"r#�	<genexpr>�s�z'WikiAdmin._do_remove.<locals>.<genexpr>z
Deleted pagesz '%(page)s' deletedr3)r*rR�endswithr-�rstriprr5�deleterrr)r!r/�pagesrpr4r"r"r#r�s


�"�zWikiAdmin._do_removecCs(|�||�|rtd||f�dSdS)N�
 '%s' => '%s')rAr�r!r4r>r"r"r#r�s�zWikiAdmin._do_exportcCs|�||�dSr()�_importrwr"r"r#r�szWikiAdmin._do_importcs�|sdg}|��}tj�|�s%tj�|�st�|�n
ttdt|�d���|D]%�t	�fdd�|D��rLtj�
|t�d��}td�|f�|�
�|�q'dS)Nrz'%(name)s' is not a directoryr.c3s4�|]}�|kp|�d�o��|dd��VqdS)rNr_)rr�
startswith)rdr/�rpr"r#rq�s��
�z%WikiAdmin._do_dump.<locals>.<genexpr>rrv)r-r8r9�isdirr6�mkdirr;rr
�anyrTrrrA)r!�	directory�namesru�dstr"rzr#r�s$����zWikiAdmin._do_dumpcG�|j|dd�dS)NFrC��_load_or_replace�r!�pathsr"r"r#r��zWikiAdmin._do_loadcGr�)NTrCr�r�r"r"r#r�r�zWikiAdmin._do_replacecCs0|j|jddgdgd�}ttdt|�d��dS)N�	WikiStart�SandBox�InterMapTxt)rWrNz'Upgrade done: %(count)s pages upgraded.)�count)rYr'rrr[)r!rr"r"r#r�s��zWikiAdmin._do_upgradecCs<|j|||d�rtdt|�|f�dSttd|d��dS)NrCrvz" '%(title)s' is already up to date)rM)rQrr
r)r!r>rMrDr"r"r#rx�szWikiAdmin._importcCs�|jj�@|D]4}tj�|�r.tt�|��D]}tj�||�}tj�|�r,|�	|||�qqtj�
|�}|�	|||�qWd�dS1sGwYdSr()r*rRr8r9r{r)rSrTr:rx�basename)r!r�rDr9r4r>r"r"r#r��s
���"�zWikiAdmin._load_or_replacecCst|j�d�|jj�&|�|j�D]}|dvr't�|j|�}d|_|�	dd�qWd�dS1s3wYdS)z3Add default wiki pages when environment is created.zInstalling default wiki pages)r�r�r�rZN)
rIrJr*rRrYr'rr5�readonlyrK)r!r/r4r"r"r#�environment_createds
��"�zWikiAdmin.environment_createdcC�dSr(r"r r"r"r#�environment_needs_upgrade�z#WikiAdmin.environment_needs_upgradecCr�r(r"r r"r"r#�upgrade_environmentr�zWikiAdmin.upgrade_environmentr()F) �__name__�
__module__�__qualname__�__doc__�
implements�IAdminCommandProviderrr$rr'r-rArQrYrrrrrrrrrrrrrrxr�r�r�r�r"r"r"r#rs8
3


		



r)r8r%rE�
trac.admin�trac.apir�	trac.core�	trac.wikir�
trac.wiki.apir�	trac.utilrr�trac.util.datefmtrr	�trac.util.textr
rrr
rr�trac.util.translationr�	Componentrr"r"r"r#�<module>s
 

https://t.me/RX1948 - 2025