MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / reevaluate

Method reevaluate

tools/python-3.11.9-amd64/Tools/demo/redemo.py:114–159  ·  view source on GitHub ↗
(self, event=None)

Source from the content-addressed store, hash-verified

112 self.reevaluate()
113
114 def reevaluate(self, event=None):
115 try:
116 self.stringdisplay.tag_remove("hit", "1.0", END)
117 except TclError:
118 pass
119 try:
120 self.stringdisplay.tag_remove("hit0", "1.0", END)
121 except TclError:
122 pass
123 self.grouplist.delete(0, END)
124 if not self.compiled:
125 return
126 self.stringdisplay.tag_configure("hit", background="yellow")
127 self.stringdisplay.tag_configure("hit0", background="orange")
128 text = self.stringdisplay.get("1.0", END)
129 last = 0
130 nmatches = 0
131 while last <= len(text):
132 m = self.compiled.search(text, last)
133 if m is None:
134 break
135 first, last = m.span()
136 if last == first:
137 last = first+1
138 tag = "hit0"
139 else:
140 tag = "hit"
141 pfirst = "1.0 + %d chars" % first
142 plast = "1.0 + %d chars" % last
143 self.stringdisplay.tag_add(tag, pfirst, plast)
144 if nmatches == 0:
145 self.stringdisplay.yview_pickplace(pfirst)
146 groups = list(m.groups())
147 groups.insert(0, m.group())
148 for i in range(len(groups)):
149 g = "%2d: %r" % (i, groups[i])
150 self.grouplist.insert(END, g)
151 nmatches = nmatches + 1
152 if self.showvar.get() == "first":
153 break
154
155 if nmatches == 0:
156 self.statusdisplay.config(text="(no match)",
157 background="yellow")
158 else:
159 self.statusdisplay.config(text="")
160
161
162# Main function, run when invoked as a stand-alone Python program.

Callers 1

recompileMethod · 0.95

Calls 13

listFunction · 0.85
spanMethod · 0.80
tag_addMethod · 0.80
yview_pickplaceMethod · 0.80
tag_removeMethod · 0.45
deleteMethod · 0.45
tag_configureMethod · 0.45
getMethod · 0.45
searchMethod · 0.45
groupsMethod · 0.45
insertMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected