source: geniuswebcore/geniusweb/issuevalue/Bid.py@ 65

Last change on this file since 65 was 59, checked in by Wouter Pasman, 3 years ago

#44 manual commit of first public release, because this will cause the dist directory to move

File size: 1.4 KB
Line 
1from typing import Any, Dict, Union
2from geniusweb.issuevalue.Value import Value
3
4NoneType=type(None)
5
6class Bid:
7 def __init__(self, issuevalues:Dict[str, Value]):
8 '''
9 FIXME use strict typing
10 '''
11 for (iss,val) in issuevalues.items():
12 if not isinstance(iss, str):
13 raise ValueError("Issue "+str(iss)+" must be a str")
14 if not isinstance(val, Value):
15 raise ValueError("value "+str(val)+" must be a Value, but is "+str(type(val)))
16 self._issuevalues = dict(issuevalues) #shallow copy : Value is immutable
17
18 def getIssueValues(self) -> Dict[str, Value]:
19 return self._issuevalues
20
21 def getIssues(self):
22 return self._issuevalues.keys()
23
24
25 def getValue(self, issue:str) -> Union[Value,NoneType] :
26 '''
27 @param issue name of the issue
28 @return the value for the given issue, or null if there is no value for
29 the given issue.
30 '''
31 if not issue in self._issuevalues:
32 return None
33 return self._issuevalues[issue];
34
35 def __eq__(self, other):
36 return isinstance(other, self.__class__) and \
37 self._issuevalues == other._issuevalues
38
39 def __repr__(self) -> str:
40 return "Bid" + repr( self._issuevalues);
41
42 def __hash__(self):
43 return hash((tuple(self._issuevalues.items())))
44
Note: See TracBrowser for help on using the repository browser.