HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/trac/util/__pycache__/__init__.cpython-310.pyc
o

�k�`��@s(ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddlZddlZddlZddlZddlmZmZmZmZddlmZmZmZmZmZd�dd�Zd�dd�Z ej!dkr|dd	l"m#Z#nddl$Z$d
d�Z#ze%Z%Wne&y�Gdd
�d
e'�Z%Ynwdd�Z(e
�)dd�*e+dd�e,e-e.d����d�Z/dd�Z0dZ1ej!dk�rdd�Z2dd�Z3z-ddl4Z4dZ5dZ6e4j7j8j9Z:dd�Z2e4j7j;j<Z<e4j7j;j=Z=e4j7j8j>Z?e4j7j8j@Z@dZ1d d!�Z3Wn	eAy�Ynwd"d#�ZBnejBZBdZ1Gd$d%�d%eC�ZDd�d)d*�ZEd�d,d-�ZFd.d/�ZGej!dk�r*d0d1�ZHnd2d1�ZHd3d4�ZI		d�d5d6�ZJd7d8�ZKGd9d:�d:eC�ZLd;d<�ZMd�d=d>�ZNdgdfd?d@�ZOdAdB�ZPGdCdD�dDeC�ZQdEdF�ZRdGdH�ZSdIdJ�ZTe
�)dK�ZUd�dLdM�ZVdNdO�ZWdPdQ�ZXdRdS�ZYdTdU�ZZe[gdV��Z\dWdX�Z]dYdZ�Z^d[d\�Z_d]d^�Z`d_d`�Zaz
e�bda�ejbZbWnec�y�e	�d�Zedbdc�ZbYnwd�dedf�Zfd�dhdi�Zgd�dkdl�ZhGdmdn�dneC�Zidodp�ZjGdqdr�dreC�Zke
�)ds�Zldtdu�Zmd�dvdw�Zndxdy�Zod�dzd{�Zpd�d|d}�Zqd�d~d�Zrd�d��Zsd�d�d��Ztd�d��Zud�ZvdS)��N)�time_now�to_datetime�to_timestamp�utc)�exception_to_unicode�getpreferredencoding�stripws�
to_unicode�to_utf8cCs^|jr|jS|r|j�|�}|r|S|j�d�}|j�d�}|r(|r(d||fS|p.|p.|jS)a�Get most informative "reporter" identity out of a request.

    That's the `Request`'s authname if not 'anonymous', or a `Request`
    argument, or the session name and e-mail, or only the name or only
    the e-mail, or 'anonymous' as last resort.

    :param req: a `trac.web.api.Request`
    :param arg_name: if given, a `Request` argument which may contain
      the id for non-authentified users
    �name�emailz%s <%s>)�is_authenticated�authname�args�get�session)�req�arg_name�rrr�r�4/usr/lib/python3/dist-packages/trac/util/__init__.py�get_reporter_id-srcCsL|pd}|dur$t|t�r|�d�}|r|d7}|dtjj|dd�7}|S)z7Generate a properly escaped Content-Disposition header.�N�utf-8z; z	filename=)�safe)�
isinstance�str�encode�urllib�parse�quote)�type�filenamerrr�content_dispositionEs

r#�nt)�getusercCs*z
t�t���dWStyYdSw)z*Retrieve the identity of the process ownerr�unknown)�pwd�getpwuid�os�geteuid�KeyErrorrrrrr%Ws
�r%c@seZdZdZdS)�WindowsErrorz?Dummy exception replacing WindowsError on non-Windows platformsN)�__name__�
__module__�__qualname__�__doc__rrrrr,asr,cCs�|ritjdkr1t|�dkr|ddksd|vr/|�dd�}|ddkr/d|d|dd�}|Stjd	kri|ddkrct|�dksNt|�dkr[|ddkr[|dd|dd�}nd
|dd�}|�dd�}|S)aConverts a Windows-style or POSIX-style path to the native style.

    i.e. on Windows, convert POSIX path to Windows path, and in a
    POSIX system, convert Windows path to POSIX path.

    :param path: the input path
    :return: the path converted to native style
    �posix��:�\�/r�Nr$zC:\)r)r�len�replace��pathrrr�native_pathds	
 

�$r;�[rcCst�|�dkS)N�Cc)�unicodedata�category)�crrr�<lambda>�srAi�]cCsdt|t�s
t|d�}t�d|�}t�d|�}|�d�s!t�d|�r'|�	dd�}t
�|�}t|�}|S)Nr�NFC� r4z[A-Za-z]:\\r5)
rrr>�	normalize�_control_codes_re�sub�
startswith�re�matchr8�	posixpath�basenamer)�filepathr"rrr�normalize_filename�s


rNFcC�dS�NFr��src�dstrrrrA��cCrOrPrrQrrrrA�rTr2�cCsNt|t�st|t���}t|t�st|t���}t||�rdSt||ttB�S)NT)rr�sys�getfilesystemencoding�_rename_atomic�
MoveFileEx�MOVEFILE_REPLACE_EXISTING�MOVEFILE_WRITE_THROUGHrQrrr�_rename�s


�r\TcCsTtddddddd�}|dkrdSzt||ddttB|�ot|�Wt|�St|�w)Nri'zTrac rename���F)�CreateTransaction�MoveFileTransactedrZr[�CommitTransaction�CloseHandle)rRrS�tarrrrX�s
���rXcCs�t||�rdSz	t�||�WdStyX}z<|jtjkr�d|t�dd�f}t�||�t�||�zt�|�Wn	t	yEYnwWYd}~dSWYd}~dSd}~ww)Nz%s-%08xrl��)
r\r)�rename�OSError�errno�EEXIST�random�randint�unlink�	Exception)rRrS�e�oldrrrrc�s&
����rcc@sZeZdZdZ		ddd�Zdd	�Zd
d�Zdd
�ZeZeZ	dd�Z
dd�Zedd��Z
dS)�
AtomicFileaDA file that appears atomically with its full content.

    This file-like object writes to a temporary file in the same directory
    as the final file. If the file is committed, the temporary file is renamed
    atomically (on Unix, at least) to its final name. If it is rolled back,
    the temporary file is removed.
    �wr]r�strictcCs�d|_tj�|�|_tj�|j�\}}tj|d|d�\}|_d|vr%in||d�}	tj	|||fi|	��|_z9t�
|j�}
ttd�rJt�|j|
j
�ttd�r\t|
d�r\t�|j|
j�ttd�rmt�|jd	|
j�WdSWdStyyYdSw)
N�-)�prefix�dir�b��encoding�errors�chmod�chflags�st_flags�chownr])�_filer)r:�realpath�_path�split�tempfile�mkstemp�_temp�fdopen�stat�hasattrrw�st_moderxryrz�st_gidrd)�selfr:�mode�bufsizerurvrrr�fd�kwargs�strrr�__init__�s(�

��zAtomicFile.__init__cCst|j|�S�N)�getattrr{)r�rrrr�__getattr__��zAtomicFile.__getattr__cCsV|jdurdSz|jd}|_|��t|j|j�WdSty*t�|j��wr�)r{�closercr�r}rjr)ri�r��frrr�commit�s
�zAtomicFile.commitcCst|jdurdSz |jd}|_|��Wz	t�|j�WdSty'YdSwzt�|j�Wwty9Ywwr�)r{r�r)rir�rjr�rrr�rollbacks

���zAtomicFile.rollbackcCs|Sr�r�r�rrr�	__enter__szAtomicFile.__enter__cCs|��dSr�)r�)r��exc_type�	exc_value�	tracebackrrr�__exit__r�zAtomicFile.__exit__cCs|jdup|jjSr�)r{�closedr�rrrrAszAtomicFile.<lambda>N)rnr]rro)r-r.r/r0r�r�r�r�r��__del__r�r��propertyr�rrrrrm�s
�rmrrrocCsTd|vrin||d�}t||fi|���}|��Wd�S1s#wYdS)z#Read a file and return its content.rsrtN)�open�read)r:r�rurvr�r�rrr�	read_files$�r�rncCs�d|vrin||d�}t||fi|���-}|r1t|ttf�r$|�|�n|�|�Wd�dSWd�dSWd�dS1sDwYdS)zVCreate a new file with the given data.

    :data: string or iterable of strings.
    rsrtN)r�rr�bytes�write�
writelines)r:�datar�rurvr�r�rrr�create_file!s��"�r�c
Cs�tj�|�}tjtjtj}ttd�r|tj7}d}	z|t�t�	||d�d�fWSt
y\}z&|jtjkr9�|d7}|dkrGt
d|��d|d||df}WYd	}~nd	}~wwq)
z7Create a new file. An index is added if the path exists�O_BINARYr2i��wb�dzFailed to create unique name: z%s.%d%srN)r)r:�splitext�O_CREAT�O_WRONLY�O_EXCLr�r�r�r�rdrerfrj)r:�parts�flags�idxrkrrr�create_unique_file/s$

"���r�cCs\t|d��}t�|���}|j}|�|d�|�|�Wd�dS1s'wYdS)�OUpdate modified time of the given file. The file is created if
        missing.�abr2N)r�r)�fstat�fileno�st_size�truncate)r"r�r��sizerrr�
touch_fileDs"�r�cCstz	t�|d�WdSty9}z$|jtjkr-t|d��Wd�n1s'wYn�WYd}~dSd}~ww)r�Nr�)r)�utimerdre�ENOENTr�)r"rkrrrr�Qs����c
Cs|zt|jj|�\}}|��t�|jj|�Wnty4}z|j�dt	|��WYd}~dSd}~ww|j�
d|�dS)Nz/Couldn't save backup of configuration file (%s)z(Saved backup of configuration file in %s)r��configr"r��shutil�copyfile�IOError�log�warningr�info)�env�suffix�backupr�rkrrr�backup_config_file^s���r�c
Cs�t��}||_|dur)t|t�}|��dd�|_|jt�	ddddt
|��7_|rG|j�d�s8|jd7_tj|_
d|_|jd	O_ntj|_
d
|_|rW|jdO_|rdtj|_
|jdO_|rst|t�rp|�d
�n||_|S)aXCreate a instance of `ZipInfo`.

    :param filename: file name of the entry
    :param mtime: modified time of the entry
    :param dir: if `True`, the entry is a directory
    :param executable: if `True`, the entry is a executable file
    :param symlink: if `True`, the entry is a symbolic link
    :param comment: comment of the entry
    N�z<hhBliUT�r2r5i�A�i�i�l@r)�zipfile�ZipInfor"rr�utctimetuple�	date_time�extra�struct�packr�endswith�
ZIP_STORED�
compress_type�
external_attr�ZIP_DEFLATEDrrr�comment)r"�mtimerr�
executable�symlinkr��zipinforrr�create_zipinfojs>

���r�cCs�t�|��A}|��D]3}|�d�rq
|�d�}|�|�}tjj|g|�R�}tj�	|�}tj�
|�s7t�|�t||d�q
Wd�dS1sIwYdS)Nr5r�)
r��ZipFile�namelistr�r~r�r)r:�join�dirname�isdir�makedirsr�)�srcfile�destdir�zip�entry�names�contentr"r�rrr�extract_zipfile�s



�"�r�c@seZdZdZddd�ZdS)�
NaivePopenaThis is a deadlock-safe version of popen that returns an object with
    errorlevel, out (a string) and err (a string).

    The optional `input`, which must be a `str` object, is first written
    to a temporary file from which the process will read.

    (`capturestderr` may not work under Windows 9x.)

    Example::

      print(Popen3('grep spam','\n\nhere spam\n\n').out)
    Nc	CsTt��}d||f}|dur2t��}t|d��
}|�|�Wd�n1s'wY|d|}|r>t��}|d|}zCd|_t�|�d?|_t|�|_	|rVt|�|_Wtj
�|�rbt�|�|rotj
�|�rot�|�|r~tj
�|�r�t�|�dSdSdStj
�|�r�t�|�|r�tj
�|�r�t�|�|r�tj
�|�r�t�|�www)Nz( %s ) > %sr�z <z 2>rU)
r�mktempr�r��errr)�system�
errorlevelr��outr:�isfile�remove)r��command�input�
capturestderr�outfile�infile�tmp�errfilerrrr��s@�

�

��

�zNaivePopen.__init__�NN)r-r.r/r0r�rrrrr��sr�csBt|t�r|n|j��fdd�}�fdd�}tjdkr|�S|�S)aTerminate the process.

    If the process has already finished and has not been waited for,
    the function does not raise OSError and WindowsError exceptions unlike
    a terminate method of `subprocess.Popen`.

    :param process: the integer id (`pid`) of the process.
    cs@ddl}d}|jj�|d��}|jj�|d�|jj�|�dS)Nrr2Fr])�ctypes�windll�kernel32�OpenProcess�TerminateProcessra)r��PROCESS_TERMINATE�handle��pidrr�
terminate_win�s
�z terminate.<locals>.terminate_winc
sRddl}z
t��|j�WdSty(}z|jtjkr�WYd}~dSd}~ww)Nr)�signalr)�kill�SIGTERMrdre�ESRCH)rrkrrr�
terminate_nix�s���z terminate.<locals>.terminate_nix�win32)r�intrrV�platform)�processrrrrr�	terminate�s


r
cCs"|r
tj�|�r
dSt�|�dS)z�Create as many directories as necessary to make `path` exist.

    If `overwrite` is `True`, don't raise an exception in case `path`
    already exists.
    N)r)r:�existsr�)r:�	overwriterrrr��sr�csPdd���fdd���fdd��D�������fdd����|��|��d	S)
z�Recursively copy a directory tree using copy2() (from shutil.copytree.)

    Added a `skip` parameter consisting of absolute paths
    which we don't want to copy.
    cSs"t|t�r|�t��p
t��}|Sr�)rrrrVrWrr9rrr�str_path
s

�zcopytree.<locals>.str_pathcs&�rtj�|�rt�|�dSdSdSr�)r)r:rrir9�rrr�remove_if_overwritings�z'copytree.<locals>.remove_if_overwritingcsg|]}�|��qSrr)�.0r�)rrr�
<listcomp>�zcopytree.<locals>.<listcomp>c
s�t�|�}t|�d�g}|D]}}tj�||�}|�vrqtj�||�}z0�r=tj�|�r=�|�t�|�}t�||�ntj�|�rI�||�n
�|�t	�
||�Wqttfyr}z|�
||t|�f�WYd}~qd}~wt	jy�}	z|�|	jd�WYd}	~	qd}	~	wwzt	�||�Wn$ty�Ynty�}z|�
||t|�f�WYd}~nd}~ww|r�t	�|��dS)Nrr)r)�listdirr�r:r��islink�readlinkr�r�r��copy2r�rd�appendr�Error�extendr�copystatr,)
rRrSr�rvr�srcname�dstname�linkto�whyr�)�copytree_recrr�skip�symlinksrrr"sH

� ��� ��
�zcopytree.<locals>.copytree_recNr)rRrSr$r#rr)r"rrr#rr$r�copytrees
"r%cCs0dd�}||�}||�}||kp|�|tj�S)z]Return True iff `path` is equal to parent or is located below `parent`
    at any level.
    cSstj�tj�|��Sr�)r)r:�normcase�abspathr9rrrrE>sz is_path_below.<locals>.normalize)rHr)�sep)r:�parentrErrr�
is_path_below:sr*c@s2eZdZdZdZ		d
dd�Zd	d
�Zdd�ZdS)�file_or_stdaContext manager for opening a file or using a standard stream

    If `filename` is non-empty, open the file and close it when exiting the
    block. Otherwise, use `sys.stdin` if opening for reading, or `sys.stdout`
    if opening for writing or appending.Nrr]rrocCs"||_||_||_||_||_dSr�)r"r�r�rurv)r�r"r�r�rurvrrrr�Ns

zfile_or_std.__init__cCsn|jsd|jvrtjntj}d|jvr|j}|Sd|jvrin|j|jd�}t|j|j|j	fi|��|_
|j
S)Nrrsrt)r"r�rV�stdin�stdout�bufferrurvr�r��file)r�r�r�rrrr�Vs
�zfile_or_std.__enter__cCs|jdur|j��dSdSr�)r/r�)r��et�ev�tbrrrr�as
�zfile_or_std.__exit__)rr]rro)r-r.r/r0r/r�r�r�rrrrr+Es
�r+cCs.t|�}|j|j}}|dkr|Sd||fS)z6Return the fully qualified class name of given object.�__builtin__z%s.%s)r!r.r-)�objr@�m�nrrr�
fq_class_namehsr7cCs|jjtt|dd��S)z`Return the number of arguments expected by the given function, unbound
    or bound method.
    �__self__F)�__code__�co_argcount�boolr�)r�rrr�arityosr<cCs$ddl}t��}|j|d�|��S)z.Retrieve the last traceback as a `str` string.rN)r/)r��io�StringIO�	print_exc�getvalue)r�r2rrr�get_last_tracebackvsrAzbuild/bdist\.[^/]+/egg/(.*)c	shg}t�|�}|r=tjD]0}z%t�|d��}|�|�d����}	Wd�Wn1s-wYWqt	y<Yqw|sNddl
}|�|�|�||�}d|kr[t
|�ks^dSdStd||�}	|d|}
d�t�d�}|dd�D]}|�|�}|r�|�d��nqx�fdd	�||	|�D�}
t||�d
���}�fdd	�||d|
�D�}|
||fS)z�Return `content` number of lines before and after the specified
    `lineno` from the (source code) file identified by `filename`.

    Returns a `(lines_before, line, lines_after)` tuple.
    rr2Nr)rNrzcoding[=:]\s*([-\w.]+)r6c�g|]
}t|�d����qS��
�r	�rstrip�r�l��charsetrrr���z'get_lines_from_file.<locals>.<listcomp>rDcrBrCrErGrIrrr�rK)�_egg_path_rerJrVr:r�r�r��group�
splitlinesrj�	linecache�
checkcache�getlinesr7�maxrI�compile�searchr	rF)r"�lineno�context�globals�linesrJr:r�rO�lbound�ubound�rep�linestr�before�line�afterrrIr�get_lines_from_filesL	

