Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
idlelib.GrepDialog.GrepDialog Class Reference
Inheritance diagram for idlelib.GrepDialog.GrepDialog:
Inheritance graph
[legend]
Collaboration diagram for idlelib.GrepDialog.GrepDialog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def open
def create_entries
def create_other_buttons
def create_command_buttons
def default_command
def grep_it
def findfiles
def close
def open
def create_widgets
def make_entry
def make_frame
def make_button
def create_option_buttons

Public Attributes

 flist
 globvar
 recvar
 globent
 root
 engine
 top
 text
 row
 ent
 buttonframe

Static Public Attributes

string title = "Find in Files Dialog"
string icon = "Grep"
int needwrapbutton = 0

Detailed Description

Definition at line 17 of file GrepDialog.py.


Constructor & Destructor Documentation

def idlelib.GrepDialog.GrepDialog.__init__ (   self,
  root,
  engine,
  flist 
)

Definition at line 23 of file GrepDialog.py.

00023 
00024     def __init__(self, root, engine, flist):
00025         SearchDialogBase.__init__(self, root, engine)
00026         self.flist = flist
00027         self.globvar = StringVar(root)
00028         self.recvar = BooleanVar(root)

Here is the caller graph for this function:


Member Function Documentation

def idlelib.GrepDialog.GrepDialog.close (   self,
  event = None 
)

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 130 of file GrepDialog.py.

00130 
00131     def close(self, event=None):
00132         if self.top:
00133             self.top.grab_release()
00134             self.top.withdraw()

Here is the caller graph for this function:

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 54 of file GrepDialog.py.

00054 
00055     def create_command_buttons(self):
00056         SearchDialogBase.create_command_buttons(self)
00057         self.make_button("Search Files", self.default_command, 1)

Here is the call graph for this function:

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 41 of file GrepDialog.py.

00041 
00042     def create_entries(self):
00043         SearchDialogBase.create_entries(self)
00044         self.globent = self.make_entry("In files:", self.globvar)

Definition at line 81 of file SearchDialogBase.py.

00081 
00082     def create_option_buttons(self):
00083         f = self.make_frame("Options")
00084 
00085         btn = Checkbutton(f, anchor="w",
00086                 variable=self.engine.revar,
00087                 text="Regular expression")
00088         btn.pack(side="left", fill="both")
00089         if self.engine.isre():
00090             btn.select()
00091 
00092         btn = Checkbutton(f, anchor="w",
00093                 variable=self.engine.casevar,
00094                 text="Match case")
00095         btn.pack(side="left", fill="both")
00096         if self.engine.iscase():
00097             btn.select()
00098 
00099         btn = Checkbutton(f, anchor="w",
00100                 variable=self.engine.wordvar,
00101                 text="Whole word")
00102         btn.pack(side="left", fill="both")
00103         if self.engine.isword():
00104             btn.select()
00105 
00106         if self.needwrapbutton:
00107             btn = Checkbutton(f, anchor="w",
00108                     variable=self.engine.wrapvar,
00109                     text="Wrap around")
00110             btn.pack(side="left", fill="both")
00111             if self.engine.iswrap():
00112                 btn.select()

Here is the call graph for this function:

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 45 of file GrepDialog.py.

00045 
00046     def create_other_buttons(self):
00047         f = self.make_frame()
00048 
00049         btn = Checkbutton(f, anchor="w",
00050                 variable=self.recvar,
00051                 text="Recurse down subdirectories")
00052         btn.pack(side="top", fill="both")
00053         btn.select()

Here is the call graph for this function:

Reimplemented in idlelib.SearchDialog.SearchDialog.

Definition at line 34 of file SearchDialogBase.py.

00034 
00035     def create_widgets(self):
00036         top = Toplevel(self.root)
00037         top.bind("<Return>", self.default_command)
00038         top.bind("<Escape>", self.close)
00039         top.protocol("WM_DELETE_WINDOW", self.close)
00040         top.wm_title(self.title)
00041         top.wm_iconname(self.icon)
00042         self.top = top
00043 
00044         self.row = 0
00045         self.top.grid_columnconfigure(0, pad=2, weight=0)
00046         self.top.grid_columnconfigure(1, pad=2, minsize=100, weight=100)
00047 
00048         self.create_entries()
00049         self.create_option_buttons()
00050         self.create_other_buttons()
00051         return self.create_command_buttons()

def idlelib.GrepDialog.GrepDialog.default_command (   self,
  event = None 
)

Definition at line 58 of file GrepDialog.py.

00058 
00059     def default_command(self, event=None):
00060         prog = self.engine.getprog()
00061         if not prog:
00062             return
00063         path = self.globvar.get()
00064         if not path:
00065             self.top.bell()
00066             return
00067         from idlelib.OutputWindow import OutputWindow
00068         save = sys.stdout
00069         try:
00070             sys.stdout = OutputWindow(self.flist)
00071             self.grep_it(prog, path)
00072         finally:
00073             sys.stdout = save

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.GrepDialog.GrepDialog.findfiles (   self,
  dir,
  base,
  rec 
)

Definition at line 110 of file GrepDialog.py.

00110 
00111     def findfiles(self, dir, base, rec):
00112         try:
00113             names = os.listdir(dir or os.curdir)
00114         except os.error as msg:
00115             print(msg)
00116             return []
00117         list = []
00118         subdirs = []
00119         for name in names:
00120             fn = os.path.join(dir, name)
00121             if os.path.isdir(fn):
00122                 subdirs.append(fn)
00123             else:
00124                 if fnmatch.fnmatch(name, base):
00125                     list.append(fn)
00126         if rec:
00127             for subdir in subdirs:
00128                 list.extend(self.findfiles(subdir, base, rec))
00129         return list

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.GrepDialog.GrepDialog.grep_it (   self,
  prog,
  path 
)

