1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-23 00:03:33 +00:00
bazarr/custom_libs/subzero/lib/httpfake.py

47 lines
1,009 B
Python
Raw Normal View History

2019-09-17 02:04:27 +00:00
import six
2018-10-31 16:08:29 +00:00
# coding=utf-8
class PlexPyNativeResponseProxy(object):
"""
The equally stupid counterpart to Sub-Zero.support.lib.PlexPyNativeRequestProxy.
Incompletely mimics a requests response object for the plex.py library to use.
"""
data = None
headers = None
response_code = None
request = None
def __init__(self, response, status_code, request):
if response:
self.data = response.content
self.headers = response.headers
self.response_code = status_code
self.request = request
def content(self):
return self.data
content = property(content)
def status_code(self):
return self.response_code
status_code = property(status_code)
def url(self):
return self.request.url
url = property(url)
def __str__(self):
return str(self.data)
def __unicode__(self):
2019-09-17 02:04:27 +00:00
return six.text_type(self.data)
2018-10-31 16:08:29 +00:00
def __repr__(self):
return repr(self.data)