@@ -30,9 +30,10 @@ class Assembly(Datastructure):
3030
3131 def __init__ (self , name = None , ** kwargs ):
3232 super (Assembly , self ).__init__ ()
33- self .attributes = {"name" : name or "Assembly" , "guid_key_map" : {} }
33+ self .attributes = {"name" : name or "Assembly" }
3434 self .attributes .update (kwargs )
3535 self .graph = Graph ()
36+ self ._parts = {}
3637
3738 # ==========================================================================
3839 # data
@@ -65,6 +66,7 @@ def data(self):
6566 def data (self , data ):
6667 self .attributes .update (data ["attributes" ] or {})
6768 self .graph .data = data ["graph" ]
69+ self ._parts = {part .guid : part .key for part in self .parts ()}
6870
6971 # ==========================================================================
7072 # properties
@@ -115,12 +117,11 @@ def add_part(self, part, key=None, **kwargs):
115117 The identifier of the part in the current assembly graph.
116118
117119 """
118- guid_key_map = self .attributes ["guid_key_map" ]
119- if part .guid in guid_key_map .keys ():
120+ if part .guid in self ._parts .keys ():
120121 raise AssemblyError ("Part already added to the assembly" )
121122 key = self .graph .add_node (key = key , part = part , ** kwargs )
122123 part .key = key
123- guid_key_map [part .guid ] = part .key
124+ self . _parts [part .guid ] = part .key
124125 return key
125126
126127 def add_connection (self , a , b , ** kwargs ):
@@ -198,7 +199,7 @@ def find(self, guid):
198199 or None if the part can't be found.
199200
200201 """
201- key = self .attributes [ "guid_key_map" ] .get (guid )
202+ key = self ._parts .get (guid )
202203
203204 if key is None :
204205 return None
0 commit comments