forked from SAP/python-pyodata
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #2 from mnunzio/async_python_no_duplicate_code
Async python no duplicate code
- Loading branch information
Showing
3 changed files
with
153 additions
and
25 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
""" | ||
Utility class to standardize response | ||
Author: Alberto Moio <email Alberto>, Nunzio Mauro <mnunzio90@gmail.com> | ||
Date: 2017-08-21 | ||
""" | ||
import json | ||
|
||
|
||
class Response: | ||
"""Representation of http response in a standard form already used by handlers""" | ||
|
||
__attrs__ = [ | ||
'content', 'status_code', 'headers', 'url' | ||
] | ||
|
||
def __init__(self): | ||
self.status_code = None | ||
self.headers = None | ||
self.url = None | ||
self.content = None | ||
|
||
@property | ||
def text(self): | ||
"""Textual representation of response content""" | ||
|
||
return self.content.decode('utf-8') | ||
|
||
def json(self): | ||
"""JSON representation of response content""" | ||
|
||
return json.loads(self.text) |
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