From 44cd59843259cecc1b6f811c157733c5fcad16bd Mon Sep 17 00:00:00 2001 From: H289364 Date: Mon, 23 Apr 2018 10:07:06 -0400 Subject: [PATCH] display the node when the cycle only contain one node --- pycycle/cli.py | 2 +- pycycle/utils.py | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/pycycle/cli.py b/pycycle/cli.py index 3985fdd..e0ce35c 100644 --- a/pycycle/cli.py +++ b/pycycle/cli.py @@ -74,7 +74,7 @@ def cli(ctx, verbose=False, help=False, source=None, here=False, ignore='', enco if check_if_cycles_exist(root_node): click.echo(crayons.red('Cycle Found :(')) - click.echo(crayons.red(get_cycle_path(root_node))) + click.echo(crayons.red(get_cycle_path(root_node, verbose=verbose))) click.echo(crayons.green("Finished.")) sys.exit(1) else: diff --git a/pycycle/utils.py b/pycycle/utils.py index 4c8394d..ac0a4ae 100644 --- a/pycycle/utils.py +++ b/pycycle/utils.py @@ -213,7 +213,10 @@ def format_path(path): :param path: :return: str """ - if len(path) > 1: + if len(path) == 1: + # print the node path if it recursively import itself + return str(path[0].full_path) + elif len(path) > 1: result = [crayons.yellow(path[0].name)] previous = path[0] @@ -231,8 +234,10 @@ def format_path(path): return '' -def get_cycle_path(root, acc=[], seen=set()): +def get_cycle_path(root, acc=[], seen=set(), verbose=False): for item in root: + if verbose: + click.echo(crayons.yellow('Checking root: {} item: {}'.format(root.name, item.full_path))) if item.full_path in seen: return format_path(acc) seen.add(item.full_path)