]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
added is_uri() function to allmydata.uri
authorrobk-tahoe <robk-tahoe@allmydata.com>
Fri, 11 Jan 2008 03:43:42 +0000 (20:43 -0700)
committerrobk-tahoe <robk-tahoe@allmydata.com>
Fri, 11 Jan 2008 03:43:42 +0000 (20:43 -0700)
src/allmydata/uri.py

index 66a1874b0e5712d498dc0e8533430ad009e73632..51ebec878f0a7365beacb290f91de8a28c2906ce 100644 (file)
@@ -434,6 +434,13 @@ def from_string(s):
 
 registerAdapter(from_string, str, IURI)
 
+def is_uri(s):
+    try:
+        uri = from_string(s)
+        return True
+    except (TypeError, AssertionError):
+        return False
+
 def from_string_dirnode(s):
     u = from_string(s)
     assert IDirnodeURI.providedBy(u)