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/admin/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

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

�k�`�I�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlmZzddl	Z	Wne
y7dZ	YnwddlmZ
ddlmZmZmZddlmZddlmZddlmZddlmZdd	lmZdd
lmZmZmZm Z m!Z!m"Z"m#Z#ddl$m%Z%m&Z&m'Z'm(Z(ddl)m*Z*dd
l+m,Z,Gdd�dej-�Z.Gdd�de,�Z/dd�Z0dd�Z1ddd�Z2e3dkr�e�4de
�e�5e2��dSdS)�N)�shlex)�__version__)�AdminCommandError�AdminCommandManager�get_console_locale)�
Configuration)�	TracError)�Environment)�translation)�html)�
console_print�exception_to_unicode�getpreferredencoding�printerr�printout�	raw_input�
to_unicode)�_�	cleandoc_�	has_babel�ngettext)�
MacroError)�
WikiMacroBasec@s2eZdZdZddeiZdZdZdZdZ	dZ
d:dd�Zdd	�Zd
d�Z
dd
�Zd:dd�Zdd�Zedd��Zdd�Zedd��Zdd�Zdd�Zedd��Zed;dd ��Zd<d!d"�Zd#d$�Zd%d&�Zd'd(�Zd)gZed:d*d+��Z d,d-�Z!d:d.d/�Z"d0gZ#e#Z$e#Z%d1d2�Z&e&Z'e&Z(d3gZ)d4d5�Z*d6d7�Z+d8d9�Z,dS)=�	TracAdmin�z3Trac Admin Console %(version)s
Available Commands:
�versionzTrac> NcCs\tj�|�trt��}dD]}|�|d�}qt�|�d|_|r,|�t	j
�|��dSdS)Nz-/:()\rF)�cmd�Cmd�__init__�readline�get_completer_delims�replace�set_completer_delims�interactive�env_set�os�path�abspath)�self�envdir�delims�c�r,�4/usr/lib/python3/dist-packages/trac/admin/console.pyr8s
�zTracAdmin.__init__cCsdS�Nr,�r(r,r,r-�	emptylineCszTracAdmin.emptylinecCsXt|t�r|jr
tjj}nt�}t||�}|jr|�dd�}zt	j
�||�p'd}Wn{ty1�t
ya}z%ttdt|�d��|jrUt�|�|j	pS|�|�d�d}WYd}~nHd}~wtyz}ztt|��d}WYd}~n/d}~wty�}ztt|��d}|��r�|jj�d|t|d	d
��WYd}~nd}~ww|js�|SdS)z)`line` may be a `bytes` or a `str` object�\z\\rzError: %(msg)s��msg�Nz%Exception in trac-admin command: %r%sT��	traceback)�
isinstance�bytesr#�sys�stdin�encodingrrr!rr�onecmd�
SystemExitrrr�
show_usage�print�do_help�arg_tokenizerr
�	Exception�	env_check�env�log�error)r(�liner;�rv�er,r,r-r<FsF


��

����zTracAdmin.onecmdcCs$d|_ttdtdd��|��dS)NTz�Welcome to trac-admin %(version)s
Interactive Trac administration console.
Copyright (C) %(year)s Edgewall Software

Type:  '?' or 'help' for help on commands.
        z	2003-2021)r�year)r#rr�TRAC_VERSION�cmdloopr/r,r,r-�rungs
�z
TracAdmin.runcCs(||_d|j|_|dur||_dSdS)NzTrac [%s]> )�envname�prompt�_TracAdmin__env)r(rNrDr,r,r-r$ss

�zTracAdmin.env_setcCs.|jsz|��WdStyYdSwdS)NFT)rP�	_init_envrBr/r,r,r-rCys
��zTracAdmin.env_checkc
Csh|js1z|��W|jSty0}zttdt|dd�d��t�d�WYd}~|jSd}~ww|jS)Nz#Failed to open environment: %(err)sTr5��err�)rPrQrBrrr
r9�exit)r(rIr,r,r-rD�s
�
���z
TracAdmin.envcCs6t|j�|_}trt|�}|rt�|�dSdSdSr.)r	rNrPrrr
�activate)r(rD�
negotiatedr,r,r-rQ�s�zTracAdmin._init_envcCs
t|j�Sr.)rrDr/r,r,r-�cmd_mgr�s
zTracAdmin.cmd_mgrcCs6t|dd�}d|_d|_tjdkrd|_t|�pdgS)NT)�posixr�nt)r�whitespace_split�
commentersr%�name�escape�list)r(�argstr�lexr,r,r-rA�s
zTracAdmin.arg_tokenizecs6t�fdd�|D��}t|�dkr|dd7<|S)Ncsh|]	}|���r|�qSr,��
startswith)�.0�a��textr,r-�	<setcomp>�sz*TracAdmin.word_complete.<locals>.<setcomp>rTr� )r_�len)r(rg�wordsr,rfr-�
word_complete�szTracAdmin.word_completecCst�d|�}dd�|D�S)Nz(?m)(?:^[ \t]*\n)+cSsg|]}t�dd|����qS)z(?m)\s+ri)�re�sub�strip)rd�eachr,r,r-�
<listcomp>�sz-TracAdmin.split_help_text.<locals>.<listcomp>)rm�split)rg�
paragraphsr,r,r-�split_help_text�szTracAdmin.split_help_textFc
Cs|durtj}dd�|D�}|sdS|r:tdd�|D��}|D]\}}}|�|�}	t|d|�|�|	df�qdS|D]A\}}}|�|�}	t|d||f�t|d|	d�|s`t|�d	kr}t|	�d	kr}|	d	d�D]}
t|tj|
d
ddd�d
�qlq<dS)NcSsg|]}|dr|�qS)r4r,�rd�docr,r,r-rq�sz'TracAdmin.print_doc.<locals>.<listcomp>css�|]	}t|d�VqdS)rN)rjrur,r,r-�	<genexpr>�s�z&TracAdmin.print_doc.<locals>.<genexpr>z%s  %srz%s %s
z    %s
rT�O�    )�initial_indent�subsequent_indent�
)	r9�stdout�maxrtr�ljustrj�textwrap�fill)�cls�docs�stream�short�long�max_lenr�argsrvrs�	paragraphr,r,r-�	print_doc�s:

