def retrieve(self, **params):
        """A proxy for Redmine object request which does some extra work for resource retrieval"""
        self.params.update(**params)

        results = []
        total_count = 0
        limit = self.params.get('limit', 0)
        offset = self.params.get('offset', 0)

        if limit == 0:
            limit = 100

        while True:
            try:
                response = self.redmine.request('get', self.url, params=dict(self.params, limit=limit, offset=offset))
            except ResourceNotFoundError:
                # This is the only place we're checking for ResourceRequirementsError
                # because for some POST/PUT/DELETE requests Redmine may also return 404
                # status code instead of 405 which can lead us to improper decisions
                if self.resource_class.requirements:
                    raise ResourceRequirementsError(self.resource_class.requirements)

                raise ResourceNotFoundError

            # A single resource was requested via get()
            if isinstance(response[self.container], dict):
                results = response[self.container]
                total_count = 1
                break

            # Resource supports limit/offset on Redmine level
            if all(response.get(param) is not None for param in ('total_count', 'limit', 'offset')):
                total_count = response['total_count']
                results.extend(response[self.container])

                # We want to get all resources
                if self.params.get('limit', 0) == 0:
                    offset += limit

                    if total_count <= offset:
                        break
                # We want to get only some resources
                else:
                    limit -= 100
                    offset += 100

                    if limit <= 0:
                        break
            # We have to mimic limit/offset if a resource
            # doesn't support this feature on Redmine level
            else:
                total_count = len(response[self.container])
                results = response[self.container][offset:None if self.params.get('limit', 0) == 0 else limit + offset]
                break

        return results, total_count
dataset/ETHPy150Open maxtepkeev/python-redmine/redmine/managers.py/ResourceManager.retrieve/original