18
18
from types import FunctionType
19
19
from inspect import cleandoc , getsourcelines , currentframe
20
20
from itertools import chain
21
- from textwrap import fill
22
21
from abc import ABCMeta
23
22
from collections import defaultdict
24
23
@@ -123,7 +122,7 @@ def __init__(self, bases=()):
123
122
124
123
def __setattr__ (self , name , value ):
125
124
if isinstance (value , _subpart ):
126
- value . _parent_ = self
125
+ object . __setattr__ ( value , ' _parent_' , self )
127
126
object .__setattr__ (self , name , value )
128
127
129
128
def __call__ (self , func ):
@@ -324,9 +323,6 @@ def __new__(meta, name, bases, dct):
324
323
for key , value in dct .items ():
325
324
326
325
if isinstance (value , _subpart ):
327
- if key in subparts :
328
- msg = 'Attempt to redeclare subpart {}'
329
- raise KeyError (msg .format (key ))
330
326
value ._name_ = key
331
327
subparts [key ] = value
332
328
@@ -621,7 +617,7 @@ def clear_cache(self, subsystems=True, channels=True, features=None):
621
617
for ch in getattr (self , chs ):
622
618
ch .clear_cache (subsystems )
623
619
624
- def check_cache (self , subsystems = True , channels = True , properties = None ):
620
+ def check_cache (self , subsystems = True , channels = True , features = None ):
625
621
"""Return the value of the cache of the object.
626
622
627
623
The cache values for the subsystems and channels are not accessible.
@@ -634,8 +630,8 @@ def check_cache(self, subsystems=True, channels=True, properties=None):
634
630
channels : bool, optional
635
631
Whether or not to include the channels caches. This argument is
636
632
used only if properties is None.
637
- properties : iterable of str, optional
638
- Name of the properties whose cache should be cleared. All caches
633
+ features : iterable of str, optional
634
+ Name of the features whose cache should be cleared. All caches
639
635
will be cleared if not specified.
640
636
641
637
Returns
@@ -646,10 +642,10 @@ def check_cache(self, subsystems=True, channels=True, properties=None):
646
642
647
643
"""
648
644
cache = {}
649
- if properties :
645
+ if features :
650
646
sss = defaultdict (list )
651
647
chs = defaultdict (list )
652
- for name in properties :
648
+ for name in features :
653
649
if '.' in name :
654
650
aux , n = name .split ('.' , 1 )
655
651
if aux in self .__subsystems__ :
@@ -660,7 +656,7 @@ def check_cache(self, subsystems=True, channels=True, properties=None):
660
656
cache [name ] = self ._cache [name ]
661
657
662
658
for ss in sss :
663
- cache [ss ] = getattr (self , ss ).check_cache (properties = sss [ss ])
659
+ cache [ss ] = getattr (self , ss ).check_cache (features = sss [ss ])
664
660
665
661
if self .__channels__ :
666
662
for ch in chs :
@@ -669,7 +665,7 @@ def check_cache(self, subsystems=True, channels=True, properties=None):
669
665
channel_cont = getattr (self , ch )
670
666
for ch_id in channel_cont .available :
671
667
chan = channel_cont [ch_id ]
672
- ch_cache [ch_id ] = chan .check_cache (properties = chs [ch ])
668
+ ch_cache [ch_id ] = chan .check_cache (features = chs [ch ])
673
669
else :
674
670
cache = self ._cache .copy ()
675
671
if subsystems :
@@ -693,7 +689,7 @@ def declared_limits(self):
693
689
Ranges are considered declared as soon as a getter has been defined.
694
690
695
691
"""
696
- return self .__ranges__
692
+ return self .__limits__
697
693
698
694
def get_limits (self , limits_id ):
699
695
"""Access the limits object matching the definition.
@@ -736,13 +732,7 @@ def reopen_connection(self):
736
732
"""Reopen the connection to the instrument.
737
733
738
734
"""
739
- message = fill (cleandoc (
740
- '''This method is used to reopen a connection whose state
741
- is suspect, for example the last message sent did not
742
- go through, and should be implemented by classes
743
- subclassing HasFeatures''' ),
744
- 80 )
745
- raise NotImplementedError (message )
735
+ raise NotImplementedError ()
746
736
747
737
def default_get_feature (self , feat , cmd , * args , ** kwargs ):
748
738
"""Method used by default by the Feature to retrieve a value from an
@@ -762,10 +752,7 @@ def default_get_feature(self, feat, cmd, *args, **kwargs):
762
752
state.
763
753
764
754
"""
765
- mess = fill (cleandoc ('''Method used by default by the Feature to
766
- retrieve a value from an instrument. Should be implemented by
767
- classes subclassing HasFeatures.''' ), 80 )
768
- raise NotImplementedError (mess )
755
+ raise NotImplementedError ()
769
756
770
757
def default_set_feature (self , feat , cmd , * args , ** kwargs ):
771
758
"""Method used by default by the Feature to set an instrument value.
@@ -784,10 +771,7 @@ def default_set_feature(self, feat, cmd, *args, **kwargs):
784
771
state.
785
772
786
773
"""
787
- mess = fill (cleandoc ('''Method used by default by the Feature to
788
- set an instrument value. Should be implemented by
789
- classes subclassing HasFeatures''' ), 80 )
790
- raise NotImplementedError (mess )
774
+ raise NotImplementedError ()
791
775
792
776
def default_check_operation (self , feat , value , i_value , state = None ):
793
777
"""Method used by default by the Feature to check the instrument
@@ -813,10 +797,7 @@ def default_check_operation(self, feat, value, i_value, state=None):
813
797
something should always be returned.
814
798
815
799
"""
816
- mess = fill (cleandoc ('''Method used by default by the Feature to
817
- check the instrument operation. Should be implemented by
818
- classes subclassing HasFeatures.''' ), 80 )
819
- raise NotImplementedError (mess )
800
+ raise NotImplementedError ()
820
801
821
802
822
803
AbstractHasFeatures .register (HasFeatures )
0 commit comments