��
�����zTracAdmin.print_docc
Cs�|�|�}|r|ddkr|�d�g}|��rMz	|j�||�}Wn+tyL}zt�ttdt|�d��|j	j
�dt|dd��WYd}~nd}~wwt|�d	kr_|�
d
d�|��D��z|�|�WStyt|�||�YSw)N���rirzCompletion error: %(err)srRztrac-admin completion error: %sTr5rTcss&�|]}|�d�r|dd�VqdS)�do_�Nrb)rdr]r,r,r-rw�s��z*TracAdmin.complete_line.<locals>.<genexpr>)rA�appendrCrX�complete_commandrBrrr
rDrErFrj�extend�	get_names�complete�AttributeErrorrl)r(rgrG�cmd_onlyr��comprIr,r,r-�
complete_line�s0

�

����zTracAdmin.complete_linecCs|�||d�S)NT�r��r(rgrG�begidx�endidxr,r,r-�
completenames��zTracAdmin.completenamescCs|�||�Sr.r�r�r,r,r-�completedefault�szTracAdmin.completedefaultc
Cs�z|js|��|jdur|j��|_Wn%ty'}ztt|��|�d}~wty9}ztt|��|�d}~ww|�|�}|ddkrId|_n|jrUtt	d|j
d���|jj|�S)Nr�upgradezPThe Trac Environment needs to be upgraded. Run:

  trac-admin "%(path)s" upgrade�r&)
