@@ -40,13 +40,11 @@ def label(self):
4040
4141 @classmethod
4242 def from_dict (cls , dictionary : Dict [str , Any ]):
43- return Option (value = dictionary ["value" ],
44- schema_id = dictionary .get ("schemaNodeId" , None ),
45- feature_schema_id = dictionary .get ("featureSchemaId" , None ),
46- options = [
47- Classification .from_dict (o )
48- for o in dictionary .get ("options" , [])
49- ])
43+ return cls (
44+ value = dictionary ["value" ],
45+ schema_id = dictionary .get ("schemaNodeId" , None ),
46+ feature_schema_id = dictionary .get ("featureSchemaId" , None ),
47+ options = [cls .from_dict (o ) for o in dictionary .get ("options" , [])])
5048
5149 def asdict (self ) -> Dict [str , Any ]:
5250 return {
@@ -119,16 +117,15 @@ def name(self):
119117
120118 @classmethod
121119 def from_dict (cls , dictionary : Dict [str , Any ]):
122- return Classification (
123- class_type = Classification .Type (dictionary ["type" ]),
124- instructions = dictionary ["instructions" ],
125- required = dictionary .get ("required" , False ),
126- options = [Option .from_dict (o ) for o in dictionary ["options" ]],
127- schema_id = dictionary .get ("schemaNodeId" , None ),
128- feature_schema_id = dictionary .get ("featureSchemaId" , None ))
120+ return cls (class_type = cls .Type (dictionary ["type" ]),
121+ instructions = dictionary ["instructions" ],
122+ required = dictionary .get ("required" , False ),
123+ options = [Option .from_dict (o ) for o in dictionary ["options" ]],
124+ schema_id = dictionary .get ("schemaNodeId" , None ),
125+ feature_schema_id = dictionary .get ("featureSchemaId" , None ))
129126
130127 def asdict (self ) -> Dict [str , Any ]:
131- if self .class_type in Classification ._REQUIRES_OPTIONS \
128+ if self .class_type in self ._REQUIRES_OPTIONS \
132129 and len (self .options ) < 1 :
133130 raise InconsistentOntologyException (
134131 f"Classification '{ self .instructions } ' requires options." )
@@ -199,16 +196,16 @@ class Type(Enum):
199196
200197 @classmethod
201198 def from_dict (cls , dictionary : Dict [str , Any ]):
202- return Tool (name = dictionary ['name' ],
203- schema_id = dictionary .get ("schemaNodeId" , None ),
204- feature_schema_id = dictionary .get ("featureSchemaId" , None ),
205- required = dictionary .get ("required" , False ),
206- tool = Tool .Type (dictionary ["tool" ]),
207- classifications = [
208- Classification .from_dict (c )
209- for c in dictionary ["classifications" ]
210- ],
211- color = dictionary ["color" ])
199+ return cls (name = dictionary ['name' ],
200+ schema_id = dictionary .get ("schemaNodeId" , None ),
201+ feature_schema_id = dictionary .get ("featureSchemaId" , None ),
202+ required = dictionary .get ("required" , False ),
203+ tool = cls .Type (dictionary ["tool" ]),
204+ classifications = [
205+ Classification .from_dict (c )
206+ for c in dictionary ["classifications" ]
207+ ],
208+ color = dictionary ["color" ])
212209
213210 def asdict (self ) -> Dict [str , Any ]:
214211 return {
@@ -309,12 +306,11 @@ class OntologyBuilder:
309306
310307 @classmethod
311308 def from_dict (cls , dictionary : Dict [str , Any ]):
312- return OntologyBuilder (
313- tools = [Tool .from_dict (t ) for t in dictionary ["tools" ]],
314- classifications = [
315- Classification .from_dict (c )
316- for c in dictionary ["classifications" ]
317- ])
309+ return cls (tools = [Tool .from_dict (t ) for t in dictionary ["tools" ]],
310+ classifications = [
311+ Classification .from_dict (c )
312+ for c in dictionary ["classifications" ]
313+ ])
318314
319315 def asdict (self ):
320316 self ._update_colors ()
@@ -336,7 +332,7 @@ def _update_colors(self):
336332 @classmethod
337333 def from_project (cls , project : "Project" ):
338334 ontology = project .ontology ().normalized
339- return OntologyBuilder .from_dict (ontology )
335+ return cls .from_dict (ontology )
340336
341337 def add_tool (self , tool : Tool ):
342338 if tool .name in (t .name for t in self .tools ):
0 commit comments