当前位置: 首页>>代码示例>>Python>>正文


Python Item.sanitize_integer_array方法代码示例

本文整理汇总了Python中admitad.items.base.Item.sanitize_integer_array方法的典型用法代码示例。如果您正苦于以下问题:Python Item.sanitize_integer_array方法的具体用法?Python Item.sanitize_integer_array怎么用?Python Item.sanitize_integer_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在admitad.items.base.Item的用法示例。


在下文中一共展示了Item.sanitize_integer_array方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_integer_array [as 别名]
    def get(self, **kwargs):
        """
        Args:
            website (list of int)
            campaign (list of int)
            search (str)
            reason (int)
            date_start (date)
            date_end (date)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'website': lambda x: Item.sanitize_integer_array(x, 'website', blank=True),
                'campaign': lambda x: Item.sanitize_integer_array(x, 'campaign', blank=True),
                'search': lambda x: Item.sanitize_string_value(x, 'search', blank=True),
                'reason': lambda x: Item.sanitize_integer_value(x, 'reason', blank=True),
                'date_start': lambda x: Item.sanitize_date(x, 'date_start', blank=True),
                'date_end': lambda x: Item.sanitize_date(x, 'date_end', blank=True),
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(url=self.URL)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:31,代码来源:broken_links.py

示例2: get

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_integer_array [as 别名]
    def get(self, **kwargs):
        """
        Args:
            campaign (list of int)
            language (str)
            order_by (str)
            limit (int)
            offset (int)

        """
        ordering = {
            'order_by': kwargs.get('order_by', None),
            'available': self.ORDERING
        }

        filtering = {
            'filter_by': kwargs,
            'available': {
                'campaign': lambda x: Item.sanitize_integer_array(x, 'campaign', True),
                'language': lambda x: Item.sanitize_string_value(x, 'language', 2, 2, True),
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_ordering(ordering) \
                   .set_filtering(filtering) \
                   .request(url=self.URL)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:30,代码来源:auxiliary.py

示例3: resolve

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_integer_array [as 别名]
    def resolve(self, broken_link_ids):
        """
        Args:
            broken_links_ids (list of int)

        """

        filtering = {
            'filter_by': {
                'link_id': broken_link_ids
            },
            'available': {
                'link_id': lambda x: Item.sanitize_integer_array(x, 'link_id', blank=True)
            }
        }

        return self.transport.post() \
                   .set_filtering(filtering) \
                   .request(url=self.RESOLVE_URL)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:21,代码来源:broken_links.py

示例4: test_sanitize_integer_array

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_integer_array [as 别名]
    def test_sanitize_integer_array(self):
        self.assertEqual(Item.sanitize_integer_array(None, '', True), None)
        self.assertEqual(Item.sanitize_integer_array([], '', True), [])
        self.assertListEqual(Item.sanitize_integer_array([0, 1, '12'], '', False), [0, 1, '12'])
        self.assertListEqual(Item.sanitize_integer_array([5, None, '1', None], '', True), [5, None, '1', None])
        self.assertListEqual(Item.sanitize_integer_array(5, ''), [5])

        with self.assertRaises(ValueError):
            Item.sanitize_integer_array(None, '', False)
            Item.sanitize_integer_array([], '', False)
            Item.sanitize_integer_array([1, 2, 3, None, 5], '', False)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:13,代码来源:test_base.py


注:本文中的admitad.items.base.Item.sanitize_integer_array方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。