@@ -41,39 +41,42 @@ def __init__(self, name=None, **kwargs):
4141 @property
4242 def DATASCHEMA (self ):
4343 import schema
44- return schema .Schema ({
45- "attributes" : dict ,
46- "graph" : Graph ,
47- })
44+
45+ return schema .Schema (
46+ {
47+ "attributes" : dict ,
48+ "graph" : Graph ,
49+ }
50+ )
4851
4952 @property
5053 def JSONSCHEMANAME (self ):
51- return ' assembly'
54+ return " assembly"
5255
5356 @property
5457 def data (self ):
5558 data = {
56- ' attributes' : self .attributes ,
57- ' graph' : self .graph .data ,
59+ " attributes" : self .attributes ,
60+ " graph" : self .graph .data ,
5861 }
5962 return data
6063
6164 @data .setter
6265 def data (self , data ):
63- self .attributes .update (data [' attributes' ] or {})
64- self .graph .data = data [' graph' ]
66+ self .attributes .update (data [" attributes" ] or {})
67+ self .graph .data = data [" graph" ]
6568
6669 # ==========================================================================
6770 # properties
6871 # ==========================================================================
6972
7073 @property
7174 def name (self ):
72- return self .attributes .get (' name' ) or self .__class__ .__name__
75+ return self .attributes .get (" name" ) or self .__class__ .__name__
7376
7477 @name .setter
7578 def name (self , value ):
76- self .attributes [' name' ] = value
79+ self .attributes [" name" ] = value
7780
7881 # ==========================================================================
7982 # customization
@@ -143,10 +146,11 @@ def add_connection(self, a, b, **kwargs):
143146 If `a` and/or `b` are not in the assembly.
144147
145148 """
149+ error_msg = "Both parts have to be added to the assembly before a connection can be created."
146150 if a .key is None or b .key is None :
147- raise AssemblyError ('Both parts have to be added to the assembly before a connection can be created.' )
151+ raise AssemblyError (error_msg )
148152 if not self .graph .has_node (a .key ) or not self .graph .has_node (b .key ):
149- raise AssemblyError ('Both parts have to be added to the assembly before a connection can be created.' )
153+ raise AssemblyError (error_msg )
150154 return self .graph .add_edge (a .key , b .key , ** kwargs )
151155
152156 def parts (self ):
@@ -159,7 +163,7 @@ def parts(self):
159163
160164 """
161165 for node in self .graph .nodes ():
162- yield self .graph .node_attribute (node , ' part' )
166+ yield self .graph .node_attribute (node , " part" )
163167
164168 def connections (self , data = False ):
165169 """Iterate over the connections between the parts.
0 commit comments