rPrQ�
needs_upgraderrrrBr
rArrNrX�execute_command)r(rGrIr�r,r,r-�default�s*
����
�zTracAdmin.default)�helprzShow documentationcCs*|j|j}|dur|�t|����|Sr.)�
_help_help�
_help_initenvr�r�get_command_help)r�rDr�r,r,r-�all_docs�szTracAdmin.all_docscCs|�||dd�d�S)N�Tr�r�r,r,r-�
complete_helpszTracAdmin.complete_helpcCs$|�|�}|drcd}t|d|dd�}|dur%|��r%|j}|�|�}|r.|�|�dSttdd�|�d��d}|rD|�	|d�}|r_t
d�t
tddt|���|D]
}t
d	|�qVdSdSt
td
t
d��|js}t�t
td��t
td
��|��r�|jnd}|j|�|�dd�dS)Nr�_help_zMNo documentation found for '%(cmd)s'. Use 'help' to see the list of commands.ri)rrzDid you mean this?zDid you mean one of these?ryz8trac-admin - The Trac Administration Console %(version)s)rzIUsage: trac-admin </path/to/projenv> [command [subcommand] [option ...]]
z=Invoking trac-admin without command starts interactive mode.
T)r�)rA�getattrrCrXr�r�rr�join�get_similar_commandsrrrjrKr#r?rDr�)r(rG�argrXrv�cmdsrrDr,r,r-r@sD

����zTracAdmin.do_help)�quitrzExit the programcCst�t��dSr.)r?r9rU�r(rGr,r,r-�do_quit0szTracAdmin.do_quit)�initenvz[<projectname> <db>]a�Create and initialize a new environment

         If no arguments are given, then the required parameters are requested
         interactively unless the optional argument `--config` is specified.

         One or more optional arguments --inherit=PATH can be used to specify
         the "[inherit] file" option at environment creation time, so that only
         the options not already specified in one of the global configuration
         files are written to the conf/trac.ini file of the newly created
         environment. Relative paths are resolved relative to the "conf"
         directory of the new environment.

         The optional argument --config=PATH can be used to specify a
         configuration file that is used to populate the environment
         configuration. The arguments <projectname>, <db> and any other
         arguments passed in the invocation are optional, but if specified
         will override values in the configuration file.
         cCs|�|�dSr.)�
do_initenvr�r,r,r-�	do_initdbMr�zTracAdmin.do_initdbcCsng}ttd��d}|�ttd|d����p|�ttd��d}td|d�}|�t|���p0|�t�|S)Nz�
Trac will first ask a few questions about your environment
in order to initialize and prepare the project database.

 Please enter the name of your project.
 This name will be used in page titles and descriptions.
z
My ProjectzProject Name [%(default)s]> )r�a
 Please specify the connection string for the database. By default,
 a local SQLite database is created in the environment directory.
 It is also possible to use an existing MySQL or PostgreSQL database
 (check the Trac documentation for the connection string syntax).
zsqlite:db/trac.dbz*Database connection string [%(default)s]> )rrr�rror?)r(�
returnvals�dp�ddbrOr,r,r-�get_initenv_argsPs 
���zTracAdmin.get_initenv_argsc
s�fdd�}���r|td��dSttd�jd����|�}g}d}d}d}|t|�kri||}|�d	�rD|�|�|�d
d��n|�d�rS|�|�dd�}n|d
kr_|�|�d}n|d7}|t|�ks.d}	|r�t	j
�|�s}|td|d��dSzt|�}	Wnt
y�}
z||
�WYd}
~
dSd}
~
ww|p�dg}t|�dkr�|ds�|	s����\}}n*t|�dkr�|	r�d}}|dr�|d}nt|�dkr�|\}}n
|dt|��dSg}
|	r�|	jdd�D]�|
��fdd�|	���D��q�|du�r|
�dd|f�|du�r|
�dd|f�|�r!|
�ddd�|�f�zt�jd|
|d��_Wn=t
�yE}
z||
�WYd}
~
dSd}
~
wt�yj}
z|td��t|
�t��t�d�WYd}
~
nd}
~
wwttd |�jt	j
��j��jjd!��dS)"Ncsttd�jd�d|�dS)NzInitenv for '%(env)s' failed.)rDz
%s)rrrNr2r/r,r-�
initenv_erroris�z+TracAdmin.do_initenv.<locals>.initenv_errorz"Does an environment already exist?r4z.Creating a new Trac environment at %(envname)s)rNTrz
--inherit=�
z	--config=�	z--no-default-dataFrTzEThe file specified in the --config argument does not exist: %(path)s.r�rzWrong number of arguments: %d)�defaultsc3s�|]
\}}�||fVqdSr.r,)rd�option�value)�sectionr,r-rw�s��z'TracAdmin.do_initenv.<locals>.<genexpr>�projectr]�trac�database�inherit�filez,
      )�create�options�default_datazFailed to create environment.a
