File: //usr/lib/python3/dist-packages/trac/util/__pycache__/__init__.cpython-310.pyc
o
�k�`� � @ s( d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dl Z d dl
Z
d dlZd dlZd dl
Z
d dlZd dlZd dlZd dlZd dlZd dlmZmZmZmZ d dlmZmZmZmZmZ d�dd�Zd�dd�Z ej!dkr|d d l"m#Z# nd dl$Z$d
d� Z#ze%Z%W n e&y� G dd
� d
e'�Z%Y nw dd� Z(e
�)dd�*e+dd� e,e-e.d���� d �Z/dd� Z0dZ1ej!dk�rdd� Z2dd� Z3z-d dl4Z4dZ5dZ6e4j7j8j9Z:dd� Z2e4j7j;j<Z<e4j7j;j=Z=e4j7j8j>Z?e4j7j8j@Z@dZ1d d!� Z3W n eAy� Y nw d"d#� ZBnejBZBdZ1G d$d%� d%eC�ZDd�d)d*�ZEd�d,d-�ZFd.d/� ZGej!dk�r*d0d1� ZHnd2d1� ZHd3d4� ZI d�d5d6�ZJd7d8� ZKG d9d:� d:eC�ZLd;d<� ZMd�d=d>�ZNdg dfd?d@�ZOdAdB� ZPG dCdD� dDeC�ZQdEdF� ZRdGdH� ZSdIdJ� ZTe
�)dK�ZUd�dLdM�ZVdNdO� ZWdPdQ� ZXdRdS� ZYdTdU� ZZe[g dV��Z\dWdX� Z]dYdZ� Z^d[d\� Z_d]d^� Z`d_d`� Zaz
e�bda� ejbZbW n ec�y� e �d� Zedbdc� ZbY nw d�dedf�Zfd�dhdi�Zgd�dkdl�ZhG dmdn� dneC�Zidodp� ZjG dqdr� 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_utf8c C s^ | j r| jS |r| j�|�}|r|S | j�d�}| j�d�}|r(|r(d||f S |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�rr r � r �4/usr/lib/python3/dist-packages/trac/util/__init__.py�get_reporter_id- s r c C sL | 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�filenamer r r �content_dispositionE s
r# �nt)�getuserc C s* z
t �t�� �d W S ty Y dS w )z*Retrieve the identity of the process ownerr �unknown)�pwd�getpwuid�os�geteuid�KeyErrorr r r r r% W s
�r% c @ s e Zd ZdZdS )�WindowsErrorz?Dummy exception replacing WindowsError on non-Windows platformsN)�__name__�
__module__�__qualname__�__doc__r r r r r, a s r, c C s� | rit jdkr1t| �dkr| d dksd| v r/| �dd�} | d dkr/d| d | dd� } | S t jd kri| d dkrct| �dksNt| �dkr[| d dkr[| d d | dd� } nd
| dd� } | �dd�} | S )a Converts 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��pathr r r �native_pathd s
�$r; �[r c C s t �| �dkS )N�Cc)�unicodedata�category)�cr r r �<lambda>� s rA i �]c C sd t | t�s
t| d�} t�d| �} t�d| �} | �d�s!t�d| �r'| � dd�} t
�| �}t|�}|S )Nr �NFC� r4 z[A-Za-z]:\\r5 )
r r r>