%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/local/lib/python3.8/idlelib/__pycache__/
Upload File :
Create Path :
Current File : //usr/local/lib/python3.8/idlelib/__pycache__/grep.cpython-38.pyc

U

qa7@sdZddlZddlZddlZddlmZmZddlmZddl	m
Z
ddlmZdddZ
d	d
ZddZGd
dde
ZddZedkrddlmZeddddddlmZeedS)zGrep dialog for Find in Files functionality.

   Inherits from SearchDialogBase for GUI and uses searchengine
   to prepare search pattern.
N)	StringVar
BooleanVar)Checkbutton)SearchDialogBase)searchenginecCsN|}t|}t|ds*t||||_|j}|dd}||||dS)aOpen the Find in Files dialog.

    Module-level function to access the singleton GrepDialog
    instance and open the dialog.  If text is selected, it is
    used as the search phrase; otherwise, the previous entry
    is used.

    Args:
        text: Text widget that contains the selected text for
              default search phrase.
        io: iomenu.IOBinding instance with default path to search.
        flist: filelist.FileList instance for OutputWindow parent.
    _grepdialogz	sel.firstzsel.lastN)Z_rootrgethasattr
GrepDialogropen)textioflistrootengineZdialogsearchphraser(/usr/local/lib/python3.8/idlelib/grep.pygreps

rcCst|dS)zHandle os.walk error.N)print)msgrrr
walk_error+src#s@tj|tdD],\}}fdd|DEdH|sq<qdS)zGenerate file names in dir that match pattern.

    Args:
        folder: Root directory to search.
        pattern: File pattern to match.
        recursive: True to include subdirectories.
    )onerrorc3s(|] }t|rtj|VqdS)N)fnmatchospathjoin).0namedirpathpatternrr	<genexpr>9szfindfiles.<locals>.<genexpr>N)rwalkr)folderr!	recursive_	filenamesrrr	findfiles0sr(cs`eZdZdZdZdZdZfddZddd	Zd
dZ	dd
Z
ddZdddZddZ
ZS)r
z$Dialog for searching multiple files.zFind in Files DialogZGreprcs,t||||_t||_t||_dS)a-Create search dialog for searching for a phrase in the file system.

        Uses SearchDialogBase as the basis for the GUI and a
        searchengine instance to prepare the search.

        Attributes:
            flist: filelist.Filelist instance for OutputWindow parent.
            globvar: String value of Entry widget for path to search.
            globent: Entry widget for globvar.  Created in
                create_entries().
            recvar: Boolean value of Checkbutton widget for
                traversing through subdirectories.
        N)super__init__rrglobvarrrecvar)selfrrr	__class__rrr*Gs
zGrepDialog.__init__Nc	Csht||||r|jpd}nd}tj|\}}tj|\}}|sJd}|jtj	|d|dS)a_Make dialog visible on top of others and ready to use.

        Extend the SearchDialogBase open() to set the initial value
        for globvar.

        Args:
            text: Multicall object containing the text information.
            searchphrase: String phrase to search.
            io: iomenu.IOBinding instance containing file path.
        z.py*N)
rrfilenamerrsplitsplitextr+setr)	r-rrr
rdirbaseheadtailrrrrZszGrepDialog.opencCs"t||d|jd|_dS)z9Create base entry widgets and add widget for search path.z	In files:rN)rcreate_entriesZ
make_entryr+Zglobentr-rrrr:ps
zGrepDialog.create_entriescCs*t|d|jdd}|jddddS)z0Add check button to recurse down subdirectories.rzRecurse down subdirectories)variablertopZboth)ZsidefillN)rZ
make_framer,pack)r-Zbtnrrrcreate_other_buttonsus
zGrepDialog.create_other_buttonscCs t||jd|jdddS)z<Create base command buttons and add button for Search Files.zSearch FilesT)ZisdefN)rcreate_command_buttonsZmake_buttondefault_commandr;rrrrA|s
z!GrepDialog.create_command_buttonscCsj|j}|sdS|j}|s.|jdSddlm}tj	}z||j
t_	|||W5|t_	XdS)a
Grep for search pattern in file path. The default command is bound
        to <Return>.

        If entry values are populated, set OutputWindow as stdout
        and perform search.  The search dialog is closed automatically
        when the search begins.
        Nr)OutputWindow)rZgetprogr+rr=ZbellZidlelib.outwinrCsysstdoutrgrep_it)r-eventprogrrCsaverrrrBs


zGrepDialog.default_commandc
CsJtj|\}}|stj}tt|||j}||j	
}td|d|dd}z|D]}z|t|ddf}	t
|	dD]T\}
}|dd	d
kr|d	d}||rtj|d|
d|d
|d7}qW5QRXWqbtk
r}zt|W5d	}~XYqbXqbt|r&d|d
ndWntk
rDYnXd	S)aSearch for prog within the lines of the files in path.

        For the each file in the path directory, open the file and
        search each line for the matching pattern.  If the pattern is
        found,  write the file and line information to stdout (which
        is an OutputWindow).

        Args:
            prog: The compiled, cooked search pattern.
            path: String containing the search path.
        z
Searching z in z ...rreplace)errorsN
z: zHits found: z'
(Hint: right-click to open locations.)zNo hits.)rrr3curdirsortedr(r,rcloserZgetpatrr	enumeratesearchrDrEwriteOSErrorAttributeError)
r-rHrr$ZfilepatZfilelistpathitsfnflinenolinerrrrrFs6

zGrepDialog.grep_it)N)N)__name__
__module____qualname____doc__titleZiconZneedwrapbuttonr*rr:r@rArBrF
__classcell__rrr.rr
@s

r
csddlm}m}mmddlm}m}ddlm	}||}|
dtt|
ddd\}}|
d|d|d||||}	|	||	d	d
fdd}
||	d
|
d}|dS)Nr)ToplevelTextSELEND)FrameButton)PyShellFileListzTest GrepDialog+rL)Zheightcs,dtdddS)Nz1.0)r)Ztag_addrZ
tag_removerrfrerrrrshow_grep_dialogsz&_grep_dialog.<locals>.show_grep_dialogzShow GrepDialog)rZcommand)tkinterrcrdrerftkinter.ttkrgrhZidlelib.pyshellriramapintZgeometryr3r?)parentrcrdrgrhrir=xyframernZbuttonrrmr_grep_dialogs
 rw__main__)mainzidlelib.idle_test.test_grepF)	verbosityexit)run)NN)r`rrrDrorrrprZidlelib.searchbaserZidlelibrrrr(r
rwr]ZunittestryZidlelib.idle_test.htestr}rrrr<module>s$


Zerion Mini Shell 1.0