&��
�


�

�
�
r`cCs�g}|rP|jj�d�}|dvr|dd�=|dd�}|sK|jjj}|�dd�}|jd}t||d|jj�\}}}|�	|||||||jjj
|jjd	��|j}|s|S)
z)Return frame information for a traceback.�__traceback_hide__)r]�before_and_thisNr�r4r5r2r�)r�r"rUr^�lines_before�lines_after�function�vars)�tb_frame�f_localsr�f_code�co_filenamer8�	tb_linenor`�	f_globalsr�co_name�tb_next)r2�frames�tb_hider"rUr]r^r_rrr�get_frame_info�s,



���rqc
CsTtj��}zt�|�WSty)}ztj��D]
}||vr"tj|=q|�d}~ww)z�
    Safe imports: rollback after a failed import.

    Initially inspired from the RollbackImporter in PyUnit,
    but it's now much simpler and works better for our needs.

    See http://pyunit.sourceforge.net/notes/reloading.html
    N)rV�modules�copy�	importlib�
import_modulerj)�module_name�already_importedrk�modnamerrr�safe__import__�s
	���ryc
CsNztt|��WSty&}zdt|�t|�t|�fWYd}~Sd}~ww)z�`repr` replacement which "never" breaks.

    Make sure we always get a representation of the input `x`
    without risking to trigger an exception (e.g. from a buggy
    `x.__repr__`).

    .. versionadded :: 1.0
    z&<%s object at 0x%X (repr() error: %s)>N)r	�reprrjr7�idr)�xrkrrr�	safe_repr�s	���r}cCsN|j}|sdSt|��dd�}|d�dd�}t|�dkr!|dnd}||fS)z�Return the docstring of an object as a tuple `(summary, description)`,
    where `summary` is the first paragraph and `description` is the remaining
    text.
    r�z

