conduit r1182 - in trunk: conduit test/python-tests
- From: jstowers svn gnome org
- To: svn-commits-list gnome org
- Subject: conduit r1182 - in trunk: conduit test/python-tests
- Date: Thu, 10 Jan 2008 10:00:09 +0000 (GMT)
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()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]