관리-도구
편집 파일: transactions.cpython-38.pyc
U �MgW � @ s� d Z ddlZddlmZ er|ddlmZ ddlmZ ddlmZ ddlmZ ddlm Z dd lm Z dd lmZ ddlmZ ddl mZ ed kr�ddlmZ ndZzddlmZ W n ek r� ddlmZ Y nX dd� ZG dd� d�Ze� ZdS )zr Copied from raven-python. Despite being called "legacy" in some places this resolver is very much still in use. � N)� TYPE_CHECKING)�URLResolver)�Dict)�List)�Optional)� URLPattern)�Tuple)�Union)�Pattern)�VERSION)� r )�RoutePattern)�get_resolverc C s, z | j }W n tk r& | jj }Y nX |S )z5Utility method for django's deprecated resolver.regex)�regex�AttributeError�pattern)Zresolver_or_patternr � r �Y/opt/hc_python/lib/python3.8/site-packages/sentry_sdk/integrations/django/transactions.py� get_regex# s r c @ sh e Zd Ze�d�Ze�d�Ze�d�Ze�d�Ze�d�Z e�d�Z i Zdd� Zdd d�Z ddd �Zd S )� RavenResolverz<(?:([^>:]+):)?([^>]+)>z\(\?\:([^\)]+)\)z\(\?P<(\w+)>[^\)]+\)+z \([^\)]+\)z\[([^\]]+)\|([^\]]+)\]z([A-Z]+)([a-z])c C s� t dk r8t|d�r8t|jt �r8| j�dd� t|jj��S t|�j}| j �dd� |�}| j �dd� |�}| j�d|�}| j�dd� |�}|� d d �� dd �� dd �� d d �� dd �� dd�� dd �}|S )z� Clean up urlpattern regexes into something readable by humans: From: > "^(?P<sport_slug>\w+)/athletes/(?P<athlete_slug>\w+)/$" To: > "{sport_slug}/athletes/{athlete_slug}/" Nr c S s d| � d� S )N�{%s}r ��group��mr r r �<lambda>M � z)RavenResolver._simplify.<locals>.<lambda>c S s d| � d� S )Nz%s� r r r r r r V r c S s d| � d� S )Nr r r r r r r r Y r z{var}c S s | � d�S )Nr r r r r r r _ r �^� �$�?z\Az\Zz//�/�\)r �hasattr� isinstancer �_new_style_group_matcher�sub�strZ_router �_optional_group_matcher�_named_group_matcher�_non_named_group_matcher�_either_option_matcher�replace)�selfr �resultr r r � _simplify: sH �� � � � � � � � �� zRavenResolver._simplifyNc s� t |��|�}|sd S |d kr&|g}n||kr8||g }||�� d � }|jD ]�}|jsv� �|||�}|rN| S qNnt |��|�s�qNz� j| W S tk r� Y nX d�� fdd�|D ��}|� � |� } | � d�s�d| } | � j|<