r2rrDrDN)r0r	r~r8r7)r4�doc�summary�descriptionrrr�get_doc�sr�)�__file__r-�__package__cCs4t�|�}|�dd�|j��D��|�dd�dS)z�Import the namespace of a module into a globals dict.

    This function is used in stub modules to import all symbols defined in
    another module into the global namespace of the stub, usually for
    backward compatibility.
    css �|]}|dtvr|VqdS�rN)�_dont_import�r�itemrrr�	<genexpr>�s���z#import_namespace.<locals>.<genexpr>�import_namespaceN)rtru�update�__dict__�items�pop)�globals_dictrv�modulerrrr��s
r�cCs�|j}|j}|�d�r|dd�}tj�|�dkrtj�|�}tj�|�d}|�tj	d��|�rRtj�|�}d�
|�d�dd��}|sH	|S|�tj	d��|�s1|S)z6Return the base path the given module is imported from)z.pycz.pyoNr]�__init__.pyr�.)r�r-r�r)r:rLr�r�r8r(r�r~)r�r:rv�	base_pathrrr�get_module_paths
�r�c	s�i}tj|dd�D]Z���d�sq	��d��dd��D����d�r3|���fdd���d�D��q	��d	�rct���d	���}t�	|�}|���fd
d�|D��Wd�n1s]wYq	q	|S)zgReturn a dictionary mapping Python module source paths to the
    distributions that contain them.
    T��only�
top_level.txtcSsg|]}|d�qS)r5r�r�toprrrr rzget_sources.<locals>.<listcomp>�SOURCES.txtc3s.�|]�t�fdd��D��r��fVqdS)c3s�|]}��|�VqdSr��rHr��rRrrr�$s��(get_sources.<locals>.<genexpr>.<genexpr>N��any�r��dist�	toplevelsr�rr�"s
��zget_sources.<locals>.<genexpr>�RECORDc3s2�|]�t�fdd��D��r�d�fVqdS)c3s�|]
}�d�|�VqdSr�r�r���rowrrr�*s��r�rNr�r�r�r�rr�)s���N)
�
pkg_resources�find_distributions�has_metadata�get_metadata_linesr�r=r>�get_metadata�csv�reader)r:�sourcesr�r�rr�r�get_sourcess*


�


���r�c
s�ddl�ddl�ddl}ddlm}�fdd��t||j�r^��fdd�}|}t|�}|j�	dd	�}t
j�|j
�d
vr@|d7}n|d7}tj|d
d�D]}t
j�|�sY||||�r[nqKiSd}i}dd�}	|�d�rmdnd}
z�||
���fdd�|D�D]
}�|||	|�<q~W|Sty�}z|d|
|t|�d�}
|D]}|
||	|�<q�WYd}~|Sd}~w�jjy�}z|d|
|t|�d�}
|D]}|
||	|�<q�WYd}~|Sd}~ww)aaGet a dictionary containing package information for a package

    `dist` can be either a Distribution instance or, as a shortcut,
    directly the module instance, if one can safely infer a Distribution
    instance from it.

    Always returns a dictionary but it will be empty if no Distribution
    instance can be created for the given module.
    rN)�_cs��|�|��Sr�)�message_from_stringr�)r�r)rrr�
parse_pkginfo?�z"get_pkginfo.<locals>.parse_pkginfoc	s~|j�d�r|���S|�d�r&tj�d���t�fdd�|�d�D��S|�d�r?tj����t�fdd�|�d�D��S|�d�rlt	�
|�d���}t�
|�}t�fd	d�|D��Wd�S1sgwY|�d
�r�z&�|d
�}|�dd��|j�d
��t��fdd�tt���D��r�WdSWn
t�jjfy�Ynw��d�d}|�d�r�||�d�vS|j|��kS)Nz.eggzinstalled-files.txtz../c3� �|]}�tj�|�kVqdSr��r)r:�normpath�rr��
resource_namerrr�H���z4get_pkginfo.<locals>.has_resource.<locals>.<genexpr>r�c3r�r�r�r�r�rrr�Mr�r�c3s�|]	}�|dkVqdSr�r)rr�r�rrr�R���PKG-INFO�Providesrr�c3s*�|]}d��d|d���vVqdS)r�Nr2)r�)rr6)r��providesrrr�Xs�"�Tr5rr�)�locationr��has_resourcer�r)r:r�r�r�r=r>r�r�r��get_allr-r~�ranger7r��Errors�MessageError�key�lower)r�r�r�r�r��pkginfo�toplevel)rr�)r�r�r�rr�CsD

�
�

 �


