Path and Unicode woes

Discussion in 'Python' started by =?iso-8859-1?B?QW5kcuk=?=, Jan 6, 2006.

  1. 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é
    =?iso-8859-1?B?QW5kcuk=?=, Jan 6, 2006
    #1
    1. Advertising

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

    Fuzzyman Guest

    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
    Fuzzyman, Jan 6, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Smith

    Re: Eclipse tag library path woes

    Chris Smith, Jul 7, 2003, in forum: Java
    Replies:
    0
    Views:
    2,793
    Chris Smith
    Jul 7, 2003
  2. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    958
    Grzegorz ¦liwiñski
    Jan 19, 2011
  3. Karl von Laudermann

    Execution and dos path woes

    Karl von Laudermann, Oct 28, 2004, in forum: Ruby
    Replies:
    2
    Views:
    137
    Matt Mower
    Oct 28, 2004
  4. Chirag Mistry
    Replies:
    6
    Views:
    169
    Ollivier Robert
    Feb 8, 2008
  5. Terry Reedy
    Replies:
    0
    Views:
    73
    Terry Reedy
    Jan 7, 2014
Loading...

Share This Page