[Idle-dev] EditorWindow.py: Fix the help_url discovery
Josh Robb
josh_robb@fastmail.fm
Tue, 1 Oct 2002 01:23:37 +0200
This is a multi-part message in MIME format.
------=_NextPart_000_01A3_01C268E9.2B1E7440
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
* EditorWindow.py: Fix the help_url discovery code on Win98. (Improves on
Patch #470637 by using pydoc logic).
There is already a patch to do this in the patch manager which is identical
to my origional solution to this problem. However during the writing of the
online help system (patch coming) i discovered that this code already exists
in the pydoc module. This code works on UNIX/Windows i have no idea if it
works on Mac but if it doesn't it should be fixed in pydoc which needs this
logic anyway.
Thoughts?
j.
------=_NextPart_000_01A3_01C268E9.2B1E7440
Content-Type: application/octet-stream;
name="help_url.diff"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="help_url.diff"
Index: EditorWindow.py
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
RCS file: /cvsroot/idlefork/idle/EditorWindow.py,v
retrieving revision 1.32
diff -c -r1.32 EditorWindow.py
*** EditorWindow.py 26 Sep 2002 22:13:22 -0000 1.32
--- EditorWindow.py 30 Sep 2002 22:28:32 -0000
***************
*** 290,319 ****
def help_dialog(self, event=3DNone):
=
fn=3Dos.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
textView.TextViewer(self.top,'Help',fn) =20
! =20
! help_url =3D "http://www.python.org/doc/current/"
! if sys.platform[:3] =3D=3D "win":
! fn =3D os.path.dirname(__file__)
! fn =3D os.path.join(fn, os.pardir, os.pardir, "pythlp.chm")
! fn =3D os.path.normpath(fn)
! if os.path.isfile(fn):
! help_url =3D fn
! else:
! fn =3D os.path.dirname(__file__)
! fn =3D os.path.join(fn, os.pardir, os.pardir, "Doc", =
"index.html")
! fn =3D os.path.normpath(fn)
! if os.path.isfile(fn):
! help_url =3D fn
! del fn
! def python_docs(self, event=3DNone):
! os.startfile(self.help_url)
else:
! def python_docs(self, event=3DNone):
! self.display_docs(self.help_url)
=20
def display_docs(self, url):
webbrowser.open(url)
=20
def cut(self,event):
self.text.event_generate("<<Cut>>")
return "break"
--- 290,324 ----
def help_dialog(self, event=3DNone):
=
fn=3Dos.path.join(os.path.abspath(os.path.dirname(__file__)),'help.txt')
textView.TextViewer(self.top,'Help',fn) =20
!=20
! ## TODO help_url should be user configurable
! ## first time we should ask for location if we can't figure it out =
automagically.
!=20
! #Ka-Ping & co have already figured out how to do this.
! import pydoc
! dirroot =3D pydoc.Helper(None, None).docdir
! fn =3D os.path.join(dirroot, "index.html")
! if os.path.isfile(fn):
! help_url =3D fn
else:
! help_url =3D "http://www.python.org/doc/current/"
! del pydoc, fn, dirroot
=20
def display_docs(self, url):
webbrowser.open(url)
=20
+ if sys.platform[:3] =3D=3D "win":
+ dirroot =3D os.path.dirname(sys.executable)
+ fn =3D os.path.join(dirroot, "pythlp.chm")
+ if os.path.isfile(fn):
+ help_url =3D fn
+ def display_docs(self, url):
+ os.startfile(url)
+ del fn, dirroot
+=20
+ def python_docs(self, event=3DNone):
+ self.display_docs(self.help_url)
+=20
def cut(self,event):
self.text.event_generate("<<Cut>>")
return "break"
------=_NextPart_000_01A3_01C268E9.2B1E7440--