Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #35351 > unrolled thread

Re: pygnomevfs get_local_path_from_uri replacement

Started byChris Rebert <clp2@rebertia.com>
First post2012-12-22 01:34 -0800
Last post2012-12-22 01:34 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: pygnomevfs get_local_path_from_uri replacement Chris Rebert <clp2@rebertia.com> - 2012-12-22 01:34 -0800

#35351 — Re: pygnomevfs get_local_path_from_uri replacement

FromChris Rebert <clp2@rebertia.com>
Date2012-12-22 01:34 -0800
SubjectRe: pygnomevfs get_local_path_from_uri replacement
Message-ID<mailman.1193.1356168885.29569.python-list@python.org>
On Sat, Dec 22, 2012 at 12:57 AM, Daniel Fetchinson
<fetchinson@googlemail.com> wrote:
> 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

Merry Solstice,
Chris

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web