File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change 19
19
0
20
20
"""
21
21
22
+ import sys
22
23
from typing import List , Tuple
23
24
24
25
import pslab .protocol as CP
37
38
_SMP = 1
38
39
39
40
41
+ class classmethod_ (classmethod ):
42
+ """Support chaining classmethod and property."""
43
+
44
+ def __init__ (self , f ):
45
+ self .f = f
46
+ super ().__init__ (f )
47
+
48
+ def __get__ (self , obj , cls = None ):
49
+ # classmethod() to support chained decorators; new in python 3.9.
50
+ if sys .version_info < (3 , 9 ) and isinstance (self .f , property ):
51
+ return self .f .__get__ (cls )
52
+ else :
53
+ return super ().__get__ (obj , cls )
54
+
55
+
40
56
class _SPIPrimitive :
41
57
"""SPI primitive commands.
42
58
@@ -69,15 +85,15 @@ class _SPIPrimitive:
69
85
def __init__ (self , device : SerialHandler = None ):
70
86
self ._device = device if device is not None else SerialHandler ()
71
87
72
- @classmethod
88
+ @classmethod_
73
89
@property
74
90
def _frequency (cls ) -> float :
75
91
ppre = cls ._PPRE_MAP [cls ._primary_prescaler ]
76
92
spre = cls ._SPRE_MAP [cls ._secondary_prescaler ]
77
93
78
94
return CP .CLOCK_RATE / (ppre * spre )
79
95
80
- @classmethod
96
+ @classmethod_
81
97
@property
82
98
def _clock_phase (cls ) -> int :
83
99
return (cls ._clock_edge ^ 1 ) & 1
You can’t perform that action at this time.
0 commit comments