Sindbad~EG File Manager

Current Path : /usr/local/lib/python3.12/idlelib/__pycache__/
Upload File :
Current File : //usr/local/lib/python3.12/idlelib/__pycache__/query.cpython-312.pyc

�

&Μg�:��j�dZddlZddlZddlZddlZddlmZmZddl	m
Z
mZmZm
Z
mZmZddlmZmZmZmZmZddl	mZddlmZddlmZGd	�d
e
�ZGd�de�ZGd
�de�ZGd�de�ZGd�de�ZGd�de�Z e!dk(r"ddl"m#Z#e#ddd��ddl$m%Z%e%eee �yy)a|
Dialogs that query users and verify the answer before accepting.

Query is the generic base class for a popup dialog.
The user must either enter a valid answer or close the dialog.
Entries are validated when <Return> is entered or [Ok] is clicked.
Entries are ignored when [Cancel] or [X] are clicked.
The 'return value' is .result set to either a valid answer or None.

Subclass SectionName gets a name for a new config file section.
Configdialog uses it for new highlight theme and keybinding set names.
Subclass ModuleName gets a name for File => Open Module.
Subclass HelpSource gets menu item and path for additions to Help menu.
�N)�
executable�platform)�Toplevel�	StringVar�
BooleanVar�W�E�S)�Frame�Button�Entry�Label�Checkbutton)�
filedialog)�Font)�
_setup_dialogc�`��eZdZdZdiddd�d�Zd
d�Zd�Zdd�Zd	�Zdd
�Z	dd�Z
�fd�Z�xZS)�QueryzoBase class for getting verified answer from a user.

    For this base class, accept any non-blank string.
    �F��text0�
used_names�_htest�_utestc�(�||_||_||_||_t	j
||�|j
�|j|�|j|�|s|j�t|�|jdk(r|jd|j�|jd|j�|jd|j�|jd|j�|jd|j�|j!�|j#�|j%d|j'�|j)�dz|j+�dzz
z|j-�|s'|j/�dz|j1�dzz
nd	zfz�|j3d
d
��|s;|j5�|j6j9�|j;�yy)
a�Create modal popup, return when destroyed.

        Additional subclass init must be done before this unless
        _utest=True is passed to suppress wait_window().

        title - string, title of popup dialog
        message - string, informational message to display
        text0 - initial value for entry
        used_names - names already in use
        _htest - bool, change box location when running htest
        _utest - bool, leave window hidden and not modal
        �aquaz<Command-.>z<Key-Escape>�WM_DELETE_WINDOWz<Key-Return>z
<KP_Enter>z+%d+%d��F)�height�widthN)�parent�messagerrr�__init__�withdraw�title�	transient�grab_setr�_windowingsystem�bind�cancel�protocol�ok�create_widgets�update_idletasks�geometry�winfo_rootx�winfo_width�winfo_reqwidth�winfo_rooty�winfo_height�winfo_reqheight�	resizable�	deiconify�entry�	focus_set�wait_window)�selfr"r&r#rrrrs        �*/usr/local/lib/python3.12/idlelib/query.pyr$zQuery.__init__&s�����������
�$������$��'��
�
���
�
�5�����v����M�M�O��d��� � �F�*��I�I�m�T�[�[�1��	�	�.�$�+�+�.��
�
�(�$�+�+�6��	�	�.�$�'�'�*��	�	�,����(����������
�
���&�&�(��'�'�)�!�+�d�.A�.A�.C�A�.E�E�G��&�&�(�!��)�)�+�A�-��0D�0D�0F�q�0H�H�'*�,���	�	
���e�5��1���N�N���J�J� � �"������c	��t|d��x|_}|jddd��|jdd��t	|dd	|j
�
�}t
||j�|_t|d|j��|_
td
d|j��|_
t	|dd|j��|_|jddddt��|jjddddtt zddg��|jjddddtt z��|j#�t%||d|j&��|_t%|d|j*��|_|j(jddd��|j,jddd��y)z�Create entry (rows, extras, buttons.

        Entry stuff on rows 0-2, spanning cols 0-2.
        Buttons on row 99, cols 1, 2.
        �
)�paddingr�news)�column�row�sticky�)�weight�w�left��anchor�justify�text�)r!�textvariable�
TkCaptionFontT)�name�exists�root� �red�rM�
foreground�font���rCrD�
columnspan�padxrE�rCrDr\r]rE�padyr�active)rM�default�command�Cancel)rMrb�c)rCrDr]N)r�frame�grid�grid_columnconfigurerr#rr�entryvarr
r9rr"�
error_font�entry_errorrr	�create_extrarr-�	button_okr+�
button_cancel)r<�ok_textre�
entrylabels    r=r.zQuery.create_widgetsYs���#�4��4�4��
�U�
�
�
�!��6�
�2�
�"�"�1�Q�"�/��5��f� $���.�
�!�$��
�
�3��
��5�����G��
��O�&*����>��� ��S�U�&*�o�o�7���	���q�a�A�A�a��H��
�
���q�a�A�A�a��c� ��V�	�	%������Q�A�!�!�%&�q�S�	�	*�	
������G�X�t�w�w�H���#��H�d�k�k�;���	
�����1�"�1��5������q�b�q��9r>c��y�N�)r<s r=rkzQuery.create_extra}s��Dr>c�0�d|z|xs|jd<y)NzERROR: rM)rj)r<r#�widgets   r=�	showerrorzQuery.showerrors��/8�7�/B��	#�4�#�#�V�,r>c�~�|jj�j�}|s|jd�y|S)zReturn non-blank entry or None.zblank line.N)r9�get�stripru)r<r9s  r=�entry_okzQuery.entry_ok�s2���
�
��� �&�&�(����N�N�=�)���r>c��d|jd<|j�}|�||_|j�y|jj�y)z�If entry is valid, bind it to 'result' and destroy tk widget.

        Otherwise leave dialog open for user to correct entry or cancel.
        rrMN)rjry�result�destroyr9r:)r<�eventr9s   r=r-zQuery.ok�sG��
$&����� ��
�
������D�K��L�L�N�
�J�J� � �"r>c�2�d|_|j�y)z0Set dialog result to None and destroy tk widget.N)r{r|)r<r}s  r=r+zQuery.cancel�s��������r>c�B��|j�t�|�	�yrq)�grab_release�superr|)r<�	__class__s �r=r|z
Query.destroy�s�������
���r>)�OKrq)
�__name__�
__module__�__qualname__�__doc__r$r.rkruryr-r+r|�
__classcell__�r�s@r=rr!sD����9;�r��e�1�f":�H!�C��#��
�r>rc�0��eZdZdZddd��fd�
Zd�Z�xZS)�SectionNamez*Get a name for a config file section name.F�rrc�0��t�|�||||||��y)N)rrr�r�r$)r<r"r&r#rrrr�s       �r=r$zSectionName.__init__�s"���
������J� &�v�	�	7r>c��|jj�j�}|s|jd�yt	|�dkDr|jd�y||j
vr|jd�y|S)z2Return sensible ConfigParser section name or None.�no name specified.NrNz"name is longer than 30 characters.zname is already in use.)r9rwrxru�lenr)r<rQs  r=ryzSectionName.entry_ok�sj���z�z�~�~��%�%�'����N�N�/�0��
��Y�r�\��N�N�?�@��
�T�_�_�
$��N�N�4�5���r>�r�r�r�r�r$ryr�r�s@r=r�r��s���0�!��7�
r>r�c�0��eZdZdZddd��fd�
Zd�Z�xZS)�
ModuleNamez-Get a module name for Open Module menu entry.Fr�c�0��t�|�||||||��y)N�rrrr�)r<r"r&r#rrrr�s       �r=r$zModuleName.__init__�s"���
������u�$�V�	�	5r>c���|jj�j�}|s|jd�y	tj
j
|�}|�|jd�yt|jtjj�s|jd�y	|jj|�}|S#ttf$r$}|jt|��Yd}~yd}~wwxYw#t$r|jd�Yyt$r@	|jj�}Y|S#t $r|jd�YYywxYwwxYw)z0Return entered module name as file path or None.r�Nzmodule not found.znot a source-based module.z%loader does not support get_filename.zloader failed to get filename.)r9rwrxru�	importlib�util�	find_spec�
ValueError�ImportError�str�
isinstance�loader�abc�SourceLoader�get_filename�AttributeError�	TypeError)r<rQ�spec�msg�	file_paths     r=ryzModuleName.entry_ok�s9���z�z�~�~��%�%�'����N�N�/�0��	��>�>�+�+�D�1�D��<��N�N�.�/���$�+�+�y�}�}�'A�'A�B��N�N�7�8��	����0�0��6�I����+�K�(�	��N�N�3�s�8�$���	���	��N�N�B�C���	�
� �K�K�4�4�6�	�����
����?�@��
��		�sG�C�2D�D�C=�=D�E)�!E)�*E�E%�!E)�$E%�%E)r�r�s@r=r�r��s���3�!��5�
r>r�c��eZdZdZd�Zy)�Gotoz1Get a positive line number for editor Go To Line.c��	t|jj��}|dkr|j	d�y|S#t$r|j	d�YywxYw)Nznot a base 10 integer.rznot a positive integer.)�intr9rwr�ru)r<�linenos  r=ryz
Goto.entry_ok�s[��	�������)�*�F��Q�;��N�N�4�5���
��
�	��N�N�3�4��	�s�#>�A�AN)r�r�r�r�ryrrr>r=r�r��s
��7�	r>r�c�f��eZdZdZddiddd��fd�
Zd�Zd�Zd�ZejZ
d	�Zd
�Z	�xZS)�
HelpSourcez,Get menu name and help source for Help menu.rF)�menuitem�filepathrrrc	�D��||_d}t�	|�	|||||||��y)z�Get menu entry and url/local file for Additional Help.

        User enters a name for the Help resource and a web url or file
        name. The user can browse for the file.
        zName for item on Help menu:rN)r�r�r$)
r<r"r&r�r�rrrr#r�s
         �r=r$zHelpSource.__init__�s4���!��
�/��
�����w�h�%�f�V�	�	Er>c	�D�|j}t|ddd��}t||j�|_t||jd��|_t|dd|j�	�}t|d
d|j��|_
|jd
ddddd
gt��|jjd
dddttzdd
g��|jdddttz��|jjd
dddttz��y)zAdd path widjets to rows 10-12.rHrIz,Help File Path: Enter URL or browse for filerJ�()rOr!�Browse�)rMr!rbrTrUrVrr@rYrZ)rCrDr\r]r_rE�rr^)rCrDr]rE�r[N)rerrr��pathvarr
�pathr�browse_fileri�
path_errorrfrr	r
)r<re�	pathlabel�browses    r=rkzHelpSource.create_extras���
�
���%��V�M�O�	� ��t�}�}�5����%�d�l�l�"�E��	���H�A� $� 0� 0�2����C�E�%)�_�_�6���	���a�R�A�A�R��F��	�	!��	�	���a�R�A�A�a��c���F�	�	$����1�"�1�Q�q�S��9������A�2�!�!�$%�a�C�	�	)r>c�R�tj||��j||��S)N)r"�	filetypes)�
initialdir�initialfile)r�Open�show)r<r��initdir�initfiles    r=�askfilenamezHelpSource.askfilenames%�����d�i�@����X��>�	?r>c��gd�}|jj�}|r#tjj	|�\}}n�d}t
dddk(rutjj
tjjt�d�}tjj|�s)tj�}ntj�}|j|||�}|r|jj|�yy)N))z
HTML Filesz*.htm *.html�TEXT)z	PDF Filesz*.pdfr�)zWindows Help Filesz*.chm)z
Text Filesz*.txtr�)z	All Files�*rY�win�Doc)
r�rw�osr��splitr�join�dirnamer�isdir�getcwdr��set)r<r�r��dir�base�files      r=r�zHelpSource.browse_file!s��� �	��|�|���!������
�
�d�+�I�C���D����|�u�$��g�g�l�l�2�7�7�?�?�:�#>��F���w�w�}�}�S�)��)�)�+�C��i�i�k�����	�3��5����L�L���T�"�r>c�d�|jj�j�}|s|jd|j�y|jd�sW|dddk(r|dd}tjj|�s|jd|j�ytdk(rd|z}|S)	z(Simple validity check for menu file pathzno help file path specified.N)zwww.�httprZzfile:zhelp file path does not exist.�darwinzfile://)	r�rwrxrur��
startswithr�rRr)r<r�s  r=�path_okzHelpSource.path_ok9s����y�y�}�}��$�$�&����N�N�9�4�?�?�K�����!1�2��B�Q�x�7�"��A�B�x���7�7�>�>�$�'����?�#���0���8�#�!�D�(���r>c�t�d|jd<|j�}|j�}|�|�dS||fS)z,Return apparently valid (name, path) or NonerrMN)r��item_okr�)r<rQr�s   r=ryzHelpSource.entry_okJs=��"$�������|�|�~���|�|�~���|�t�|�t�E�$���Er>)
r�r�r�r�r$rkr�r�r�ryr�r�r�r�s@r=r�r��sA���2�35�r��u�U�E�)�(?�#�,�"�"�G��"Fr>r�c�>��eZdZdZgddd��fd�
Zd�Zd�Zd�Z�xZS)�	CustomRunz�Get settings for custom run of module.

    1. Command line arguments to extend sys.argv.
    2. Whether to restart Shell or not.
    F)�cli_argsrrc�4��d}t�|�||||||��y)z�cli_args is a list of strings.

        The list is assigned to the default Entry StringVar.
        The strings are displayed joined by ' ' for display.
        z$Command Line Arguments for sys.argv:r�Nr�)r<r"r&r�rrr#r�s       �r=r$zCustomRun.__init__Ys*���9��
�����w�h��f�	�	.r>c��|j}t|d��|_t||jddd��}t	|dd|j
��|_|jd	d
ddd
��|jjd	dddd��y)zAdd run mode on rows 10-12.T)�valueFz
Restart shell)�variable�onvalue�offvaluerMrTrUrVrr@rYrZrHr[r��weN)rer�
restartvarrrri�
args_errorrf)r<re�restarts   r=rkzCustomRun.create_extraes����
�
��$�T��6����e�d�o�o�t�',�?�D����C�E�%)�_�_�6���	���A�2�!�!�C��H������A�2�!�!�$(�	�	*r>c���|jj�j�}	tj|d��}|S#t
$r$}|j
t|��Yd}~yd}~wwxYw)z.Return command line arg list or None if error.T)�posixN)r9rwrx�shlexr�r�rur�)r<�
cli_stringr��errs    r=�cli_args_okzCustomRun.cli_args_okrs\���Z�Z�^�^�%�+�+�-�
�	��{�{�:�T�:�H�����	��N�N�3�s�8�$���	�s�A�	A0�A+�+A0c�f�|j�}|jj�}|�dS||fS)z4Return apparently valid (cli_args, restart) or None.N)r�r�rw)r<r�r�s   r=ryzCustomRun.entry_ok|s7���#�#�%���/�/�%�%�'���'�t�@�h��-@�@r>)	r�r�r�r�r$rkr�ryr�r�s@r=r�r�Qs'����35��e�
.�*��Ar>r��__main__)�mainzidlelib.idle_test.test_queryrF)�	verbosity�exit)�run)&r��importlib.utilr��
importlib.abcr�r��sysrr�tkinterrrrrr	r
�tkinter.ttkrrr
rrr�tkinter.fontr�tkinter.simpledialogrrr�r�r�r�r�r��unittestr��idlelib.idle_test.htestr�rrr>r=�<module>r�s���
�*%�	��$�<�<�@�@���.��H��D�%��0'��'�T
�5�
� ZF��ZF�x/A��/A�d�z����	'�1�5�A�+���z�9�%�r>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists