Skip to content

Commit

Permalink
remove unused, untested function
Browse files Browse the repository at this point in the history
There is a split_commas function in daf_butler that can be used.
It can be extended to do type conversion (as this one did, to
int), or we could write a helper to convert a list of Any items
to a list of int items that could be chained with split_commas.
  • Loading branch information
n8pease committed Apr 1, 2022
1 parent 6ef3868 commit 0bd8a5f
Showing 1 changed file with 0 additions and 38 deletions.
38 changes: 0 additions & 38 deletions python/lsst/ctrl/mpexec/cli/opt/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,6 @@
import click
from lsst.daf.butler.cli.utils import MWOptionDecorator, MWPath, split_commas, unwrap


def _split_commas_int(context, param, values):
"""Special callback that handles comma-separated list of integers.
Parameters
----------
context : `click.Context` or `None`
The current execution context.
param : `click.core.Option` or `None`
The parameter being handled.
values : `list` [ `str` ]
All the values passed for this option. Strings may contain commas,
which will be treated as delimiters for separate values.
Returns
-------
numbers : `tuple` [ `int` ]
The passed in values separated by commas and combined into a single
list.
"""

def _to_int(value):
"""Convert string to integer, handle errors."""
try:
return int(value)
except ValueError:
raise click.BadParameter(
message=f"'{value}' is not a valid integer",
ctx=context,
param=param,
)

values = split_commas(context, param, values)
if values is None:
return values
return tuple(_to_int(value) for value in values)


butler_config_option = MWOptionDecorator(
"-b", "--butler-config", help="Location of the gen3 butler/registry config file."
)
Expand Down

0 comments on commit 0bd8a5f

Please sign in to comment.