Skip to content

Commit

Permalink
bikeshed: .sbt.zip instead of just .zip
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Apr 27, 2020
1 parent 47aecfc commit 75e1f78
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
4 changes: 2 additions & 2 deletions sourmash/sbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,11 @@ def save(self, path, storage=None, sparseness=0.0, structure_only=False):
"""
version = 5

if path.endswith(".zip"):
if path.endswith(".sbt.zip"):
storage = ZipStorage(path)
kind = "Zip"
backend = "FSStorage"
subdir = '.sbt.{}'.format(os.path.basename(path[:-4]))
subdir = '.sbt.{}'.format(os.path.basename(path[:-8]))
storage_args = FSStorage("", subdir).init_args()
storage.save(subdir + "/", "")
else:
Expand Down
File renamed without changes.
16 changes: 7 additions & 9 deletions tests/test_sbt.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ def test_sbt_zipstorage(tmpdir):
to_search.data, 0.1)}
print(*old_result, sep='\n')

with ZipStorage(str(tmpdir.join("tree.zip"))) as storage:
with ZipStorage(str(tmpdir.join("tree.sbt.zip"))) as storage:
tree.save(str(tmpdir.join("tree")), storage=storage)

with ZipStorage(str(tmpdir.join("tree.zip"))) as storage:
with ZipStorage(str(tmpdir.join("tree.sbt.zip"))) as storage:
tree = SBT.load(str(tmpdir.join("tree")),
leaf_loader=SigLeaf.load,
storage=storage)
Expand Down Expand Up @@ -471,9 +471,9 @@ def test_sbt_redisstorage():


def test_save_zip(tmpdir):
testdata = utils.get_test_data("v5.zip")
testsbt = tmpdir.join("v5.zip")
newsbt = tmpdir.join("new.zip")
testdata = utils.get_test_data("v5.sbt.zip")
testsbt = tmpdir.join("v5.sbt.zip")
newsbt = tmpdir.join("new.sbt.zip")

shutil.copyfile(testdata, str(testsbt))

Expand All @@ -492,15 +492,13 @@ def test_save_zip(tmpdir):
new_result = {str(s) for s in new_tree.find(search_minhashes, to_search, 0.1)}
print(*new_result, sep="\n")


assert old_result == new_result
assert len(new_result) == 2



def test_load_zip(tmpdir):
testdata = utils.get_test_data("v5.zip")
testsbt = tmpdir.join("v5.zip")
testdata = utils.get_test_data("v5.sbt.zip")
testsbt = tmpdir.join("v5.sbt.zip")

shutil.copyfile(testdata, str(testsbt))

Expand Down

0 comments on commit 75e1f78

Please sign in to comment.