Author: jstowers
Date: Thu Jan 10 10:00:09 2008
New Revision: 1182
URL: http://svn.gnome.org/viewvc/conduit?rev=1182&view=rev
Log:
Add utility function to check a uri exists. Probbably a good idea to port some
of the other dps over to this instead of creating lots of short lived objects
in get_all
Modified:
trunk/conduit/Vfs.py
trunk/test/python-tests/TestCoreVfs.py
Modified: trunk/conduit/Vfs.py
==============================================================================
--- trunk/conduit/Vfs.py (original)
+++ trunk/conduit/Vfs.py Thu Jan 10 10:00:09 2008
@@ -107,6 +107,16 @@
Formats the uri so it can be displayed to the user (strips passwords, etc)
"""
return gnomevfs.format_uri_for_display(uri)
+
+def uri_exists(uri):
+ """
+ @returns: True if the uri exists
+ """
+ try:
+ return gnomevfs.exists(gnomevfs.URI(uri)) == 1
+ except Exception, err:
+ print err
+ return False
#
# For monitoring locations
Modified: trunk/test/python-tests/TestCoreVfs.py
==============================================================================
--- trunk/test/python-tests/TestCoreVfs.py (original)
+++ trunk/test/python-tests/TestCoreVfs.py Thu Jan 10 10:00:09 2008
@@ -13,6 +13,9 @@
ok("Unescape back to original",Vfs.uri_unescape(safe+safeunsafe) ==
safe+unsafe)
ok("Get protocol", Vfs.uri_get_protocol("file:///foo/bar") == "file://")
ok("Get filename", Vfs.uri_get_filename("file:///foo/bar") == "bar")
+ok("file:///home exists", Vfs.uri_exists("file:///home") == True)
+ok("/home exists", Vfs.uri_exists("/home") == True)
+ok("/foo/bar does not exist", Vfs.uri_exists("/foo/bar") == False)
# Test the folder scanner theading stuff
tmpdiruri = Utils.new_tempdir()
_______________________________________________
SVN-commits-list mailing list (read only)
http://mail.gnome.org/mailman/listinfo/svn-commits-list
Want to limit the commits to a few modules? Go to above URL, log in to edit
your options and select the modules ('topics') you want.
Module maintainer? It is possible to set the reply-to to your development
mailing list. Email [EMAIL PROTECTED] if interested.