
    S
h                         d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZm	Z	m
Z
 d Zd ZddZ G d	 d
e          Zd Zd Zd Z G d de          ZdededefdZd ZdS )    N)settings)DjangoJSONEncoder)
URLPatternURLResolverget_resolverc                 >    fd t          |                     S )Nc                     g }| j         D ]d}t          |dd           r&|j        s|                     |                     9t          |dd           r|                    |j                   e|S )Nurl_patternsname)r
   getattr	namespaceextendappendr   )resolvernamespattern
_get_namess      U/var/www/html/01_SiteInternet/03_Maps/venv/lib/python3.11/site-packages/umap/utils.pyr   z"_get_url_names.<locals>._get_names   s    , 	+ 	+Gw55 +( 6LLG!4!4555&$// +W\***    )r   )moduler   s    @r   _get_url_namesr   
   s6    	 	 	 	 	 :l6**+++r   c            
      F   i } dg}t           j        r|                    d           |D ]Mt                    }|                     t          t          |fd|D                                            N|                     t          t           di                      | S )z8
    Return templated URLs prepared for javascript.
    z	umap.urlszumap.sync.appc                 2    g | ]}t          |           S ))r   )get_uri_template).0urlr   s     r   
<listcomp>z _urls_for_js.<locals>.<listcomp>$   s'    SSSc-c&AAASSSr   UMAP_EXTRA_URLS)r   REALTIME_ENABLEDr   r   updatedictzipr   )urlsmodulesr   r   s      @r   _urls_for_jsr%      s     DmG  (''' 
 
v&&USSSSUSSSTTUU	
 	
 	
 	
 	KK"3R88999Kr    c                    d	fd	}t          |          }|                     d          }t          |          dk    rJ|d         |j        v r;|d         }|d         } |j        |         \  }}dz   |                    d          z   |j                            |           }	|	D ]}
|
dd         \  }}|s|d         \  }} |||          c S g }|D ]\  }}|                    |           t          d |          }t          |
                    |                    }|D ](\  }}t          |          |k    r |||          c c S )dS )
