File tree 1 file changed +13
-6
lines changed 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change 8
8
chaining together using boolean logic
9
9
"""
10
10
11
- from abc import ABCMeta , abstractmethod
11
+ from abc import abstractmethod
12
12
13
13
14
- class Specification :
15
- __metaclass__ = ABCMeta
14
+ class Specification (object ):
16
15
17
16
def and_specification (self , candidate ):
18
- raise NotImplementedError
17
+ raise NotImplementedError ()
19
18
20
19
def or_specification (self , candidate ):
21
- raise NotImplementedError
20
+ raise NotImplementedError ()
22
21
23
22
def not_specification (self ):
24
- raise NotImplementedError
23
+ raise NotImplementedError ()
25
24
26
25
@abstractmethod
27
26
def is_satisfied_by (self , candidate ):
@@ -101,10 +100,18 @@ def is_satisfied_by(self, candidate):
101
100
print ('Specification' )
102
101
andrey = User ()
103
102
ivan = User (super_user = True )
103
+ vasiliy = 'not User instance'
104
104
105
105
root_specification = UserSpecification ().\
106
106
and_specification (SuperUserSpecification ())
107
107
108
108
print (root_specification .is_satisfied_by (andrey ))
109
109
print (root_specification .is_satisfied_by (ivan ))
110
+ print (root_specification .is_satisfied_by (vasiliy ))
110
111
112
+
113
+ ### OUTPUT ###
114
+ # Specification
115
+ # False
116
+ # True
117
+ # False
You can’t perform that action at this time.
0 commit comments