���
z!get_pkginfo.<locals>.has_resourcer�r5)r�z__init__.pycz__init__.pyoz/__init__.pyz.pyTr�)
�authorzauthor-email�
maintainerzmaintainer-email�licensez	home-pagerrr��versioncSs|���dd�S)Nrpr�)r�r8)�attrrrrrEtr�zget_pkginfo.<locals>.normalize�METADATAr�csg|]}|�vr|�qSrr�rr�)r�rrryszget_pkginfo.<locals>.<listcomp>z6Failed to read %(metadata)s file for %(dist)s: %(err)s)�metadatar�r�z7Failed to parse %(metadata)s file for %(dist)s: %(err)s)r�email.errors�types�trac.util.translationr�r�
ModuleTyper�r-r8r)r:rLr�r�r�r�r�r�r	rvr�)r�r�r�r�r��module_pathr��attrsr�rEr�r�rkr�r)rr�r�r�get_pkginfo0sb


��
��
�
���
�
���r�cCs�i}dD]*}t||d�}|r.t|t�r.|dvr&d}|�dd��dd���}nt|�}|||<qt|dd�p:t|dd�}|d	krO|�dd��d
d���|d<|Sd|d<|S)z2Get a dictionary containing metadata for a module.)	r��author_emailr��maintainer_email�	home_page�urlr�r�tracr)r�r�r��$zURL: r��revisionz$Rev$zRev: r)r�rrr8�stripr	)r�r��k�vr�rrr�get_module_metadata�s&�
���r�r�cCs�g}t�d�t��t���d��}t|�|j|kr6|�	t
t����d��|�
|���t|�|j|ksd�|�}t|�|krG|d|�S|S)Nz{}{}r�)�hashlib�sha1�formatr)�getpidrrr7�digest_sizer�r�_entropyrgr�digestr�)r6�result�hasherrrr�urandom�s��
r�� cCs<d�dd�t|dd�D��}t|�|kr|d|�S|S)z2Generate `digits` number of hex digits of entropy.rcss�|]}d|VqdS)z%.2xNr)rr�rrrr��s�zhex_entropy.<locals>.<genexpr>r2r6N)r�r�r7)�digitsr�rrr�hex_entropy�s r�r6cCsd�dd�t|�D��S)z8Returns a string of `length` random letters and numbers.rcss&�|]}t�tjtjd�VqdS)z/.N)rg�choice�string�
ascii_lettersr��rr|rrrr��s��zsalt.<locals>.<genexpr>)r�r�)�lengthrrr�salt�s
�r��$1$c
s8|}|}t���t|�}t|�}t��||�}t��|�����|�t�fdd�tt���D����fdd�}|�t|���|���td�D]:}t��}|d@r\|���n|���|drj|�|�|drs|���|d@r}|���n|���|���qL�fd	d
�}	||dtt|	���d�S)
z�Based on FreeBSD src/lib/libcrypt/crypt.c 1.2

    :param password: the plain text password to crypt
    :param salt: the raw salt
    :param magic: our magic string
    c3s�|]	}�|dVqdS)r�Nr)r�i)�mixinrrr��r�zmd5crypt.<locals>.<genexpr>c3s<�t��}|r|d@rdVn�dV|dL}|sdSdS)Nr2r)r7)r�)�passwordrr�iter_password_or_zero�s�
�z'md5crypt.<locals>.iter_password_or_zeroi�r2��c3s��d}dD]'\}}}�|d>�|d>B�|B}td�D]
}||d@V|dL}qq�d}td	�D]
}||d@V|dL}q5dS)
Ns@./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz))rr��)r2r��
)r6rU�)r��	�)��
r�r�rUr�?r��r6)r�)�value�itoa64�arsr@r�r�)�finalrr�
iter_ito64s� 
�
�zmd5crypt.<locals>.iter_ito64r��ascii)	r
r��md5r�r�r�r�r7r)
r�r��magic�	magic_arg�salt_argr5r�r��m2r
r)r	r�r�r�md5crypt�s4$




