Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
maplocal.cpython-313.pyc67 linesDownload Raw Back to __pycache__
1�

2��j���3�SSKrSSKrSSKrSSKrSSKJr SSKJr SSK	J4r5 SSKJr SSK
Jr SSK
Jr SSK
Jr SS	K
Jr SS6K
Jr SSKJr "SS
\75rS\S\4SjrS\S\S\4SjrS\S\S\\4Sjr"SS5rg)�N)�Sequence)�Path)�8NamedTuple)�	safe_join)�ctx)�9exceptions)�10flowfilter)�http)�version)�11parse_specc�H�\rSrSr%\R12\S'\\S'\\S'Sr	g)�MapLocalSpec��matches�regex�13local_path�N)14�__name__�15__module__�__qualname__�__firstlineno__r	�TFilter�__annotations__�strr�__static_attributes__r��_D:\code\apps\devtools\python\user_packages\Python313\site-packages\mitmproxy/addons/maplocal.pyrrs��
�
�
���J��rr�option�returnc�X�[U5upn[R"U5 [U5R
5RSS9n[XU5$![Ran[	SU<SUS35eSnAff=f![an[	SUSUS35eSnAff=f)NzInvalid regular expression z (�)T)�strictzInvalid file path: )16r�re�compile�error�17ValueErrorr�18expanduser�resolve�FileNotFoundErrorr)r�filterr�replacement�e�paths      r�parse_map_local_specr.s���!+�F�!3��F�;�H�19�20�21�5��D��K� �+�+�-�5�5�T�5�B����t�,�,���8�8�H��6�u�i�r�!��A�F�G�G��H��22�D��.�{�m�2�a�S��B�C�C��D�s.�A�&B�B�-B�B�23B)�B$�$B)�root�	untrustedc��[U5Rn[UR5/UQ76nUc[	S5e[U5$)z�Join a Path element with an untrusted str.24 25This is a convenience wrapper for werkzeug's safe_join,26raising a ValueError if the path is malformed.zUntrusted paths.)r�partsr�as_posixr&)r/r0�untrusted_parts�joineds    r�_safe_path_joinr6)sC��27�9�o�+�+�O�
�t�}�}��
9��
9�F�
�~��+�,�,���<�r�url�specc��[R"URU5nU(deUR5(aUR	S5nOH[R28"URUSS9SnURS5SnUR
S5nU(a[RRU5nXDS3/n[R"SSU5nXF:waURXfS3/5 UVs/sHn[URU5PM sn$URS	-/$s snf![a /s$f=f)29z�30Get all potential file candidates given a URL and a mapping spec ordered by preference.31This function already assumes that the spec regex matches the URL.32�)�maxsplit�?r�/z/index.htmlz[^0-9a-zA-Z\-_.=(),/]�_z33index.html)r#�searchr�groups�group�split�strip�urllib�parse�unquote�sub�extendr6rr&)r7r8�m�suffix�decoded_suffix�suffix_candidates�escaped_suffix�xs        r�file_candidatesrO5s"��34	�	�	�$�*�*�c�"�A��H�1��x�x�z�z����������$�*�*�c�A�6�q�9�����c�"�1�%�����c�"��
����-�-�f�5��+�/?�{�-K�L����� 8�#�~�N���+��$�$�n�8H��6T�%U�V�	�AR�S�AR�A�O�D�O�O�Q�7�AR�S�S����,�.�/�/��	T���	��I�	�s$�9D5�= D0�D5�0D5�5E�Ec�P�\rSrSrS35SjrSrSrS\RSS4Sjr	S	r36g)�MapLocal�RrNc��/Ulg�N��replacements)�selfs r�__init__�MapLocal.__init__Ss37��02��rc�B�URS[[/S5 g)N�	map_localz�38            Map remote resources to a local file using a pattern of the form39            "[/flow-filter]/url-regex/file-or-directory-path", where the40            separator can be any character.41            )�42add_optionrr)rW�loaders  r�load�
MapLocal.loadVs"�������S�M��
�			43rc��SU;aP/Ul[RRH*n[	U5nURRU5 M, gg![44a"n[R"SUSU35UeSnAff=f)Nr[zCannot parse map_local option z: )	rVr�optionsr[r.r&r�OptionsError�append)rW�updatedrr8r,s     r�	configure�MapLocal.configurebs����'�!� "�D���+�+�/�/���/��7�D��!�!�(�(��.�0�"��45"��$�1�1�8����1�#�F������s�A�46B�"A?�?B�flowc�4�UR(d"UR(dUR(dgURRn/nUR47GH.nUR
U5(dM[R"URU5(dMDURR5(aUR/nO[X$5nURU5 SnUHnUR5(dMUn O U(dM�S[R0n[ R""[%U55Sn	U	(aX�S'UR'5n48[.R0R3SX�5Ul g U(aT[.R0R3S5Ul[*R4"SSR7S	U5535 gg![(a%n[*R,"SU35 SnAGM�SnAff=f)49N�ServerrzContent-TypezCould not read file: ��i�z)None of the local file candidates exist: z, c3�8# �UHn[U5v� M g7frT)r)�.0rNs  r�	<genexpr>�#MapLocal.request.<locals>.<genexpr>�s���Ee�Vd�QR�c�!�f�f�Vd�s�)�responser%�live�request�50pretty_urlrVrr#r?rr�is_filerOrHr�	MITMPROXY�	mimetypes�51guess_typer�52read_bytes�OSError�logging�warningr53�Response�make�info�join)rWrgr7�all_candidatesr8�54candidates�55local_file�	candidate�headers�mimetype�contentsr,s            rrq�MapLocal.requestos����=�=�D�J�J�d�i�i���l�l�%�%�����%�%�D��|�|�D�!�!�b�i�i��56�57�C�&@�&@��?�?�*�*�,�,�"&�/�/�!2�J�!0��!;�J��%�%�j�1�!�58�!+�I� �(�(�*�*�%.�59��",�60�:�'��):�):�;�G�(�3�3�C�61�O�D�Q�G�H��2:��/�!�#-�#8�#8�#:��62%)�M�M�$6�$6�s�H�$N�D�M��9&�:� �M�M�.�.�s�3�D�M��L�L�;�D�I�I�Ee�Vd�Ee�<e�;f�g�
���#�!����*?��s�(C�D� ��!�s�G(�(63H�2H�HrU)rN)rrrrrXr^rer64�HTTPFlowrqrrrrrQrQRs(��3�6566�/�(�D�M�M�(�d�(rrQ)ryrur#�urllib.parserD�collections.abcr�pathlibr�typingr�werkzeug.securityr�	mitmproxyrrr	r67r�mitmproxy.utils.specrrrr.r6�listrOrQrrr�<module>r�s�����	��$���'�� � ���+��:��
-��
-��
-� 	�$�	�3�	�4�	�0��0�L�0�T�$�Z�0�:E�Er
codekingpro/portable-devtools · Team Ai