diff --git a/src/apex/plugins/apexparadigm/__init__.py b/src/apex/plugins/apexparadigm/__init__.py index b9fe91ba5d7176c1e55cf822f4ca4c93d5bd0156..5cc6a948e20682028e3ddd14bb057ad2ce4da34a 100644 --- a/src/apex/plugins/apexparadigm/__init__.py +++ b/src/apex/plugins/apexparadigm/__init__.py @@ -51,7 +51,7 @@ class ApexParadigmPlugin(object): for hop_index in range(0, len(frame['path'])): hop = frame['path'][hop_index] - if hop[-1] is not '*': + if not apex.routing.is_hop_consumed(hop): split_hop = hop.split('-') node = split_hop[0].upper() if len(split_hop) >= 2 and split_hop[1]: @@ -134,7 +134,7 @@ class ApexParadigmPlugin(object): for hop_index in reversed(range(0, len(frame['path']))): hop = frame['path'][hop_index] # If this is the last node before a spent node, or a spent node itself, we are done - if hop[-1] == '*' or frame['path'][hop_index-1][-1] == '*': + if apex.routing.is_hop_consumed(hop) or apex.routing.is_hop_consumed(frame['path'][hop_index-1]): break split_hop = hop.split('-') node = split_hop[0].upper() @@ -198,7 +198,7 @@ class ApexParadigmPlugin(object): for hop_index in reversed(range(0, len(frame['path']))): hop = frame['path'][hop_index] # If this is the last node before a spent node, or a spent node itself, we are done - if hop[-1] == '*' or frame['path'][hop_index-1][-1] == '*': + if apex.routing.is_hop_consumed(hop) or apex.routing.is_hop_consumed(frame['path'][hop_index-1]): break elif selected_hop and selected_hop['index'] <= hop_index: break @@ -225,7 +225,7 @@ class ApexParadigmPlugin(object): new_path = [] for hop_index in range(0, len(frame['path'])): hop = frame['path'][hop_index] - if hop[-1] != '*': + if not apex.routing.is_hop_consumed(hop): if hop_index == selected_hop['index']: if selected_hop['band_path'] is None: new_path += [hop + '*'] diff --git a/src/apex/routing/__init__.py b/src/apex/routing/__init__.py index 44ff0f181caa45370293dd2b02e407ad2c5fcd24..f10884d31b5df72b584be624b8f13a6881d1e7e2 100644 --- a/src/apex/routing/__init__.py +++ b/src/apex/routing/__init__.py @@ -7,6 +7,7 @@ from __future__ import division from __future__ import print_function from .route import has_seen # noqa: F401 +from .route import is_hop_consumed # noqa: F401 __author__ = 'Jeffrey Phillips Freeman (WI2ARD)' __maintainer__ = 'Jeffrey Phillips Freeman (WI2ARD)' diff --git a/src/apex/routing/route.py b/src/apex/routing/route.py index 9a8fa2816831212eb611966b816faf3709dcc284..d2bd779688bc2fab5bf9300cb0f614df719d0826 100644 --- a/src/apex/routing/route.py +++ b/src/apex/routing/route.py @@ -27,3 +27,10 @@ def has_seen(port_map, frame): return True return False + + +def is_hop_consumed(hop): + if hop.trim()[-1] is '*': + return True + else: + return False