1111from loam .tools import switch_opt , config_conf_section , set_conf_opt
1212
1313
14- def _actual_index (arg ):
15- """Turn a string in a integer or slice."""
14+ def _slice_or_int (arg ):
15+ """Parse a string into an integer or slice."""
1616 if ':' in arg :
1717 idxs = arg .split (':' )
1818 if len (idxs ) > 3 :
@@ -27,15 +27,15 @@ def _actual_index(arg):
2727 return int (arg )
2828
2929
30- def _index_collection (arg ):
31- """Build an index collection from a command line input."""
32- return [_actual_index (item ) for item in arg .split (',' ) if item ]
30+ def _list_of (from_str ):
31+ """Return fn parsing a str as a comma-separated list of given type."""
32+ def parser (arg ):
33+ return tuple (from_str (v ) for v in map (str .strip , arg .split (',' )) if v )
34+ return parser
3335
3436
35- def _float_list (arg ):
36- """Build a tuple of floats from a command line input."""
37- return tuple (float (val ) for val in arg .split (',' ) if val )
38-
37+ _index_collection = _list_of (_slice_or_int )
38+ _float_list = _list_of (float )
3939
4040HOME_DIR = pathlib .Path .home ()
4141CONFIG_DIR = HOME_DIR / '.config' / 'stagpy'
@@ -164,7 +164,7 @@ def _float_list(arg):
164164 Conf (None , True , None , {'type' : float },
165165 False , 'ending fraction of series to process' )),
166166 ('marktimes' ,
167- Conf ('' , True , 'M' , {},
167+ Conf ('' , True , 'M' , {'type' : _float_list },
168168 False , 'list of times where to put a mark' )),
169169 ('marksteps' ,
170170 Conf ('' , True , 'T' , {'type' : _index_collection },
@@ -187,7 +187,7 @@ def _float_list(arg):
187187CONF_DEF ['plates' ] = OrderedDict ((
188188 ('plot' ,
189189 Conf ('c.T.v2-v2.dv2-v2.topo_top' , True , 'o' ,
190- {'nargs' : '?' , 'const' : '' , 'type' : str }, True ,
190+ {'nargs' : '?' , 'const' : '' }, True ,
191191 'variables to plot, can be a surface field, field, or dv2' )),
192192 ('field' ,
193193 Conf ('eta' , True , None , {},
0 commit comments