Definition at line 74 of file GrepDialog.py.

00074 
00075     def grep_it(self, prog, path):
00076         dir, base = os.path.split(path)
00077         list = self.findfiles(dir, base, self.recvar.get())
00078         list.sort()
00079         self.close()
00080         pat = self.engine.getpat()
00081         print("Searching %r in %s ..." % (pat, path))
00082         hits = 0
00083         for fn in list:
00084             try:
00085                 f = open(fn)
00086             except IOError as msg:
00087                 print(msg)
00088                 continue
00089             lineno = 0
00090             while 1:
00091                 block = f.readlines(100000)
00092                 if not block:
00093                     break
00094                 for line in block:
00095                     lineno = lineno + 1
00096                     if line[-1:] == '\n':
00097                         line = line[:-1]
00098                     if prog.search(line):
00099                         sys.stdout.write("%s: %s: %s\n" % (fn, lineno, line))
00100                         hits = hits + 1
00101         if hits:
00102             if hits == 1:
00103                 s = ""
00104             else:
00105                 s = "s"
00106             print("Found", hits, "hit%s." % s)
00107             print("(Hint: right-click to open locations.)")
00108         else:
00109             print("No hits.")

Here is the call graph for this function:

Here is the caller graph for this function:

def idlelib.SearchDialogBase.SearchDialogBase.make_button (   self,
  label,
  command,
  isdef = 0 
) [inherited]

Definition at line 69 of file SearchDialogBase.py.

00069 
00070     def make_button(self, label, command, isdef=0):
00071         b = Button(self.buttonframe,
00072                    text=label, command=command,
00073                    default=isdef and "active" or "normal")
00074         cols,rows=self.buttonframe.grid_size()
00075         b.grid(pady=1,row=rows,column=0,sticky="ew")
00076         self.buttonframe.grid(rowspan=rows+1)
00077         return b

Here is the caller graph for this function:

def idlelib.SearchDialogBase.SearchDialogBase.make_entry (   self,
  label,
  var 
) [inherited]

Definition at line 52 of file SearchDialogBase.py.

00052 
00053     def make_entry(self, label, var):
00054         l = Label(self.top, text=label)
00055         l.grid(row=self.row, column=0, sticky="nw")
00056         e = Entry(self.top, textvariable=var, exportselection=0)
00057         e.grid(row=self.row, column=1, sticky="nwe")
00058         self.row = self.row + 1
00059         return e

def idlelib.SearchDialogBase.SearchDialogBase.make_frame (   self,
  labeltext = None 
) [inherited]

Definition at line 60 of file SearchDialogBase.py.

00060 
00061     def make_frame(self,labeltext=None):
00062         if labeltext:
00063             l = Label(self.top, text=labeltext)
00064             l.grid(row=self.row, column=0, sticky="nw")
00065         f = Frame(self.top)
00066         f.grid(row=self.row, column=1, columnspan=1, sticky="nwe")
00067         self.row = self.row + 1
00068         return f

Here is the caller graph for this function:

def idlelib.SearchDialogBase.SearchDialogBase.open (   self,
  text,
  searchphrase = None 
) [inherited]

Definition at line 14 of file SearchDialogBase.py.

00014 
00015     def open(self, text, searchphrase=None):
00016         self.text = text
00017         if not self.top:
00018             self.create_widgets()
00019         else:
00020             self.top.deiconify()
00021             self.top.tkraise()
00022         if searchphrase:
00023             self.ent.delete(0,"end")
00024             self.ent.insert("end",searchphrase)
00025         self.ent.focus_set()
00026         self.ent.selection_range(0, "end")
00027         self.ent.icursor(0)
00028         self.top.grab_set()

def idlelib.GrepDialog.GrepDialog.open (   self,
  text,
  searchphrase,
  io = None 
)

Definition at line 29 of file GrepDialog.py.

00029 
00030     def open(self, text, searchphrase, io=None):
00031         SearchDialogBase.open(self, text, searchphrase)
00032         if io:
00033             path = io.filename or ""
00034         else:
00035             path = ""
00036         dir, base = os.path.split(path)
00037         head, tail = os.path.splitext(base)
00038         if not tail:
00039             tail = ".py"
00040         self.globvar.set(os.path.join(dir, "*" + tail))


Member Data Documentation

Definition at line 136 of file SearchDialogBase.py.

Definition at line 11 of file SearchDialogBase.py.

Definition at line 79 of file SearchDialogBase.py.

Definition at line 25 of file GrepDialog.py.

Definition at line 43 of file GrepDialog.py.

Definition at line 26 of file GrepDialog.py.

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 20 of file GrepDialog.py.

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 21 of file GrepDialog.py.

Definition at line 27 of file GrepDialog.py.

Definition at line 10 of file SearchDialogBase.py.

Definition at line 43 of file SearchDialogBase.py.

Definition at line 15 of file SearchDialogBase.py.

string idlelib.GrepDialog.GrepDialog.title = "Find in Files Dialog" [static]

Reimplemented from idlelib.SearchDialogBase.SearchDialogBase.

Definition at line 19 of file GrepDialog.py.

Definition at line 12 of file SearchDialogBase.py.


The documentation for this class was generated from the following file: