Completed
Push — master ( 95dcbf...7b2c7c )
by Jeffrey
03:59
created

is_hop_consumed()   A

Complexity

Conditions 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
c 1
b 0
f 0
dl 0
loc 5
rs 9.4285
1
#!/usr/bin/env python
2
# -*- coding: utf-8 -*-
3
4
# These imports are for python3 compatability inside python2
5
from __future__ import absolute_import
6
from __future__ import division
7
from __future__ import print_function
8
9
__author__ = 'Jeffrey Phillips Freeman (WI2ARD)'
10
__maintainer__ = 'Jeffrey Phillips Freeman (WI2ARD)'
11
__email__ = '[email protected]'
12
__license__ = 'Apache License, Version 2.0'
13
__copyright__ = 'Copyright 2016, Syncleus, Inc. and contributors'
14
__credits__ = []
15
16
17
def has_seen(port_map, frame):
18
    # Can't digipeat anything when you are the source
19
    for port in port_map.values():
20
        if frame['source'] == port['identifier']:
21
            return True
22
23
    # can't digipeat things we already digipeated.
24
    for hop in frame['path']:
25
        for port in port_map.values():
26
            if hop.startswith(port['identifier']) and hop.endswith('*'):
27
                return True
28
29
    return False
30
31
32
def is_hop_consumed(hop):
33
    if hop.trim()[-1] is '*':
34
        return True
35
    else:
36
        return False
37