shell bypass 403
�
Tf�! � �V � d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z m
Z
mZ ddlm
Z
ddlmZ dadZd � Zdd
�Z G d� d� � Z G d
� de
� � Z G d� de
� � Zd� Zedk r; eej � � dk rddlmZ eddd�� � ddlmZ ee� � dS dS )z�Module browser.
XXX TO DO:
- reparse when source changed (maybe just a button would be OK?)
(or recheck on window popup)
- add popup menu with more options (e.g. doc strings, base classes, imports)
- add base classes to class browser tree
� N)�idleConf)�pyshell)�TreeNode�TreeItem�ScrolledCanvas)�
py_extensions)�ListedToplevel)z.pyic � � t j � | � � \ }}t j � |� � }|t v o|t
vS �N)�os�path�splitext�normcaser �browseable_extension_blocklist)r
�_�exts �8/usr/local/python-3.11/lib/python3.11/idlelib/browser.py�is_browseable_extensionr sF � �
�W�
�
�d�
#�
#�F�A�s�
�'�
�
�3�
�
�C��-��M�C�/M�$M�M� c �� � g }| � � � D ]�\ }}|�|j |k r�t |d� � r�|j r�|j |k r�g }|j D ]R}t |t � � r|}n#|j }|j |j k r|j � d|� �}|� |� � �S|xj d� d� |� � � � z
c_ |� |� � ��|S )a Transform a child dictionary to an ordered sequence of objects.
The dictionary maps names to pyclbr information objects.
Filter out imported objects.
Augment class names with bases.
The insertion order of the dictionary is assumed to have been in line
number order, so sorting is not necessary.
The current tree only calls this once per child_dict as it saves
TreeItems once created. A future tree and tests might violate this,
so a check prevents multiple in-place augmentations.
N�super�.z({})z, )
�items�module�hasattrr �name�
isinstance�str�append�format�join)�
child_dict�modname�obs�key�obj�supers�sup�snames r �transform_childrenr* # s
� �
�C��$�$�&�&� � ���S��?�c�j�G�3�3��s�G�$�$�
=���
=�s�x�3������9� )� )�C�!�#�s�+�+� <� #��� #����:���3�3�'*�z�$;�$;�E�$;�$;�E��M�M�%�(�(�(�(����F�M�M�$�)�)�F�*;�*;�<�<�<����J�J�s�O�O�O���Jr c �: � e Zd ZdZddd�d�Zd
d�Zd� Zd� Zd � ZdS )�
ModuleBrowserz1Browse module classes and functions in IDLE.
F)�_htest�_utestc �f � || _ || _ || _ || _ | � � � dS )a Create a window for browsing a module's structure.
Args:
master: parent for widgets.
path: full path of file to browse.
_htest - bool; change box location when running htest.
-utest - bool; suppress contents when running unittest.
Global variables:
file_open: Function used for opening a file.
Instance variables:
name: Module name.
file: Full path and module with supported extension.
Used in creating ModuleBrowserTreeItem as the rootnode for
the tree and subsequently in the children.
N)�masterr
r- r. �init)�selfr0 r
r- r. s r �__init__zModuleBrowser.__init__J s1 � �$ ����� �������� � �����r Nc �j � | j � � � | j � � � dS )z&Dismiss the window and the tree nodes.N)�top�destroy�node)r2 �events r �closezModuleBrowser.closeb s0 � ��������� �������r c � � | j }| j s| j st j nt j |� � }|j at j �
� � t |� � x| _ }|�
d| j � � |� d| j � � | j rA|� d|� � � |� � � dz fz � � | � � � |� � � t+ j � � }t+ j |d� � d }t1 ||dd� � � }|j � dd
�� � | � � � }t9 |j d|� � x| _ }| j s*|� � � |� � � dS dS )
z3Create browser tkinter widgets, including the tree.�WM_DELETE_WINDOWz<Escape>z+%d+%d�� �normal�
backgroundr � )�bg�highlightthickness� takefocus�both)�expand�fillN)!r0 r- r. r �flist�PyShellFileList�open� file_open�pyclbr�_modules�clearr r5 �protocolr9 �bind�geometry�winfo_rootx�winfo_rooty�settitle� focus_setr �CurrentTheme�GetHighlightr �frame�pack�rootnoder �canvasr7 �updaterD ) r2 �rootrF r5 �themer>