comparison service/mqtt_to_rdf/candidate_binding.py @ 1667:a2347393b43e

comments, debug, dead code
author drewp@bigasterisk.com
date Tue, 21 Sep 2021 22:19:11 -0700
parents 1a7c1261302c
children 3cf7f313b285
comparison
equal deleted inserted replaced
1666:4fd9fdfcf16a 1667:a2347393b43e
10 10
11 log = logging.getLogger('cbind') 11 log = logging.getLogger('cbind')
12 INDENT = ' ' 12 INDENT = ' '
13 13
14 14
15 class BindingConflict(ValueError): 15 class BindingConflict(ValueError): # might be the same as `Inconsistent`
16 pass 16 pass
17 17
18 18
19 @dataclass 19 @dataclass
20 class CandidateBinding: 20 class CandidateBinding:
54 for k, v in newBindings.binding.items(): 54 for k, v in newBindings.binding.items():
55 if k in self.binding and self.binding[k] != v: 55 if k in self.binding and self.binding[k] != v:
56 raise BindingConflict(f'thought {k} would be {self.binding[k]} but another Evaluation said it should be {v}') 56 raise BindingConflict(f'thought {k} would be {self.binding[k]} but another Evaluation said it should be {v}')
57 self.binding[k] = v 57 self.binding[k] = v
58 58
59 def subtract(self, removeBindings: 'CandidateBinding'):
60 for k, v in removeBindings.binding.items():
61 if k in self.binding:
62 del self.binding[k]
63
64 def copy(self): 59 def copy(self):
65 return CandidateBinding(self.binding.copy()) 60 return CandidateBinding(self.binding.copy())
66 61
67 def contains(self, term: BindableTerm): 62 def contains(self, term: BindableTerm):
68 return term in self.binding 63 return term in self.binding