Re: pygnomevfs get_local_path_from_uri replacement

Discussion in 'Python' started by Daniel Fetchinson, Dec 22, 2012.

  1. >> Hi folks, I realize this is slightly off topic and maybe belongs to a
    >> gnome email list but it's nevertheless python:
    >>
    >> I use an old python program that was written for gnome 2 and gtk 2 and
    >> uses the function get_local_path_from_uri. More specifically it uses
    >> gnomevfs.get_local_path_from_uri.
    >>
    >> Now with gnome 3 the module pygnomevfs does not exist anymore and
    >> after checking the source for pygnomevfs it turns out it's written in
    >> C using all the header files and stuff from gnome 2. So I can't just
    >> lift it from the source. I was hoping it's pure python in which case I
    >> could have simply lifted it.
    >>
    >> Does anyone know what a good replacement for get_local_path_from_uri
    >> is? Is there a gtk/gnome/etc related python package that contains it
    >> which would work with gnome 3? Or a totally gnome-independent python
    >> implementation?

    >
    > The commit
    > https://mail.gnome.org/archives/commits-list/2009-May/msg05733.html
    > suggests that get_local_path_from_uri() might have been defined as
    > (taking slight liberties):
    > gnome_vfs_unescape_string(remove_host_from_uri(uri))
    > Assuming these functions do the "obvious" things implied by their
    > names (you can probably chase down the Gnome VFS source or docs to
    > check; I don't care enough to bother), given a general URI
    > "protocol://host/path", it presumably returns either
    > "protocol:///path" (`protocol:` likely being "file:" in this case) or
    > "/path", in either case with `path` having been un-percent-escaped.
    > The latter transform can be done using
    > http://docs.python.org/2/library/urllib.html#urllib.unquote
    >
    > Alternately, you might call the Gnome VFS C API directly via
    > http://docs.python.org/2/library/ctypes.html


    Thanks, ctypes is actually a great idea, I should have thought about that.
    In the meantime I use the simple function

    def get_local_path_from_uri( uri ):

    return uri.split( '//' )[1]


    and it seems to work. In the program the function is always called in
    a try: except: block so if anything is not okay it will get caught, I
    don't have to catch exceptions inside the function.

    Cheers,
    Daniel



    --
    Psss, psss, put it down! - http://www.cafepress.com/putitdown
    Daniel Fetchinson, Dec 22, 2012
    #1
    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. Youhanna Mounir
    Replies:
    3
    Views:
    549
  2. Praveen Pandey

    replacement for ActiveX in .NET

    Praveen Pandey, Dec 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    3,354
    smith
    Dec 8, 2004
  3. Kermit Lowry
    Replies:
    0
    Views:
    369
    Kermit Lowry
    Sep 25, 2003
  4. mail
    Replies:
    1
    Views:
    524
    Will Stranathan
    Mar 2, 2004
  5. Daniel Fetchinson

    pygnomevfs get_local_path_from_uri replacement

    Daniel Fetchinson, Dec 22, 2012, in forum: Python
    Replies:
    0
    Views:
    95
    Daniel Fetchinson
    Dec 22, 2012
Loading...

Share This Page