rc@s^eZdZdZdZddd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dS)�Rangesu�Holds information about ranges parsed from a string

    :author: Tim Hatch

    >>> x = Ranges("1,2,9-15")
    >>> 1 in x
    True
    >>> 5 in x
    False
    >>> 10 in x
    True
    >>> 16 in x
    False
    >>> [i for i in range(20) if i in x]
    [1, 2, 9, 10, 11, 12, 13, 14, 15]

    Also supports iteration, which makes that last example a bit simpler:

    >>> list(x)
    [1, 2, 9, 10, 11, 12, 13, 14, 15]

    Note that it automatically reduces the list and short-circuits when the
    desired ranges are a relatively small portion of the entire set:

    >>> x = Ranges("99")
    >>> 1 in x # really fast
    False
    >>> x = Ranges("1, 2, 1-2, 2") # reduces this to 1-2
    >>> x.pairs
    [(1, 2)]
    >>> x = Ranges("1-9,2-4") # handle ranges that completely overlap
    >>> list(x)
    [1, 2, 3, 4, 5, 6, 7, 8, 9]

    The members 'a' and 'b' refer to the min and max value of the range, and
    are None if the range is empty:

    >>> x.a
    1
    >>> x.b
    9
    >>> e = Ranges()
    >>> e.a, e.b
    (None, None)

    Empty ranges are ok, and ranges can be constructed in pieces, if you
    so choose:

    >>> x = Ranges()
    >>> x.appendrange("1, 2, 3")
    >>> x.appendrange("5-9")
    >>> x.appendrange("2-3") # reduce'd away
    >>> list(x)
    [1, 2, 3, 5, 6, 7, 8, 9]

    Reversed ranges are ignored, unless the Ranges has the `reorder` property
    set.

    >>> str(Ranges("20-10"))
    ''
    >>> str(Ranges("20-10", reorder=True))
    '10-20'

    As rendered ranges are often using ',​' (comma + Zero-width
    space) to enable wrapping, we also support reading such ranges, as
    they can be copy/pasted back.

    >>> str(Ranges('1,​3,​5,​6,​7,​9'))
    '1,3,5-7,9'

    u4[0-9]+(?:[-:][0-9]+)?(?:,​?[0-9]+(?:[-:][0-9]+)?)*NFcCs&g|_d|_|_||_|�|�dSr�)�pairsrrs�reorder�appendrange)r�rrrrrr�dszRanges.__init__c	Cs�|sdS|j}t|t�rt�d|�}|D]8}z
tt|�dd��\}}Wnty5t|�t|�}}Ynw||krB|�||f�q|j	rL|�||f�q|�
�dS)z�Add ranges to the current one.

        A range is specified as a string of the form "low-high", and
        `r` can be a list of such strings, a string containing comma-separated
        ranges, or `None`.
        Nu,​?rpr2)rrrrIr~�mapr
�
ValueErrorrr�_reduce)r�r�pr|rrsrrrrjs"
��zRanges.appendrangecCs�|j}|��d}|dt|�krJ||ddd||dkr>||dt||d||dd�f||<||d=n|d7}|dt|�ks|r\|dd|_|dd|_dSd|_|_dS)z5Come up with the minimal representation of the rangesrr2r]N)r�sortr7rRrrs)r�rr�rrrr�s .�zRanges._reduceccs0�|jD]\}}t||d�D]}|VqqdS)z�
        This is another way I came up with to do it.  Is it faster?

        from itertools import chain
        return chain(*[range(a, b+1) for a, b in self.pairs])
        r2N)rr�)r�rrsr�rrr�__iter__�s���zRanges.__iter__cCsd|jdur0|j|kr|jkr0ndS|jD]\}}||kr'|kr(dS||kr/dSqdS)z2
        >>> 55 in Ranges()
        False
        NTF)rrsr)r�r|rrsrrr�__contains__�s$���zRanges.__contains__cCsHg}|jD]\}}||kr|�t|��q|�d||f�qd�|�S)z�Provide a compact string representation of the range.

        >>> (str(Ranges("1,2,3,5")), str(Ranges()), str(Ranges('2')))
        ('1-3,5', '', '2')
        >>> str(Ranges('99-1')) # only nondecreasing ranges allowed
        ''
        �%d-%d�,)rrrr�)r�rrrsrrr�__str__�s
zRanges.__str__cCs0|jdus
|jdurdSt|j|jdtj�S)z�The length of the entire span, ignoring holes.

        >>> (len(Ranges('99')), len(Ranges('1-2')), len(Ranges('')))
        (1, 2, 0)
        Nrr2)rrs�minrV�maxsizer�rrr�__len__�szRanges.__len__cCs|jduo	|jduS)zyReturn True iff the range is not empty.

        >>> (bool(Ranges()), bool(Ranges('1-2')))
        (False, True)
        N)rrsr�rrr�__nonzero__�szRanges.__nonzero__cCs~t�}|j|j|j|_|_|_g|_|jD]%\}}||kr:||kr1|j�||f�||_|S|j�||f�q|S|S)a�Truncate the Ranges by setting a maximal allowed value.

        Note that this `max` can be a value in a gap, so the only guarantee
        is that `self.b` will be lesser than or equal to `max`.

        >>> r = Ranges("10-20,25-45")
        >>> str(r.truncate(30))
        '10-20,25-30'

        >>> str(r.truncate(22))
        '10-20'

        >>> str(r.truncate(10))
        '10'
        )rrrsrrr)r�rRrrrsrrrr��s�zRanges.truncaterP)r-r.r/r0�RE_STRr�rrrrrr"r#r�rrrrrsH
rcstg�d�����fdd�}t|�D]}�dur|��q|�dkr&|�q|�|��q�dur5|�d���S)z�Converts a list of revisions to a minimal set of ranges.

    >>> to_ranges([2, 12, 3, 6, 9, 1, 5, 11])
    '1-3,5-6,9,11-12'
    >>> to_ranges([])
    ''
    Ncs0��kr
��t���dS��d��f�dS)Nr)rrr��begin�end�rangesrr�store�szto_ranges.<locals>.storer2r)�sortedr�)�revsr)�revrr%r�	to_ranges�s


