1- import warnings
2-
31from ngcsimlib .commands .command import Command
42from ngcsimlib .utils import extract_args
5- from ngcsimlib .component_utils import find_compartment
6-
3+ from ngcsimlib .componentUtils import find_compartment
4+ from ngcsimlib . logger import warn , error
75
86class Clamp (Command ):
97 """
@@ -33,11 +31,9 @@ def __init__(self, components=None, compartment=None, clamp_name=None,
3331 super ().__init__ (components = components , command_name = command_name ,
3432 required_calls = ['clamp' ])
3533 if compartment is None :
36- raise RuntimeError (
37- self .name + " requires a \' compartment\' to clamp to for construction" )
34+ error (self .name , "requires a \' compartment\' to clamp to for construction" )
3835 if clamp_name is None :
39- raise RuntimeError (
40- self .name + " requires a \' clamp_name\' to bind to for construction" )
36+ error (self .name , "requires a \' clamp_name\' to bind to for construction" )
4137
4238 self .clamp_name = clamp_name
4339 self .compartment = compartment
@@ -46,23 +42,20 @@ def __init__(self, components=None, compartment=None, clamp_name=None,
4642 _ , mapped_name = find_compartment (component .compartments , component .__class__ , self .compartment )
4743
4844 if mapped_name is None :
49- raise RuntimeError (self .name +
50- " is attempting to initialize clamp to non-existent compartment \" " + self .compartment
51- + "\" on " + name )
45+ error (self .name , " is attempting to initialize clamp to non-existent compartment \" " ,
46+ self .compartment , "\" on " , name , sep = " " )
5247
5348 if mapped_name != self .compartment :
54- warnings .warn (self .name +
55- " is attempting to initialize clamp to a property name, not a compartment of " +
56- name + ". If using a verboseDict and autoMap this will work, otherwise this clamp will "
57- "have unknown behavior" )
49+ warn (self .name , " is attempting to initialize clamp to a property name, not a compartment of " , name ,
50+ ". If using a verboseDict and autoMap this will work, otherwise this clamp will have unknown "
51+ "behavior" , sep = " " )
5852
5953 def __call__ (self , * args , ** kwargs ):
6054 try :
6155 vals = extract_args ([self .clamp_name ], * args , ** kwargs )
6256 except RuntimeError :
63- raise RuntimeError (self .name + ", " + str (
64- self .clamp_name ) + " is missing from keyword arguments or a positional "
65- "arguments can be provided" )
57+ error (self .name , "," , self .clamp_name ,
58+ "is missing from keyword arguments or a positional arguments can be provided" )
6659
6760 for component in self .components :
6861 self .components [component ].clamp (self .compartment , vals [self .clamp_name ])
0 commit comments