473,503 Members | 2,142 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Path and Unicode woes

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é

Jan 6 '06 #1
1 1334
Not full help - but still a pointer.

E%3A/ isn't a unicode issue - but a value that is HTML escaped. MEaning
(I presume without looking it up) 'E:/' - your file path.

All the best,

Fuzzyman
http://www.voidspace.org.uk/python/index.shtml

Jan 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
3869
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
14
2611
by: Thomas Heller | last post by:
I was trying to track down a bug in py2exe where the executable did not work when it is in a directory containing japanese characters. Then, I discovered that part of the problem is in the...
70
4016
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
3
1614
by: Stilgar[bbs.isca.uiowa.edu] | last post by:
I have a VB.NET app that is made up of several fill-in-the-blank-type forms that allows non-technical people convert articles, press releases and publications into XML. For publications created...
0
7205
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7287
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7008
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5594
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5022
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
1521
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
746
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
399
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.