r-c@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)�lazyz3A lazily-evaluated attribute.

    :since: 1.0
    cCs||_t�||�dSr�)�fn�	functools�update_wrapper)r�r/rrrr�sz
lazy.__init__cCsD|dur|S|jj|jvr|j|jjS|�|�}||j|jj<|Sr��r/r-r�)r��instance�ownerr�rrr�__get__s
zlazy.__get__cCs||j|jj<dSr�)r�r/r-)r�r3rrrr�__set__szlazy.__set__cCs"|jj|jvr|j|jj=dSdSr�r2)r�r3rrr�
__delete__ s�zlazy.__delete__N)r-r.r/r0r�r5r6r7rrrrr.
s	r.z(\d+)cCs,t�|�}tt|ddd��|ddd�<|S)zzComparison function for natural order sorting based on
    http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/214202.r2Nr6)�DIGITSr~rr
)�s�piecesrrr�embedded_numbers(s
r;cs\i�|dur|D]}g�|<q|D]
\}}��|g��|�q|dur%�S�fdd�|D�S)z�
    >>> rv = partition([(1, "a"), (2, "b"), (3, "a")])
    >>> rv == {'a': [1, 3], 'b': [2]}
    True
    >>> partition([(1, "a"), (2, "b"), (3, "a")], "ab")
    [[1, 3], [2]]
    Ncsg|]}�|�qSrrr��r�rrr@rzpartition.<locals>.<listcomp>)�
setdefaultr)�iterable�orderr�r�r?rr<r�	partition0s
r@c	Cs\z||�}Wn
ttfy|YSw|dur ||kr ||�}|dur,||kr,||�}|Sr�)�	TypeErrorr)�numeric_typer9�defaultr rRrrrr�_as_numericCs�rDcC�tt||||�S)z�Convert s to an int and limit it to the given range, or return default
    if unsuccessful.

    :since 1.3.6: the default value of the `default` argument is `None`
    )rDr
�r9rCr rRrrr�as_intO�rGcCrE)ztConvert s to a float and limit it to the given range, or return default
    if unsuccessful.

    :since: 1.3.6
    )rD�floatrFrrr�as_floatXrHrJc	Cs~t|t�r,ztt|��WSty+|����}|dvr YdS|dvr'YdS|YSwzt|�WSttfy>|YSw)aSConvert the given value to a `bool`.

    If `value` is a string, return `True` for any of "yes", "true",
    "enabled", "on" or non-zero numbers, ignoring case. For non-string
    arguments, return the argument converted to a `bool`, or `default`
    if the conversion fails.

    :since 1.2: the `default` argument can be specified.
    )�yes�true�enabled�onT)�no�false�disabled�offF)rrr;rIrr�r�rA)rrCrrr�as_boolas 

�
�rScGsd�tddd�|D���S)z=Strip `/` from the arguments and join them with a single `/`.r5Ncss�|]
}|r|�d�VqdS)r5N�r�)r�eachrrrr�~s�zpathjoin.<locals>.<genexpr>)r��filter)rrrr�pathjoin|srWrcCs,|sgSdd�t�||�D�}dd�|D�S)a�Split a string at `sep` and return a list without any empty items.

    >>> to_list('1,2, 3,4 ')
    ['1', '2', '3', '4']
    >>> to_list('1;2; 3;4 ', sep=';')
    ['1', '2', '3', '4']
    >>> to_list('1,2;3 4 ', sep=r'[,;\s]+')
    ['1', '2', '3', '4']
    >>> to_list('')
    []
    >>> to_list(None)
    []
    >>> to_list([])
    []

    :since 1.3.6: the `sep` argument may be a regular expression
    cSsg|]}|���qSrrTr�rrrr�rzto_list.<locals>.<listcomp>cSsg|]}|r|�qSrrr�rrrr�r)rIr~)�
splittabler(r~rrr�to_list�srYcCs0z|�|�}Wn
tyYdSw|||<dS)z`Substitute an item if the item is found in a list, otherwise leave
    the list unmodified.
    N)�indexr)�the_list�item_to_remove�item_to_addrZrrr�sub_val�s�r^zcompat presentation translationr�r�)rrro)rrnrro)NFFFN)Fr�)r�)r6)r�)NNN)r)wr�rer0r�rtr=r)r�rKrgrIr�rVr�r�r�urllib.parserr>r��trac.util.datefmtrrrr�trac.util.textrrrr	r
rr#r�getpassr%r'r,�	NameErrorrdr;rSr�rVr�chrr�rFrN�can_rename_open_filer\rXr�rZr[r�r��MoveFileExWrY�ktmw32r^r`�MoveFileTransactedWr_rarjrc�objectrmr�r�r�r�r�r�r�r�r
r�r%r*r+r7r<rArLr`rqryr}r��	frozensetr�r�r�r�r�r�r��NotImplementedError�Randomr�r�r�rrr-r.r8r;r@rDrGrJrSrWrYr^�
__no_apidoc__rrrr�<module>s�


�����





�

E




�7'
#6#

/X

�



PV