Path and Unicode woes

  • Thread starter =?iso-8859-1?B?QW5kcuk=?=
  • Start date
?

=?iso-8859-1?B?QW5kcuk=?=

I'm attempting to override a wxHtmlWindow method in order to
pre-process the file before displaying it. I'm using a unicode version
of wxPython. I don't think my problem are wxPython-specific, but
rather a unicode mis-understanding. Consider the following:

.. def OnLinkClicked(self, linkinfo):
.. #adapted from the wxPython demo
.. target_file = linkinfo.GetHref()
.. current = self.GetOpenedPage()
.. path = os.path.dirname(current)
.. print "path = ", path
.. print "current = ", current
.. print "target_file = ", target_file
.. filename = os.path.join(path, target_file)
.. print "filename = ", filename
.. filename = filename.replace('\\','/')
.. print "filename: ", filename+'\n'
.. self.LoadFile(filename)

The first time I *click* on a link, I get the following:


path = E:/Copy of rurple0.9.0.1b/rurple0.9.0.1/html/en
current = E:/Copy of rurple0.9.0.1b/rurple0.9.0.1/html/en/rur.htm.html
target_file = intro/browser.htm
filename = E:/Copy of
rurple0.9.0.1b/rurple0.9.0.1/html/en\intro/browser.htm
filename: E:/Copy of
rurple0.9.0.1b/rurple0.9.0.1/html/en/intro/browser.htm

.... and everything is just fine (the expected file opens in the browser
window). The second time I *click* on a link, I get the following
(note the replacement of "E:" by "/E%3A"):

path = /E%3A/Copy of rurple0.9.0.1b/rurple0.9.0.1/html/en/intro
current = /E%3A/Copy of
rurple0.9.0.1b/rurple0.9.0.1/html/en/intro/browser.htm.html
target_file = explore.htm
filename = /E%3A/Copy of
rurple0.9.0.1b/rurple0.9.0.1/html/en/intro\explore.htm
filename: /E%3A/Copy of
rurple0.9.0.1b/rurple0.9.0.1/html/en/intro/explore.htm

Traceback (most recent call last):
File "E:\Copy of rurple0.9.0.1b\rurple0.9.0.1\rur_py\browser.py",
line 77, in OnLinkClicked
self.LoadFile(filename)
File "E:\Copy of rurple0.9.0.1b\rurple0.9.0.1\rur_py\browser.py",
line 54, in LoadFile
data = open(filename, 'r').read()
IOError: [Errno 2] No such file or directory: u'/E%3A/Copy of
rurple0.9.0.1b/rurple0.9.0.1/html/en/intro/explore.htm'

Any help or pointers would be appreciated...

André
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top