Decouple Slipnode from the global slipnet.

This commit is contained in:
Arthur O'Dwyer
2017-04-16 23:37:35 -07:00
parent 10f65fcf55
commit 63b3fd4999
3 changed files with 6 additions and 11 deletions

View File

@ -1,5 +1,3 @@
#from slipnode import Slipnode
class Sliplink(object):
def __init__(self, source, destination, label=None, length=0.0):

View File

@ -265,7 +265,7 @@ class SlipNet(object):
self.__addSlipLink(destination, source, label=self.opposite)
def __addNode(self, name, depth, length=0):
slipnode = Slipnode(name, depth, length)
slipnode = Slipnode(self, name, depth, length)
self.slipnodes += [slipnode]
return slipnode

View File

@ -13,10 +13,11 @@ def jump_threshold():
class Slipnode(object):
# pylint: disable=too-many-instance-attributes
def __init__(self, name, depth, length=0.0):
def __init__(self, slipnet, name, depth, length=0.0):
self.slipnet = slipnet
self.name = name
self.conceptualDepth = depth
self.usualConceptualDepth = depth
self.name = name
self.intrinsicLinkLength = length
self.shrunkLinkLength = length * 0.4
@ -111,9 +112,7 @@ class Slipnode(object):
If no linked node is found, return None
"""
from slipnet import slipnet
if relation == slipnet.identity:
if relation == self.slipnet.identity:
return self
destinations = [l.destination
for l in self.outgoingLinks if l.label == relation]
@ -126,11 +125,9 @@ class Slipnode(object):
If it does not exist return None
"""
from slipnet import slipnet
result = None
if self == destination:
result = slipnet.identity
result = self.slipnet.identity
else:
for link in self.outgoingLinks:
if link.destination == destination: