����JFIF���������
1#@!#!123s
D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
alt
/
python37
/
lib64
/
python3.7
/
idlelib
/
__pycache__
/
Filename :
query.cpython-37.opt-1.pyc
back
Copy
B ����� f2:������������������@���s ��d�Z�ddlZddlZddlZddlmZmZ�ddlmZm Z m Z mZmZm Z �ddlmZmZmZmZmZ�ddlmZ�ddlmZ�G�dd ��d e�ZG�d d��de�ZG�dd ��d e�ZG�dd��de�ZG�dd��de�ZG�dd��de�Zedk�rddlmZ�edddd��ddl m!Z!�e!eee��dS�)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)�Fontc�������������������sl���e�Zd�ZdZdi�ddd�dd�Zddd �Zd d��Zdd d�Zdd��Zddd�Z ddd�Z ��fdd�Z���ZS�)�QueryzoBase class for getting verified answer from a user. For this base class, accept any non-blank string. ��F)�text0� used_names�_htest�_utestc������ ������C���sX��||�_�||�_||�_||�_t�|�|��|�����|��|��|��|��|�� ���|�j �dd�}|dkr�y|�j �dd|�jdd��W�n���Y�nX�|�� d|�j��|�� d |�j��|��d |�j��|�� d|�j��|�� d|�j��|�����|�����|��d |���|���d�|����d���|���|�s$|���d�|����d��nd�f���|�jddd��|�sT|�����|�����dS�)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 �tk�windowingsystemZaquaz!::tk::unsupported::MacWindowStyleZstyleZ moveableModalr���z<Command-.>z<Key-Escape>ZWM_DELETE_WINDOWz<Key-Return>z <KP_Enter>z+%d+%d��������F)Zheight�widthN)�parent�messager���r���r����__init__Zwithdraw�titleZ transientZgrab_setr���ZcallZ_wZbind�cancelZprotocol�ok�create_widgetsZupdate_idletasksZgeometryZwinfo_rootxZwinfo_widthZwinfo_reqwidthZwinfo_rootyZwinfo_heightZwinfo_reqheightZ resizableZ deiconifyZwait_window) �selfr���r���r���r���r���r���r���r�����r$����2/opt/alt/python37/lib64/python3.7/idlelib/query.pyr���%���sB���� *zQuery.__init__�OKc�������������C���s6��t�|�dd��|�_}|jdddd��|jddd��t|dd |�jd �}t|�|�j�|�_t |d|�jd�|�_ |�j ����td d|�j d�|�_t|dd|�jd�|�_|jddddtd��|�j jddddtt�ddgd��|�jjddddtt�d��|�����t||d|�jd�|�_t|d|�jd�|�_|�jjdddd��|�jjdddd��dS�)z�Create entry (rows, extras, buttons. Entry stuff on rows 0-2, spanning cols 0-2. Buttons on row 99, cols 1, 2. � ���)Zpaddingr���Znews)�column�row�sticky����)Zweight�w�left)�anchor�justify�text����)r����textvariableZ TkCaptionFontT)�name�exists�root� �red)r0���� foreground�font��������)r(���r)���� columnspan�padxr*���)r(���r)���r<���r=���r*����padyr���Zactive)r0����default�commandZCancel)r0���r@����c���)r(���r)���r=���N)r ����frame�gridZgrid_columnconfigurer ���r���r���r���Zentryvarr����entry� focus_setr���r���� error_font�entry_errorr���r����create_extrar���r!���Z button_okr ���Z button_cancel)r#���Zok_textrB���Z entrylabelr$���r$���r%���r"���[���s0���� zQuery.create_widgetsc�������������C���s���d�S�)Nr$���)r#���r$���r$���r%���rH������������zQuery.create_extraNc�������������C���s���d|�|p|�j�d<�d�S�)NzERROR: r0���)rG���)r#���r���Zwidgetr$���r$���r%���� showerror����s����zQuery.showerrorc�������������C���s$���|�j�������}|s |��d��dS�|S�)zReturn non-blank entry or None.zblank line.N)rD����get�striprJ���)r#���rD���r$���r$���r%����entry_ok����s ���� zQuery.entry_okc�������������C���s8���d|�j�d<�|����}|dk r*||�_|�����n |�j����dS�)z�If entry is valid, bind it to 'result' and destroy tk widget. Otherwise leave dialog open for user to correct entry or cancel. r���r0���N)rG���rM����result�destroyrD���rE���)r#����eventrD���r$���r$���r%���r!�������s���� zQuery.okc�������������C���s���d|�_�|�����dS�)z0Set dialog result to None and destroy tk widget.N)rN���rO���)r#���rP���r$���r$���r%���r �������s����zQuery.cancelc����������������s���|������t������d�S�)N)Zgrab_release�superrO���)r#���)� __class__r$���r%���rO�������s����z Query.destroy)r&���)N)N)N) �__name__� __module__�__qualname__�__doc__r���r"���rH���rJ���rM���r!���r ���rO���� __classcell__r$���r$���)rR���r%���r��� ���s���5 % r���c�������������������s0���e�Zd�ZdZddd���fdd� Zdd��Z���ZS�)�SectionNamez*Get a name for a config file section name.F)r���r���c���������������s���t���j||||||d��d�S�)N)r���r���r���)rQ���r���)r#���r���r���r���r���r���r���)rR���r$���r%���r�������s����zSectionName.__init__c�������������C���sV���|�j�������}|s |��d��dS�t|�dkr:|��d��dS�||�jkrR|��d��dS�|S�)z2Return sensible ConfigParser section name or None.zno name specified.Nr1���z"name is longer than 30 characters.zname is already in use.)rD���rK���rL���rJ����lenr���)r#���r3���r$���r$���r%���rM�������s���� zSectionName.entry_ok)rS���rT���rU���rV���r���rM���rW���r$���r$���)rR���r%���rX�������s���rX���c�������������������s0���e�Zd�ZdZddd���fdd� Zdd��Z���ZS�)� ModuleNamez-Get a module name for Open Module menu entry.F)r���r���c���������������s���t���j||||||d��d�S�)N)r���r���r���)rQ���r���)r#���r���r���r���r���r���r���)rR���r$���r%���r�������s����zModuleName.__init__c���������� ���C���s����|�j�������}|s |��d��dS�ytj�|�}W�n4�ttfk rd�}�z|��t |���dS�d}~X�Y�nX�|dkr||��d��dS�t |jtjj �s�|��d��dS�y|j�|�}W�n"�tk r����|�jd|�d��dS�X�|S�)z0Return entered module name as file path or None.zno name specified.Nzmodule not foundznot a source-based modulez$loader does not support get_filename)r���)rD���rK���rL���rJ���� importlib�util� find_spec� ValueError�ImportError�str� isinstance�loader�abc�SourceLoader�get_filename�AttributeError)r#���r3����spec�msgZ file_pathr$���r$���r%���rM�������s,���� zModuleName.entry_ok)rS���rT���rU���rV���r���rM���rW���r$���r$���)rR���r%���rZ�������s���rZ���c���������������@���s���e�Zd�ZdZdd��ZdS�)�Gotoz1Get a positive line number for editor Go To Line.c�������������C���sL���yt�|�j����}W�n�tk r0���|��d��d�S�X�|dkrH|��d��d�S�|S�)Nznot a base 10 integer.r���znot a positive integer.)�intrD���rK���r^���rJ���)r#����linenor$���r$���r%���rM�������s���� z Goto.entry_okN)rS���rT���rU���rV���rM���r$���r$���r$���r%���ri�������s���ri���c�������������������s\���e�Zd�ZdZddi�ddd���fdd� Zdd��Zd d ��Zdd��Zej Z d d��Zdd��Z ���ZS�)� HelpSourcez,Get menu name and help source for Help menu.r���F)�menuitem�filepathr���r���r���c������ ��� ������s(���||�_�d}t��j|||||||d��dS�)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:)r���r���r���r���N)rn���rQ���r���) r#���r���r���rm���rn���r���r���r���r���)rR���r$���r%���r�������s ����zHelpSource.__init__c�������������C���s����|�j�}t|dddd�}t|�|�j�|�_t||�jdd�|�_t|dd|�jd �}t|d d|�j d�|�_ |jd ddddd gtd��|�jjd dddtt �dd gd��|jdddtt�d��|�j jd dddtt �d��dS�)zAdd path widjets to rows 10-12.r,���r-���z,Help File Path: Enter URL or browse for file)r.���r/���r0����(���)r2���r���ZBrowse����)r0���r���r@���r6���r7���)r0���r8���r9���r���r'���r:���r;���)r(���r)���r<���r=���r>���r*�������r���)r(���r)���r<���r=���r*���r>���)r(���r)���r=���r*�������)r(���r)���r<���r=���r*���N)rB���r ���r���rn����pathvarr����pathr����browse_filerF���� path_errorrC���r���r���r ���)r#���rB���Z pathlabelZbrowser$���r$���r%���rH�����s ���� zHelpSource.create_extrac�������������C���s���t�j|�|d�j||d�S�)N)r���� filetypes)Z initialdirZinitialfile)r���ZOpenZshow)r#���rw���ZinitdirZinitfiler$���r$���r%����askfilename��s����zHelpSource.askfilenamec�������������C���s����dddddg}|�j����}|r.tj�|�\}}nHd�}td�d��dkrntj�tj�t�d�}tj� |�svt� ��}nt� ��}|��|||�}|r�|�j��|��d�S�) N)z HTML Filesz*.htm *.html�TEXT)z PDF Filesz*.pdfry���)zWindows Help Filesz*.chm)z Text Filesz*.txtry���)z All Files�*r:����winZDoc) rs���rK����osrt����splitr����join�dirnamer����isdir�getcwdrx����set)r#���rw���rt����dir�base�filer$���r$���r%���ru�����s"���� zHelpSource.browse_filec�������������C���s|���|�j�������}|s$|��d|�j��dS�|�d�sx|dd��dkrJ|dd��}tj��|�sh|��d|�j��dS�tdkrxd|�}|S�) z(Simple validity check for menu file pathzno help file path specified.N)zwww.Zhttpr;���zfile:zhelp file path does not exist.�darwinzfile://) rt���rK���rL���rJ���rv���� startswithr|���r4���r���)r#���rt���r$���r$���r%����path_ok6��s���� zHelpSource.path_okc�������������C���s6���d|�j�d<�|����}|����}|dks*|dkr.dS�||fS�)z,Return apparently valid (name, path) or Noner���r0���N)rv����item_okr����)r#���r3���rt���r$���r$���r%���rM���G��s���� zHelpSource.entry_ok) rS���rT���rU���rV���r���rH���rx���ru���rX���rM���r����r����rW���r$���r$���)rR���r%���rl�������s���rl���c�������������������sB���e�Zd�ZdZg�ddd���fdd� Zdd��Zdd ��Zd d��Z���ZS�)� 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_argsr���r���c���������������s ���d}t���j||||||d��dS�)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���r���r���N)rQ���r���)r#���r���r���r����r���r���r���)rR���r$���r%���r���V��s����zCustomRun.__init__c�������������C���sj���|�j�}t|�dd�|�_t||�jdddd�}t|dd|�jd�|�_|jd d ddd d��|�jjd ddddd��dS�)zAdd run mode on rows 10-12.T)�valueFz Restart shell)ZvariableZonvalueZoffvaluer0���r6���r7���)r0���r8���r9���r���r'���r:���r;���r,���)r(���r)���r<���r=���r*���rr���ZweN)rB���r���� restartvarr���r ���rF���Z args_errorrC���)r#���rB����restartr$���r$���r%���rH���b��s���� zCustomRun.create_extrac���������� ���C���sV���|�j�������}ytj|dd�}W�n0�tk rP�}�z|��t|���dS�d}~X�Y�nX�|S�)z6Validity check and parsing for command line arguments.T)�posixN)rD���rK���rL����shlexr}���r^���rJ���r`���)r#���Z cli_stringr�����errr$���r$���r%����cli_args_oko��s����zCustomRun.cli_args_okc�������������C���s&���|�����}|�j���}|dkrdS�||fS�)z3Return apparently valid (cli_args, restart) or NoneN)r����r����rK���)r#���r����r����r$���r$���r%���rM���y��s���� zCustomRun.entry_ok) rS���rT���rU���rV���r���rH���r����rM���rW���r$���r$���)rR���r%���r����N��s��� r�����__main__)�mainzidlelib.idle_test.test_queryr���F)� verbosity�exit)�run)"rV���r[���r|���r�����sysr���r���Ztkinterr���r���r���r���r���r ���Ztkinter.ttkr ���r���r���r ���r���r���Ztkinter.fontr���r���rX���rZ���ri���rl���r����rS���Zunittestr����Zidlelib.idle_test.htestr����r$���r$���r$���r%����<module>���s(��� �$\2