Example #1
0
class StreamContent(object):
    def __init__(self, content):

        if isinstance(content, text_type):
            content = content.encode("utf8")

        self._content = BytesIO(content)

    def stream(self, *args, **kwargs):

        return self._content.__iter__()
Example #2
0
class StreamContent(object):
    def __init__(self, content):

        if isinstance(content, text_type):
            content = content.encode('utf8')

        self._content = BytesIO(content)

    def stream(self, *args, **kwargs):

        return self._content.__iter__()
Example #3
0
class DummyFile(object):
    def __init__(self, data):
        self.buffer = BytesIO(data)

    def read(self, amt=None):
        return self.buffer.read(amt)

    def fileno(self):
        return -1

    def readline(self):
        self.buffer.readline()

    def __iter__(self):
        return self.buffer.__iter__()
Example #4
0
class DummyFile(object):
    def __init__(self, data):
        self.buffer = BytesIO(data)

    def read(self, amt=None):
        return self.buffer.read(amt)

    def fileno(self):
        return -1

    def readline(self):
        self.buffer.readline()

    def __iter__(self):
        return self.buffer.__iter__()
Example #5
0
class StreamContent(object):

    def __init__(self, content):

        if not hasattr(content, '__iter__'):
            self._content = BytesIO(content)
        else:
            self._content = content

    def read(self, *args, **kwargs):

        return self._content.read(*args, **kwargs)

    def stream(self, *args, **kwargs):

        return self._content.__iter__()