def _set_request_kwargs(self):
        try:
            self.scraper.get_main_page_rpt()
        except ObjectDoesNotExist:
            raise CloseSpider("Scraper must have exactly one main page request page type!")

        for rpt in self.scraper.requestpagetype_set.all():
            if rpt.page_type == 'MP':
                pt_dict = self.mp_request_kwargs
            else:
                self.dp_request_kwargs[rpt.page_type] = {}
                pt_dict = self.dp_request_kwargs[rpt.page_type]

            if rpt.headers != '':
                try:
                    headers = json.loads(rpt.headers)
                except ValueError:
                    raise CloseSpider("Incorrect HTTP header attribute ({a}): not a valid JSON dict!".format(a=rpt.page_type))
                if not isinstance(headers, dict):
                    raise CloseSpider("Incorrect HTTP header attribute ({a}): not a valid JSON dict!".format(a=rpt.page_type))
                pt_dict['headers'] = headers

            if rpt.body != '':
                pt_dict['body'] = rpt.body

            if rpt.cookies != '':
                try:
                    cookies = json.loads(rpt.cookies)
                except __HOLE__:
                    raise CloseSpider("Incorrect cookies attribute ({a}): not a valid JSON dict!".format(a=rpt.page_type))
                if not isinstance(cookies, dict):
                    raise CloseSpider("Incorrect cookies attribute ({a}): not a valid JSON dict!".format(a=rpt.page_type))
                pt_dict['cookies'] = cookies

            if rpt.meta != '':
                try:
                    meta = json.loads(rpt.meta)
                except ValueError:
                    raise CloseSpider("Incorrect meta attribute ({a}): not a valid JSON dict!".format(a=rpt.page_type))
                if not isinstance(meta, dict):
                    raise CloseSpider("Incorrect meta attribute ({a}): not a valid JSON dict!".format(a=rpt.page_type))
                pt_dict['meta'] = meta
dataset/ETHPy150Open holgerd77/django-dynamic-scraper/dynamic_scraper/spiders/django_base_spider.py/DjangoBaseSpider._set_request_kwargs