a5  
    Utility function to return an URI Template from a named URL in django
    Copied from django-digitalpaper.

    Restrictions:
    - Only supports named urls! i.e. url(... name="toto")
    - Only support one namespace level
    - Only returns the first URL possibility.
    - Supports multiple pattern possibilities (i.e., patterns with
      non-capturing parenthesis in them) by trying to find a pattern
      whose optional parameters match those you specified (a parameter
      is considered optional if it doesn't appear in every pattern possibility)
    Nc                 R    |sg }| t          d |D                       z  }d|S )zURI template converterc              3   $   K   | ]}|d |z  gV  dS )z{%s}N )r   ps     r   	<genexpr>z5get_uri_template.<locals>._convert.<locals>.<genexpr>=   s*      >>AFQJ>>>>>>r   /)r!   )templateargspathsprefixs      r   _convertz"get_uri_template.<locals>._convert9   sB     	D4>>>>>>>> &&%%((r   :   r   r-      c                 @    t          |           t          |          z  S N)set)xys     r   <lambda>z"get_uri_template.<locals>.<lambda>X   s    AQ r   r7   )r   splitlennamespace_dictrstripreverse_dictgetlistr   reducesortedunion)urlnamer/   r1   r   r2   r   partsr   nprefixpossibilitiestmppossibilityr   resultparamsseen_paramscommon_paramsexpected_paramss     `               r   r   r   *   s   ) ) ) ) ) ) F##HMM#E
5zzA~~%(h&===!H	($3I>#s 3 33)11'::M 4 4"2A2wW 	4 )^NFF8FF+++++
 K"- + +""6**** ##?#?MMM$]%8%8%>%>??O #. 4 4&>>_44#8FF3333333 54 4r   c                       e Zd Zd ZdS )DecoratedURLPatternc                 r    t          j        | g|R i |}|r| j        D ]} ||j                  |_        |S r7   )r   resolve_decorate_withfunc)selfr/   kwargsrK   rU   s        r   rS   zDecoratedURLPattern.resolvec   sV    #D:4:::6:: 	0+ 0 0"d6;//r   N)__name__
__module____qualname__rS   r*   r   r   rQ   rQ   b   s#            r   rQ   c                 p    d }| r0t          | t          t          f          s| g} | D ]} |||           |S )ax  
    Utility function to decorate a group of url in urls.py

    Taken from http://djangosnippets.org/snippets/532/ + comments
    See also http://friendpaste.com/6afByRiBB9CMwPft3a6lym

    Example:
    urlpatterns = [
        url(r'^language/(?P<lang_code>[a-z]+)$', views.MyView, name='name'),
    ] + decorated_patterns(login_required, url(r'^', include('cms.urls')),
    c                    | D ]}t          |t                    rHt          |_        t	          |d          st          |dg            |j                            |           _t          |t                    rf|j	        D ]^}t          |t                    rGt          |_        t	          |d          st          |dg            |j                            |           _d S )NrT   )

isinstancer   rQ   	__class__hasattrsetattrrT   r   r   r
   )r#   rU   r   pps       r   decoratez$decorated_patterns.<locals>.decoratex   s     	7 	7C#z** 7 3s$455 7C!12666"))$////C-- 7* 7 7B!"j11 7':&r+;<< >#B(8"===)00666	7 	7r   )r]   listtuple)rU   r#   rb   fs       r   decorated_patternsrf   k   sa    7 7 7  $u.. 	6D 	 	AHT1Kr   c                 F   t          j        |           }t          | d          5 }t          j        |d          5 }|                    |           d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   t          j        ||j        |j        f           d S )Nrbwb)ns)osstatopengzip
writelinesutimest_mtime_ns)	from_pathto_pathrl   f_inf_outs        r   	gzip_filerv      s   79D	i		 #$Yw%% 	#T"""	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	# 	## # # # # # # # # # # # # # # HW$*D,<=>>>>>>s4   A4AA4A!	!A4$A!	%A44A8;A8c                 >    | j                             d          dk    S )Nzx-requested-withXMLHttpRequest)headersget)requests    r   is_ajaxr|      s    ?1226FFFr   c                       e Zd ZdS )ConflictErrorN)rX   rY   rZ   r*   r   r   r~   r~      s        Dr   r~   	referencelatestincomingc                      |k    r|S fd D             } fdD             }|D ]}||vrt                      |dd         }|D ]}|                    |           |D ]}|                    |           |S )zVFinds the changes between reference and incoming, and reapplies them on top of latest.c                     g | ]}|v|	S r*   r*   )r   itemr   s     r   r   z"merge_features.<locals>.<listcomp>   s#    BBBT-A-At-A-A-Ar   c                     g | ]}|v|	S r*   r*   )r   r   r   s     r   r   z"merge_features.<locals>.<listcomp>   s#    @@@d$i*?*?T*?*?*?r   N)r~   remover   )r   r   r   removedaddedr   mergeds   ` `    r   merge_featuresr      s    BBBB	BBBG@@@@h@@@E  " "v//!  AAAYF   d  dMr   c                 4    t          j        | fdt          i|S )z:Utility using the Django JSON Encoder when dumping objectscls)jsondumpsr   )objrW   s     r   
json_dumpsr      s     :c;;0;F;;;r   )Nr&   N)rn   r   rk   django.confr   django.core.serializers.jsonr   django.urlsr   r   r   r   r%   r   rQ   rf   rv   r|   
ValueErrorr~   rc   r   r   r*   r   r   <module>r      s\     				             : : : : : : = = = = = = = = = =, , ,  "5 5 5 5p    *   " " "J? ? ?G G G	 	 	 	 	J 	 	 	d D D    2< < < < <r   