summaryrefslogtreecommitdiff
path: root/gitlab/utils.py
blob: 181ca20562776ce5756057a5f15400ade70362dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class _StdoutStream(object):
    def __call__(self, chunk):
        print(chunk)


def response_content(response, streamed, action, chunk_size):
    if streamed is False:
        return response.content

    if action is None:
        action = _StdoutStream()

    for chunk in response.iter_content(chunk_size=chunk_size):
        if chunk:
            action(chunk)