Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cee949f

Browse files
committed
Removed old and broken AE-based browser controller, use webbrowser.py
instead. This fixes bug #488420.
1 parent 551ffae commit cee949f

1 file changed

Lines changed: 11 additions & 31 deletions

File tree

Mac/Tools/IDE/PyDocSearch.py

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,22 @@
1-
import aetools
2-
import Standard_Suite
3-
import Required_Suite
4-
import WWW_Suite
51
import re
62
import W
73
import macfs
84
import os
95
import MacPrefs
106
import MacOS
117
import string
8+
import webbrowser
129

13-
if hasattr(WWW_Suite, "WWW_Suite"):
14-
WWW = WWW_Suite.WWW_Suite
15-
else:
16-
WWW = WWW_Suite.WorldWideWeb_suite_2c__as_defined_in_Spyglass_spec_2e_
17-
18-
class WebBrowser(aetools.TalkTo,
19-
Standard_Suite.Standard_Suite,
20-
WWW):
21-
22-
def openfile(self, path, activate = 1):
23-
if activate:
24-
self.activate()
25-
self.OpenURL("file:///" + string.join(string.split(path,':'), '/'))
2610

2711
app = W.getapplication()
2812

29-
#SIGNATURE='MSIE' # MS Explorer
30-
SIGNATURE='MOSS' # Netscape
31-
3213
_titlepat = re.compile('<title>\([^<]*\)</title>')
3314

3415
def sucktitle(path):
3516
f = open(path)
3617
text = f.read(1024) # assume the title is in the first 1024 bytes
3718
f.close()
38-
lowertext = string.lower(text)
19+
lowertext = text.lower()
3920
matcher = _titlepat.search(lowertext)
4021
if matcher:
4122
return matcher.group(1)
@@ -84,25 +65,25 @@ def __init__(self, hits):
8465
map(lambda (c, p): "%s (%d)" % (p, c), hits), ', '), hits)
8566
nicehits.sort()
8667
self.w = W.Window((440, 300), "Search results %d" % _resultscounter, minsize = (200, 100))
87-
self.w.results = TwoLineList((-1, -1, 1, -14), nicehits, self.listhit)
68+
self.w.results = W.TwoLineList((-1, -1, 1, -14), nicehits, self.listhit)
8869
self.w.open()
8970
self.w.bind('return', self.listhit)
9071
self.w.bind('enter', self.listhit)
9172
_resultscounter = _resultscounter + 1
92-
self.browser = None
9373

9474
def listhit(self, isdbl = 1):
9575
if isdbl:
9676
for i in self.w.results.getselection():
97-
if self.browser is None:
98-
self.browser = WebBrowser(SIGNATURE, start = 1)
99-
self.browser.openfile(self.hits[i][1])
77+
path = self.hits[i][1]
78+
url = "file://" + "/".join(path.split(":"))
79+
webbrowser.open(url)
80+
10081

10182
class Status:
10283

10384
def __init__(self):
10485
self.w = W.Dialog((440, 64), "Searching\xc9")
105-
self.w.searching = W.TextBox((4, 4, -4, 16), "DevDev:PyPyDoc 1.5.1:ext:parseTupleAndKeywords.html")
86+
self.w.searching = W.TextBox((4, 4, -4, 16), "")
10687
self.w.hits = W.TextBox((4, 24, -4, 16), "Hits: 0")
10788
self.w.canceltip = W.TextBox((4, 44, -4, 16), "Type cmd-period (.) to cancel.")
10889
self.w.open()
@@ -131,6 +112,7 @@ def match(text, patterns, all):
131112
hits.reverse()
132113
return hits
133114

115+
134116
def dosearch(docpath, searchstring, settings):
135117
(docpath, kind, case, word, tut, lib, ref, ext, api) = settings
136118
books = [(tut, 'tut'), (lib, 'lib'), (ref, 'ref'), (ext, 'ext'), (api, 'api')]
@@ -219,7 +201,7 @@ def __init__(self):
219201
self.w.extending = W.CheckBox((bookstart, 98, -10, 16), "Extending & embedding")
220202
self.w.api = W.CheckBox((bookstart, 118, -10, 16), "C/C++ API")
221203

222-
self.w.setdocfolderbutton = W.Button((10, -30, 80, 16), "Set doc folder", self.setdocpath)
204+
self.w.setdocfolderbutton = W.Button((10, -30, 100, 16), "Set doc folder", self.setdocpath)
223205

224206
if docpath:
225207
self.w.setdefaultbutton(self.w.searchbutton)
@@ -229,7 +211,7 @@ def __init__(self):
229211
self.docpath = docpath
230212
if not docpath:
231213
docpath = "(please select the Python html documentation folder)"
232-
self.w.docfolder = W.TextBox((100, -28, -10, 16), docpath)
214+
self.w.docfolder = W.TextBox((120, -28, -10, 16), docpath)
233215

234216
[self.w.phraseradio, self.w.allwordsradio, self.w.anywordsradio][kind].set(1)
235217

@@ -252,8 +234,6 @@ def search(self):
252234
Results(hits)
253235
elif hasattr(MacOS, 'SysBeep'):
254236
MacOS.SysBeep(0)
255-
#import PyBrowser
256-
#PyBrowser.Browser(hits)
257237

258238
def setdocpath(self):
259239
fss, ok = macfs.GetDirectory()

0 commit comments

Comments
 (0)