@@ -66,7 +66,7 @@ class ClassKey(Enum):
6666 REPORT = ClassInfo (REPORT_INTERFACE , invoke_name = "Report" )
6767
6868
69- class PurposeKey (Enum ):
69+ class Purpose (Enum ):
7070 """
7171 Purpose of class to be created.
7272 """
@@ -101,39 +101,42 @@ def new_method(proxy, args): # pragma: no cover
101101 setattr (method_class , method_name , new_method )
102102
103103
104- def make_dyn_class (key ):
104+ def make_dyn_class (key , purpose ):
105105 """
106106 Dynamically generate a class from introspection specification.
107107
108108 :param ClassKey key: key that identifies the class to make
109109 """
110- try :
111- klass = make_class (
112- key .value .invoke_name ,
113- ET .fromstring (SPECS [key .value .interface_name ]), # nosec B314
114- TIMEOUT ,
115- )
116-
110+ if purpose is Purpose .INVOKE :
117111 try :
118- if key == ClassKey .MANAGER :
119- _add_abs_path_assertion (klass , "CreatePool" , "devices" )
120- if key == ClassKey .POOL :
121- _add_abs_path_assertion (klass , "InitCache" , "devices" )
122- _add_abs_path_assertion (klass , "AddCacheDevs" , "devices" )
123- _add_abs_path_assertion (klass , "AddDataDevs" , "devices" )
124- except AttributeError as err : # pragma: no cover
125- # This can only happen if the expected method is missing from
126- # the XML spec or code generation has a bug, we will never
127- # test for these conditions.
112+ klass = make_class (
113+ key .value .invoke_name ,
114+ ET .fromstring (SPECS [key .value .interface_name ]), # nosec B314
115+ TIMEOUT ,
116+ )
117+
118+ try :
119+ if key == ClassKey .MANAGER :
120+ _add_abs_path_assertion (klass , "CreatePool" , "devices" )
121+ if key == ClassKey .POOL :
122+ _add_abs_path_assertion (klass , "InitCache" , "devices" )
123+ _add_abs_path_assertion (klass , "AddCacheDevs" , "devices" )
124+ _add_abs_path_assertion (klass , "AddDataDevs" , "devices" )
125+ except AttributeError as err : # pragma: no cover
126+ # This can only happen if the expected method is missing from
127+ # the XML spec or code generation has a bug, we will never
128+ # test for these conditions.
129+ raise StratisCliGenerationError (
130+ "Malformed class definition; could not access a class or "
131+ "method in the generated class definition"
132+ ) from err
133+
134+ return klass
135+
136+ except DPClientGenerationError as err : # pragma: no cover
128137 raise StratisCliGenerationError (
129- "Malformed class definition; could not access a class or "
130- "method in the generated class definition "
138+ f"Failed to generate class { key . value . invoke_name } needed for invoking "
139+ "dbus-python methods "
131140 ) from err
132141
133- return klass
134-
135- except DPClientGenerationError as err : # pragma: no cover
136- raise StratisCliGenerationError (
137- f"Failed to generate class { key .value .invoke_name } needed for invoking "
138- "dbus-python methods"
139- ) from err
142+ assert False # pragma: no cover
0 commit comments