forked from Imagelibrary/littlefs
scripts: csv.py: Fixed NoneType issues with default sort
$ ./scripts/csv.py lfs.code.csv -bfunction -fsize -S ... blablabla ... TypeError: cannot unpack non-iterable NoneType object The issue was argparse's const defaults bypassing the type callback, so the sort field ends up with None when it expects a tuple (well technically a tuple tuple). This is only an issue for csv.py because csv.py's sort fields can contain exprs.
This commit is contained in:
@@ -1264,7 +1264,7 @@ def infer(fields_, results,
|
|||||||
# make sure sort fields are included
|
# make sure sort fields are included
|
||||||
if sort is not None:
|
if sort is not None:
|
||||||
by.extend(k for k, reverse in sort
|
by.extend(k for k, reverse in sort
|
||||||
if k not in by and k not in fields)
|
if k and k not in by and k not in fields)
|
||||||
|
|
||||||
# find best type for all fields used by field exprs
|
# find best type for all fields used by field exprs
|
||||||
fields__ = set(it.chain.from_iterable(
|
fields__ = set(it.chain.from_iterable(
|
||||||
@@ -1891,6 +1891,7 @@ if __name__ == "__main__":
|
|||||||
k.strip(),
|
k.strip(),
|
||||||
RExpr(v) if v is not None else None)
|
RExpr(v) if v is not None else None)
|
||||||
)(*x.split('=', 1)),
|
)(*x.split('=', 1)),
|
||||||
|
const=(None, None),
|
||||||
help="Sort by this field. Can include an expression of the form "
|
help="Sort by this field. Can include an expression of the form "
|
||||||
"field=expr.")
|
"field=expr.")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@@ -1902,6 +1903,7 @@ if __name__ == "__main__":
|
|||||||
k.strip(),
|
k.strip(),
|
||||||
RExpr(v) if v is not None else None)
|
RExpr(v) if v is not None else None)
|
||||||
)(*x.split('=', 1)),
|
)(*x.split('=', 1)),
|
||||||
|
const=(None, None),
|
||||||
help="Sort by this field, but backwards. Can include an expression "
|
help="Sort by this field, but backwards. Can include an expression "
|
||||||
"of the form field=expr.")
|
"of the form field=expr.")
|
||||||
sys.exit(main(**{k: v
|
sys.exit(main(**{k: v
|
||||||
|
|||||||
Reference in New Issue
Block a user