Skip to content

Commit

Permalink
Using Opener instead of argparse.FileType
Browse files Browse the repository at this point in the history
  • Loading branch information
crosenth committed Nov 17, 2023
1 parent 7037e85 commit 2272a1c
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions taxtastic/subcommands/taxtable.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
specified with ``-o/--outfile``.
"""
import argparse
import csv
import logging
import re
Expand All @@ -31,7 +30,7 @@
from itertools import groupby

from taxtastic.taxonomy import Taxonomy
from taxtastic.utils import add_database_args
from taxtastic.utils import add_database_args, Opener

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -93,13 +92,13 @@ def build_parser(parser):
help='one or more space-delimited tax_ids (eg "-t 47770 33945")')

input_group.add_argument(
'-f', '--tax-id-file', metavar='FILE', type=argparse.FileType('rt'),
'-f', '--tax-id-file', metavar='FILE', type=Opener('rt'),
help=('File containing a whitespace-delimited list of '
'tax_ids (ie, separated by tabs, spaces, or newlines.'))

input_group.add_argument(
'-i', '--seq-info',
type=argparse.FileType('rt'),
type=Opener('rt'),
help=('Read tax_ids from sequence info file, minimally '
'containing a column named "tax_id"'))

Expand All @@ -108,7 +107,7 @@ def build_parser(parser):

output_group.add_argument(
'-o', '--outfile',
type=argparse.FileType('wt'),
type=Opener('wt'),
default=sys.stdout,
metavar='FILE',
help=('Output file containing lineages for the specified taxa '
Expand Down

0 comments on commit 2272a1c

Please sign in to comment.