@@ -38,13 +38,11 @@ def label(self):
3838
3939 @classmethod
4040 def from_dict (cls , dictionary : Dict [str , Any ]):
41- return Option (value = dictionary ["value" ],
42- schema_id = dictionary .get ("schemaNodeId" , None ),
43- feature_schema_id = dictionary .get ("featureSchemaId" , None ),
44- options = [
45- Classification .from_dict (o )
46- for o in dictionary .get ("options" , [])
47- ])
41+ return cls (
42+ value = dictionary ["value" ],
43+ schema_id = dictionary .get ("schemaNodeId" , None ),
44+ feature_schema_id = dictionary .get ("featureSchemaId" , None ),
45+ options = [cls .from_dict (o ) for o in dictionary .get ("options" , [])])
4846
4947 def asdict (self ) -> Dict [str , Any ]:
5048 return {
@@ -117,16 +115,15 @@ def name(self):
117115
118116 @classmethod
119117 def from_dict (cls , dictionary : Dict [str , Any ]):
120- return Classification (
121- class_type = Classification .Type (dictionary ["type" ]),
122- instructions = dictionary ["instructions" ],
123- required = dictionary .get ("required" , False ),
124- options = [Option .from_dict (o ) for o in dictionary ["options" ]],
125- schema_id = dictionary .get ("schemaNodeId" , None ),
126- feature_schema_id = dictionary .get ("featureSchemaId" , None ))
118+ return cls (class_type = cls .Type (dictionary ["type" ]),
119+ instructions = dictionary ["instructions" ],
120+ required = dictionary .get ("required" , False ),
121+ options = [Option .from_dict (o ) for o in dictionary ["options" ]],
122+ schema_id = dictionary .get ("schemaNodeId" , None ),
123+ feature_schema_id = dictionary .get ("featureSchemaId" , None ))
127124
128125 def asdict (self ) -> Dict [str , Any ]:
129- if self .class_type in Classification ._REQUIRES_OPTIONS \
126+ if self .class_type in self ._REQUIRES_OPTIONS \
130127 and len (self .options ) < 1 :
131128 raise InconsistentOntologyException (
132129 f"Classification '{ self .instructions } ' requires options." )
@@ -197,16 +194,16 @@ class Type(Enum):
197194
198195 @classmethod
199196 def from_dict (cls , dictionary : Dict [str , Any ]):
200- return Tool (name = dictionary ['name' ],
201- schema_id = dictionary .get ("schemaNodeId" , None ),
202- feature_schema_id = dictionary .get ("featureSchemaId" , None ),
203- required = dictionary .get ("required" , False ),
204- tool = Tool .Type (dictionary ["tool" ]),
205- classifications = [
206- Classification .from_dict (c )
207- for c in dictionary ["classifications" ]
208- ],
209- color = dictionary ["color" ])
197+ return cls (name = dictionary ['name' ],
198+ schema_id = dictionary .get ("schemaNodeId" , None ),
199+ feature_schema_id = dictionary .get ("featureSchemaId" , None ),
200+ required = dictionary .get ("required" , False ),
201+ tool = cls .Type (dictionary ["tool" ]),
202+ classifications = [
203+ Classification .from_dict (c )
204+ for c in dictionary ["classifications" ]
205+ ],
206+ color = dictionary ["color" ])
210207
211208 def asdict (self ) -> Dict [str , Any ]:
212209 return {
@@ -307,12 +304,11 @@ class OntologyBuilder:
307304
308305 @classmethod
309306 def from_dict (cls , dictionary : Dict [str , Any ]):
310- return OntologyBuilder (
311- tools = [Tool .from_dict (t ) for t in dictionary ["tools" ]],
312- classifications = [
313- Classification .from_dict (c )
314- for c in dictionary ["classifications" ]
315- ])
307+ return cls (tools = [Tool .from_dict (t ) for t in dictionary ["tools" ]],
308+ classifications = [
309+ Classification .from_dict (c )
310+ for c in dictionary ["classifications" ]
311+ ])
316312
317313 def asdict (self ):
318314 self ._update_colors ()
@@ -334,7 +330,7 @@ def _update_colors(self):
334330 @classmethod
335331 def from_project (cls , project : Project ):
336332 ontology = project .ontology ().normalized
337- return OntologyBuilder .from_dict (ontology )
333+ return cls .from_dict (ontology )
338334
339335 def add_tool (self , tool : Tool ):
340336 if tool .name in (t .name for t in self .tools ):
0 commit comments