Skip to content

Commit

Permalink
convert compute to use FileOutput
Browse files Browse the repository at this point in the history
  • Loading branch information
luizirber committed Jan 21, 2020
1 parent faecba6 commit 69ce7a6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ all: build

build: .PHONY
$(PYTHON) setup.py build_ext -i
cargo build

clean:
$(PYTHON) setup.py clean --all
Expand Down
2 changes: 1 addition & 1 deletion sourmash/cli/compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def subparser(subparsers):
help='recompute signatures even if the file exists'
)
file_args.add_argument(
'-o', '--output', type=FileType('wt'),
'-o', '--output',
help='output computed signatures to this file'
)
file_args.add_argument(
Expand Down
11 changes: 6 additions & 5 deletions sourmash/command_compute.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import screed
import time

from . import sourmash_args
from .signature import SourmashSignature, save_signatures
from .logging import notify, error, set_quiet
from .utils import RustObject
Expand Down Expand Up @@ -273,15 +274,15 @@ def build_siglist(sig, filename, name=None):
return [sig]


def save_siglist(siglist, output_fp, filename=None):
def save_siglist(siglist, sigfile_name, filename=None):
# save!
if output_fp:
sigfile_name = output_fp.name
save_signatures(siglist, output_fp)
if sigfile_name:
with sourmash_args.FileOutput(sigfile_name, 'w') as fp:
save_signatures(siglist, fp)
else:
if filename is None:
raise Exception("internal error, filename is None")
with open(filename, 'w') as fp:
with sourmash_args.FileOutput(filename, 'w') as fp:
sigfile_name = filename
save_signatures(siglist, fp)
notify(
Expand Down

0 comments on commit 69ce7a6

Please sign in to comment.