summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--obnamlib/__init__.py1
-rw-r--r--obnamlib/nodestorevfs.py50
-rw-r--r--obnamlib/store.py35
-rw-r--r--without-tests1
4 files changed, 54 insertions, 33 deletions
diff --git a/obnamlib/__init__.py b/obnamlib/__init__.py
index c31abaf3..a1d812a6 100644
--- a/obnamlib/__init__.py
+++ b/obnamlib/__init__.py
@@ -42,6 +42,7 @@ from vfs import VirtualFileSystem, VfsFactory, VfsTests
from vfs_local import LocalFS
from metadata import (read_metadata, set_metadata, Metadata, metadata_fields,
metadata_verify_fields)
+from nodestorevfs import NodeStoreVfs
from store import Store, LockFail
from forget_policy import ForgetPolicy
from app import App
diff --git a/obnamlib/nodestorevfs.py b/obnamlib/nodestorevfs.py
new file mode 100644
index 00000000..fbdc0a11
--- /dev/null
+++ b/obnamlib/nodestorevfs.py
@@ -0,0 +1,50 @@
+# Copyright 2010 Lars Wirzenius
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+
+import btree
+
+
+class NodeStoreVfs(btree.NodeStoreDisk):
+
+ def __init__(self, fs, dirname, node_size, codec, upload_queue_size,
+ lru_size):
+ btree.NodeStoreDisk.__init__(self, dirname, node_size, codec,
+ upload_max=upload_queue_size,
+ lru_size=lru_size)
+ self.fs = fs
+
+ def mkdir(self, dirname):
+ if not self.fs.exists(dirname):
+ self.fs.makedirs(dirname)
+
+ def read_file(self, filename):
+ return self.fs.cat(filename)
+
+ def write_file(self, filename, contents):
+ self.fs.overwrite_file(filename, contents, make_backup=False)
+
+ def file_exists(self, filename):
+ return self.fs.exists(filename)
+
+ def rename_file(self, old, new):
+ self.fs.rename(old, new)
+
+ def remove_file(self, filename): # pragma: no cover
+ self.fs.remove(filename)
+
+ def listdir(self, dirname): # pragma: no cover
+ return self.fs.listdir(dirname)
+
diff --git a/obnamlib/store.py b/obnamlib/store.py
index 8faaef60..a01e764b 100644
--- a/obnamlib/store.py
+++ b/obnamlib/store.py
@@ -124,38 +124,6 @@ def decode_metadata(encoded):
return obnamlib.Metadata(**args)
-class NodeStoreVfs(btree.NodeStoreDisk):
-
- def __init__(self, fs, dirname, node_size, codec, upload_queue_size,
- lru_size):
- btree.NodeStoreDisk.__init__(self, dirname, node_size, codec,
- upload_max=upload_queue_size,
- lru_size=lru_size)
- self.fs = fs
-
- def mkdir(self, dirname):
- if not self.fs.exists(dirname):
- self.fs.makedirs(dirname)
-
- def read_file(self, filename):
- return self.fs.cat(filename)
-
- def write_file(self, filename, contents):
- self.fs.overwrite_file(filename, contents, make_backup=False)
-
- def file_exists(self, filename):
- return self.fs.exists(filename)
-
- def rename_file(self, old, new):
- self.fs.rename(old, new)
-
- def remove_file(self, filename): # pragma: no cover
- self.fs.remove(filename)
-
- def listdir(self, dirname): # pragma: no cover
- return self.fs.listdir(dirname)
-
-
class StoreTree(object):
'''A B-tree within a Store.'''
@@ -175,7 +143,8 @@ class StoreTree(object):
if not self.fs.exists(self.dirname):
return False
codec = btree.NodeCodec(self.key_bytes)
- ns = NodeStoreVfs(self.fs, self.dirname, self.node_size, codec,
+ ns = obnamlib.NodeStoreVfs(self.fs,
+ self.dirname, self.node_size, codec,
self.upload_queue_size, self.lru_size)
self.forest = btree.Forest(ns)
return True
diff --git a/without-tests b/without-tests
index 42660e06..a73a9492 100644
--- a/without-tests
+++ b/without-tests
@@ -20,3 +20,4 @@
./obnamlib/plugins/sftp_plugin.py
./obnamlib/plugins/__init__.py
+./obnamlib/nodestorevfs.py