forked from Imagelibrary/littlefs
scripts: codemap[d3].py: Added -e/--error-on-recursion
Might as well, since we already need to find this to calculate stack info. I've been considering adding -z/--depth to these scripts as well, but that would require quite a bit more work. It's probably not worth the added complexity/headache. Depth termination would need to happen on the javascript side, and we'd still need cycle detection anyways. But an error code is easy to add.
This commit is contained in:
@@ -1247,6 +1247,10 @@ def main_(f, paths, *,
|
||||
line = canvas.draw(row)
|
||||
f.writeln(line)
|
||||
|
||||
if (args.get('error_on_recursion')
|
||||
and mt.isinf(totals.get('stack', 0))):
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
def main(paths, *,
|
||||
height=None,
|
||||
@@ -1496,6 +1500,10 @@ if __name__ == "__main__":
|
||||
'--no-label',
|
||||
action='store_true',
|
||||
help="Don't render any labels.")
|
||||
parser.add_argument(
|
||||
'-e', '--error-on-recursion',
|
||||
action='store_true',
|
||||
help="Error if any functions are recursive.")
|
||||
parser.add_argument(
|
||||
'--code-path',
|
||||
type=lambda x: x.split(),
|
||||
|
||||
@@ -1990,6 +1990,10 @@ def main(paths, output, *,
|
||||
totals.get('stack', 0)),
|
||||
totals.get('ctx', 0)))
|
||||
|
||||
if (args.get('error_on_recursion')
|
||||
and mt.isinf(totals.get('stack', 0))):
|
||||
sys.exit(2)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import argparse
|
||||
@@ -2218,6 +2222,10 @@ if __name__ == "__main__":
|
||||
'--background',
|
||||
help="Background color to use. Note #00000000 can make the "
|
||||
"background transparent.")
|
||||
parser.add_argument(
|
||||
'-e', '--error-on-recursion',
|
||||
action='store_true',
|
||||
help="Error if any functions are recursive.")
|
||||
parser.add_argument(
|
||||
'--code-path',
|
||||
type=lambda x: x.split(),
|
||||
|
||||
Reference in New Issue
Block a user