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


Python Item.sanitize_string_value方法代码示例

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


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

示例1: get

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_value [as 别名]
    def get(self, **kwargs):
        """
        Args:
            campaign (id)
            website (id)
            status (string)
            start_date (date)
            end_date (date)
            appeal_id (string)
            appeal_status (string)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'campaign': lambda x: Item.sanitize_integer_value(x, 'campaign', blank=True),
                'website': lambda x: Item.sanitize_integer_value(x, 'website', blank=True),
                'status': lambda x: Item.sanitize_string_value(x, 'status', blank=True),
                'start_date': lambda x: Item.sanitize_string_value(x, 'start_date', blank=True),
                'end_date': lambda x: Item.sanitize_string_value(x, 'end_date', blank=True),
                'appeal_id': lambda x: Item.sanitize_string_value(x, 'appeal_id', blank=True),
                'appeal_status': lambda x: Item.sanitize_string_value(x, 'appeal_status', blank=True),
            }
        }

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

示例2: get

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_value [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: get

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_value [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

示例4: getOne

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_value [as 别名]
    def getOne(self, code='ru'):
        """
        Args:
            code (str)

        """

        request_data = {
            'url': self.SINGLE_URL,
            'code': Item.sanitize_string_value(code, 'code', 2, 2, False)
        }

        return self.transport.get().request(**request_data)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:15,代码来源:auxiliary.py

示例5: get

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

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

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

示例6: getOne

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_value [as 别名]
    def getOne(self, news_id, **kwargs):
        """
        Args:
            news_id (int)
            language (str)

        """
        request_data = {
            'url': self.SINGLE_URL,
            'news_id': self.sanitize_id(news_id)
        }

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

        return self.transport.get().set_filtering(filtering).request(**request_data)
开发者ID:admitad,项目名称:admitad-python-api,代码行数:22,代码来源:news.py

示例7: test_sanitize_fields

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_value [as 别名]
    def test_sanitize_fields(self):
        fields = {
            'field1': lambda x: Item.sanitize_non_blank_value(x, ''),
            'field2': lambda x: Item.sanitize_integer_value(x, ''),
            'field3': lambda x: Item.sanitize_string_value(x, '', blank=True),
        }

        data = Item.sanitize_fields(fields, field1='foobarbaz', field2=42, field3='')

        self.assertDictEqual(data, {
            'field1': 'foobarbaz',
            'field2': 42,
            'field3': ''
        })

        data = Item.sanitize_fields(fields, field1='foobarbaz', field2=42, field3='', field4='another')

        self.assertDictEqual(data, {
            'field1': 'foobarbaz',
            'field2': 42,
            'field3': ''
        })
开发者ID:admitad,项目名称:admitad-python-api,代码行数:24,代码来源:test_base.py

示例8: get

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

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'website': lambda x: Item.sanitize_integer_value(x, 'website', blank=True),
                'has_tool': lambda x: Item.sanitize_string_array(x, 'has_tool', blank=True),
                'language': lambda x: Item.sanitize_string_value(x, 'language', blank=True),
            }
        }

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

示例9: test_sanitize_string_value

# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_value [as 别名]
    def test_sanitize_string_value(self):
        self.assertEqual(Item.sanitize_string_value('foo', '', 10, None, False), 'foo')
        self.assertEqual(Item.sanitize_string_value('foo', '', None, 2, False), 'foo')
        self.assertEqual(Item.sanitize_string_value('foobarbaz', '', 10, 5, False), 'foobarbaz')
        self.assertEqual(Item.sanitize_string_value('', '', None, None, True), '')

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


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