Project environment for '%(project_name)s' created.

You may configure the environment by editing the file:

  %(config_path)s

You can run the Trac standalone web server `tracd` and point
your browser to http://localhost:8000/%(project_dir)s.

  tracd --port 8000 %(project_path)s

Navigate to "Help/Guide" to browse the documentation for Trac,
including information on further setup (such as deploying Trac
to a real web server).

The latest documentation can also be found on the project
website:

  https://trac.edgewall.org/
)�project_name�project_path�project_dir�config_path)rCrrrNrArjrcr��popr%r&�existsrrr��sectionsr�r�r�r	rPrBrr6�	print_excr9rU�basename�config_file_path)r(rGr�r��
inherit_pathsr�r��i�item�configrIr��db_strr�r,)r�r(r-r�hs��



����
�

�

�
�����zTracAdmin.do_initenvr.)NFF)F)-�__name__�
__module__�__qualname__�introrK�
doc_header�rulerrOrNrPr�rr0r<rMr$rC�propertyrDrQrXrArl�staticmethodrt�classmethodr�r�r�r�r�r�r�r�r@�
_help_quit�
_help_exit�	_help_EOFr��do_exit�do_EOFr�r�r�r�r,r,r,r-r-s^�
!







%�rc@s"eZdZdZed�Zddd�ZdS)�TracAdminHelpMacro�messagesa3
    Display help for trac-admin commands.

    Examples:
    {{{
    [[TracAdminHelp]]               # all commands
    [[TracAdminHelp(wiki)]]         # all wiki commands
    [[TracAdminHelp(wiki export)]]  # the "wiki export" command
    [[TracAdminHelp(upgrade)]]      # the upgrade command
    }}}
    Nc	Cs�|r+|����}ttd|dd�}|dur t|j�}|�|�}|s*ttd|d���nt�	|j�}t
��}tj||dd�t
j|��dd�S)	Nr�rz(Unknown trac-admin command "%(command)s")�commandT)r��wiki)�class_)rorrr�rrrDr�rrr��io�StringIOr�r�pre�getvalue)	r(�	formatterr]�contentr�r�rvrX�bufr,r,r-�expand_macro�s

��zTracAdminHelpMacro.expand_macror.)r�r�r��_domainr�_descriptionr�r,r,r,r-r��sr�csdd���fdd�|D�S)NcSs&|��r|Sd�dd�|�d�D��S)Nz"'"css�|]}d|VqdS)z'%s'Nr,)rd�vr,r,r-rw�s�z-_quote_args.<locals>.quote.<locals>.<genexpr>�')�isalnumr�rr)r�r,r,r-�quote�sz_quote_args.<locals>.quotecsg|]}�|��qSr,r,)rdr��r�r,r-rq�sz_quote_args.<locals>.<listcomp>r,�r�r,r�r-�_quote_args�sr�c	Cs�|durtjdd�}t�}|rq|ddvr'|�d�tdg|dd����S|ddvr;ttj�	tjd�t
�dS|�tj�|d��t
|�dkrZ|�d�t|dd����S	z|��Wntyo|�d�Ynwq[|�d�S)	NrTr)z-hz--helpr�rir�)z-vz	--versionTr)r9�argvrr<r�r�rr%r&r�rKr$r'rjrM�KeyboardInterruptr�)r��adminr,r,r-�_run�s&"��
r�cCs*t�t��z	t|�Wt��St��w)zMain entry point.)r
rVrr��
deactivater�r,r,r-rMsrM�__main__zTrac==%sr.)6rr�r%�
pkg_resourcesrmr9r�r6rr�ImportErrorr�rrK�trac.admin.apirrr�trac.configr�	trac.corer�trac.envr	�	trac.utilr
�trac.util.htmlr�trac.util.textrr
rrrrr�trac.util.translationrrrr�trac.wiki.formatterr�trac.wiki.macrosrrrr�r�r�rMr��requirerUr,r,r,r-�<module>sJ�$&
	�

https://t.me/RX1948 - 2025