[conduit] Add Vfs.backend_name() to return the file implementation name
- From: John Stowers <jstowers src gnome org>
- To: svn-commits-list gnome org
- Subject: [conduit] Add Vfs.backend_name() to return the file implementation name
- Date: Fri, 24 Apr 2009 21:31:19 -0400 (EDT)
commit ba6829c8c1cbbf7db69e6ed237522b1067dc32c7
Author: John Stowers <john stowers gmail com>
Date: Sat Apr 25 13:07:38 2009 +1200
Add Vfs.backend_name() to return the file implementation name
---
conduit/Vfs.py | 6 ++++++
conduit/platform/FileGio.py | 1 +
conduit/platform/FileGnomeVfs.py | 1 +
conduit/platform/FilePython.py | 1 +
conduit/platform/__init__.py | 1 +
test/python-tests/TestCoreVfs.py | 2 +-
6 files changed, 11 insertions(+), 1 deletions(-)
diff --git a/conduit/Vfs.py b/conduit/Vfs.py
index 6c66933..62d7f50 100644
--- a/conduit/Vfs.py
+++ b/conduit/Vfs.py
@@ -29,6 +29,12 @@ def backend_supports_remote_uri_schemes():
"""
return len(FileImpl.FileImpl.SCHEMES) > 1 and "file://" in FileImpl.FileImpl.SCHEMES
+def backend_name():
+ """
+ @returns: The name of the selected file impl backend
+ """
+ return FileImpl.FileImpl.NAME
+
def uri_is_valid(uri):
"""
Checks if the uri is valid (i.e. not a local path), and its type
diff --git a/conduit/platform/FileGio.py b/conduit/platform/FileGio.py
index 54bb3bc..b6ab3f0 100644
--- a/conduit/platform/FileGio.py
+++ b/conduit/platform/FileGio.py
@@ -8,6 +8,7 @@ log = logging.getLogger("platform.FileGio")
class FileImpl(conduit.platform.File):
SCHEMES = ("file://","http://","ftp://","smb://")
+ NAME = "GIO"
def __init__(self, URI, impl=None):
if impl:
self._file = impl
diff --git a/conduit/platform/FileGnomeVfs.py b/conduit/platform/FileGnomeVfs.py
index 109bbc5..bba38a7 100644
--- a/conduit/platform/FileGnomeVfs.py
+++ b/conduit/platform/FileGnomeVfs.py
@@ -12,6 +12,7 @@ log = logging.getLogger("platform.FileGnomeVfs")
class FileImpl(conduit.platform.File):
SCHEMES = ("file://","http://","ftp://","smb://")
+ NAME = "GnomeVfs"
def __init__(self, URI, impl=None):
if impl:
self._URI = impl
diff --git a/conduit/platform/FilePython.py b/conduit/platform/FilePython.py
index a25be60..454237e 100644
--- a/conduit/platform/FilePython.py
+++ b/conduit/platform/FilePython.py
@@ -9,6 +9,7 @@ log = logging.getLogger("platform.FilePython")
class FileImpl(conduit.platform.File):
SCHEMES = ("file://",)
+ NAME = "Python"
def __init__(self, URI):
self._path = URI.split("file://")[-1]
diff --git a/conduit/platform/__init__.py b/conduit/platform/__init__.py
index 31b94f0..6851f0f 100644
--- a/conduit/platform/__init__.py
+++ b/conduit/platform/__init__.py
@@ -3,6 +3,7 @@ import gobject
class File:
SCHEMES = ()
+ NAME = None
def __init__(self, URI):
pass
diff --git a/test/python-tests/TestCoreVfs.py b/test/python-tests/TestCoreVfs.py
index 04f444a..a90338a 100644
--- a/test/python-tests/TestCoreVfs.py
+++ b/test/python-tests/TestCoreVfs.py
@@ -8,7 +8,7 @@ for impl in ("GIO", "GnomeVfs",):
reload(Vfs)
reload(Utils)
- ok("--- TESTING VFS WITH FILE IMPL: %s" % impl, True)
+ ok("--- TESTING VFS WITH FILE IMPL: %s" % Vfs.backend_name(), True)
ok("Supports remote uri schemes: %s" % Vfs.backend_supports_remote_uri_schemes(), True)
safe = '/&=:@'
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]