Team Ai
Datasetpublic

codekingpro/portable-devtools

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

2��j0��:�SSKrSSKrSSKrSSKrSSKJr SSKJr SSK	r	SSK3rSSKJr SSKJ
r
 SSKJr SSKJr SSKJr SS	KJr \R&"\5rS4\4SjrSrS
\S\R2S\\-4SjrS
\S\R2S\4Sjr"SS5rg)�N)�Sequence)�Any)�certs)�command)�5exceptions)�flow)�http)�ALERT�specc���URS5(aURS5(d[R"SU-5eU[	S5SR5$)N�header[�]zInvalid header spec: %s�����)�6startswith�endswithr�CommandError�len�strip)rs �ZD:\code\apps\devtools\python\user_packages\Python313\site-packages\mitmproxy/addons/cut.py�7headernamersP���O�O�I�&�&�4�=�=��+=�+=��%�%�&?�$�&F�G�G���I���$�*�*�,�,�c�L�[U[5=(a [U5S:�$)N�)�8isinstance�tupler)�vs r�is_addrrs���a���.�C��F�Q�J�.r�cut�f�returnc��[U[R5(a1UR(a US;aURR	5$URS5nUn[
U5GH�upEURS5(a[R"SU-5e[X5S5nU[U5S-9:XGayUS:Xa [U5(a[US5s $US:Xa [U5(a[US5s $URS	5(a0U(d g10URR[!U5S115s $[U["5(aUs $[U[$5(aU(aSs $Ss $[U[&R(5(a!UR+5R-S
5s $[U[.5(aU[U5S:�aF[US[&R(5(a$USR+5R-S
5s $UnGM� [U=(d S125$)N)zrequest.contentzresponse.content�.�_z"Can't access internal attribute %sr�port�hostrr
��true�false�ascii)rr	�HTTPFlow�	websocket�_get_formatted_messages�split�	enumeraterrr�getattrrr�str�headers�getr�bytes�boolr�Cert�to_pem�decode�list)rr�path�current�ir�parts       r�extractr=s���13	�1�d�m�m�$�$�
�K�K��:�:��{�{�2�2�4�4��9�9�S�>�D��G��T�?����?�?�3����)�)�*N�QU�*U�V�V��w�d�+����D�	�A�
���v�~�'�'�"2�"2��7�1�:��&��v�~�'�'�"2�"2��7�1�:��&�����+�+������*�*�:�d�+;�R�@�@��D�%�(�(����D�$�'�'�!%�v�2�7�2��D�%�*�*�-�-��{�{�}�+�+�G�4�4��4��&�&���I��M��t�A�w��14�15�3�3��A�w�~�~�'�.�.�w�7�7���7#�8�w�}�"��rc�\�[X5n[U[5(a[U5$U$)N)r=rr3�repr)rr�rets   r�extract_strrAKs'��16�#�/�C��#�u����C�y���17rc	���\rSrSr\R"S5S\\RS\RRS\RR4Sj5r\R"S5S\\RS\RRS\RRSS	4S18j5r\R"S5S\\RS\RRSS	4Sj5rS
rg	)�Cut�Sr�flows�cutsr c19�|�/nUH.nURUVs/sHn[XT5PM sn5 M0 U$s snf)a�20Cut data from a set of flows. Cut specifications are attribute paths21from the base of the flow object, with a few conveniences - "port"22and "host" retrieve parts of an address tuple, ".header[key]"23retrieves a header value. Return values converted to strings or24bytes: SSL certificates are converted to PEM format, bools are "true"25or "false", "bytes" are preserved, and all other values are26converted to strings.27)�appendr=)�selfrErFr@r�cs      rr�Cut.cutTs<��(*���A��J�J�t�4�t�!���
�t�4�5���28��5s�929zcut.saver9Nc	�N�SnURS5(aCSn[RRUSS5n[R30R
U5n[U5S:Xa�[U5S:Xa�[X4(aSOS5nUR5S:�aURS	5 [USUS5n[U[5(aURU5 O URURS3155 SSS5 [R!["S5 g[X4(aSOS
SS32S9n[$R&"U5n	UH/n33UVs/sHn[)X�5PM nnU	R+U5 M1 SSS5 [R!["S[U5[U54-5 g!,(df   N�=fs snf!,(df   NV=f![,a(n
[R/[1U
55 Sn
A
gSn
A
ff=f)a34Save cuts to file. If there are multiple flows or cuts, the format35is UTF-8 encoded CSV. If there is exactly one row and one column,36the data is written to file as-is, with raw bytes preserved. If the37path is prefixed with a "+", values are appended if there is an38existing file.39F�+TrN�ab�wbr�40�utf8zSaved single cut.�a�wr&)�newline�encodingz#Saved %s cuts over %d flows as CSV.)r�osr9�41expanduser�	mitmproxy�types�Pathr�open�tell�writer=rr3�encode�logger�logr42�csv�writerrA�writerow�OSError�errorr0)rIrErFr9rH�epath�fpr�tfprbrrJ�vals�es              r�save�Cut.savehs������?�?�3����F��G�G�&�&�t�A�B�x�0�E��?�?�'�'��.�D�	!��4�y�A�~�#�e�*��/��$���D�9�R��w�w�y�1�}��������Q���q��2�A�!�!�U�+�+������������&�!1�2�:��43�44�5�"5�6����#�S�"�v��� �Z�Z��_�F�"��;?�@�4�a��A� 1�4��@�����-�#�	��45�46��9�S��Y��E�47�<S�S��%:�9��  A�����	!��L�L��Q�� � ��	!�sa�2G2�A?G�"G2�1G2� G!�%G�:G!�9G2�48G�G2�G!�!49G/�+G2�250H$�<H�H$zcut.clipc��[R"SS9n[U5S:XaM[U5S:Xa>[USUS5nUR	U5 [51R
[S5 Oq[R"U5nUH/nUVs/sHn[Xv5PM nnURU5 M1 [52R
[S[U5-5 [R"UR55 gs snf![Ra(n	[53R[!U	55 Sn	A	gSn	A	ff=f)z�54Send cuts to the clipboard. If there are multiple flows or cuts, the55format is UTF-8 encoded CSV. If there is exactly one row and one56column, the data is written to file as-is, with raw bytes preserved.57r&)rTrrzClipped single cut.zClipped %s cuts as CSV.N)�io�StringIOrrAr]r_r`r58rarbrc�	pyperclip�copy�getvalue�PyperclipExceptionrer0)59rIrErFrgrrbrrJrirjs60          r�clip�Cut.clip�s����[�[��
$���t�9��>�c�%�j�A�o��D��G�U�1�X�.�A��H�H�Q�K��J�J�u�3�4��Z�Z��^�F���37�8�4�a��A�)�4��8�����%��
�J�J�u�7�#�d�)�C�D�	!��N�N�2�;�;�=�)��	9��61�+�+�	!��L�L��Q�� � ��	!�s�D�#$D
�
E	�!E�E	�)�__name__�62__module__�__qualname__�__firstlineno__rrr�FlowrXrY�CutSpec�DatarrZrkrt�__static_attributes__rvrrrCrCSs���_�_�U�����	�	�"���o�o�%�%��63���	�	�	���&
�_�_�Z� �+!���	�	�"�+!��o�o�%�%�+!��o�o�"�"�	+!�6465�+!�!�+!�Z
�_�_�Z� �!���	�	�"�!��o�o�%�%�!�66�	!�!�!rrC)rarn�logging�os.pathrV�collections.abcr�typingrrp�mitmproxy.typesrXrrrrr	�
mitmproxy.logr67�	getLoggerrwr_r0rrr{r3r=rArCrvrr�<module>r�s���68�	���$������ ����	�	�	�8�	$��-�S�-�/�)��)����)�s�U�{�)�X�S��T�Y�Y��3��]!�]!r
codekingpro/portable-devtools · Team Ai