From: Brian Warner Date: Sat, 21 Feb 2009 04:03:09 +0000 (-0700) Subject: storage: move si_b2a/si_a2b/storage_index_to_dir out of server.py and into common.py X-Git-Tag: allmydata-tahoe-1.4.0~166 X-Git-Url: https://git.rkrishnan.org/pf/content/simplejson/decoder.py.html?a=commitdiff_plain;h=d14f00c537114f5693cc6dfbfbff705ca7ed2093;p=tahoe-lafs%2Ftahoe-lafs.git storage: move si_b2a/si_a2b/storage_index_to_dir out of server.py and into common.py --- diff --git a/src/allmydata/storage/common.py b/src/allmydata/storage/common.py index 695c044e..a442dbf4 100644 --- a/src/allmydata/storage/common.py +++ b/src/allmydata/storage/common.py @@ -1,4 +1,17 @@ +import os.path +from allmydata.util import base32 + class DataTooLargeError(Exception): pass + +def si_b2a(storageindex): + return base32.b2a(storageindex) + +def si_a2b(ascii_storageindex): + return base32.a2b(ascii_storageindex) + +def storage_index_to_dir(storageindex): + sia = si_b2a(storageindex) + return os.path.join(sia[:2], sia) diff --git a/src/allmydata/storage/crawler.py b/src/allmydata/storage/crawler.py index abdb0db4..435bd2fa 100644 --- a/src/allmydata/storage/crawler.py +++ b/src/allmydata/storage/crawler.py @@ -3,7 +3,7 @@ import os, time, struct import cPickle as pickle from twisted.internet import reactor from twisted.application import service -from allmydata.storage.server import si_b2a +from allmydata.storage.common import si_b2a from allmydata.util import fileutil class TimeSliceExceeded(Exception): diff --git a/src/allmydata/storage/server.py b/src/allmydata/storage/server.py index 4840cc53..96e5b6ab 100644 --- a/src/allmydata/storage/server.py +++ b/src/allmydata/storage/server.py @@ -8,6 +8,8 @@ from allmydata.interfaces import RIStorageServer, IStatsProducer from allmydata.util import base32, fileutil, log, time_format import allmydata # for __full_version__ +from allmydata.storage.common import si_b2a, si_a2b, storage_index_to_dir +_pyflakes_hush = [si_b2a, si_a2b, storage_index_to_dir] # re-exported from allmydata.storage.lease import LeaseInfo from allmydata.storage.mutable import MutableShareFile, EmptyShare, \ create_mutable_sharefile @@ -26,16 +28,6 @@ from allmydata.storage.immutable import ShareFile, BucketWriter, BucketReader # $SHARENUM matches this regex: NUM_RE=re.compile("^[0-9]+$") -def si_b2a(storageindex): - return base32.b2a(storageindex) - -def si_a2b(ascii_storageindex): - return base32.a2b(ascii_storageindex) - -def storage_index_to_dir(storageindex): - sia = si_b2a(storageindex) - return os.path.join(sia[:2], sia) - class StorageServer(service.MultiService, Referenceable):