-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #224 from gunthercox/issue_203
Correct issue with statement response serialization
- Loading branch information
Showing
7 changed files
with
62 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
from .statement import Statement | ||
from .statement import Response | ||
from .response import Response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
class Response(object): | ||
""" | ||
A response represents an entity which response to a statement. | ||
""" | ||
|
||
def __init__(self, text, **kwargs): | ||
self.text = text | ||
self.occurrence = kwargs.get("occurrence", 1) | ||
|
||
def __str__(self): | ||
return self.text | ||
|
||
def __repr__(self): | ||
return "<Response text:%s>" % (self.text) | ||
|
||
def __eq__(self, other): | ||
if not other: | ||
return False | ||
|
||
if isinstance(other, Response): | ||
return self.text == other.text | ||
|
||
return self.text == other | ||
|
||
def serialize(self): | ||
data = {} | ||
|
||
data["text"] = self.text | ||
data["occurrence"] = self.occurrence | ||
|
||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters