當前位置: 首頁>>代碼示例>>Python>>正文


Python Item.sanitize_integer_value方法代碼示例

本文整理匯總了Python中admitad.items.base.Item.sanitize_integer_value方法的典型用法代碼示例。如果您正苦於以下問題:Python Item.sanitize_integer_value方法的具體用法?Python Item.sanitize_integer_value怎麽用?Python Item.sanitize_integer_value使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在admitad.items.base.Item的用法示例。


在下文中一共展示了Item.sanitize_integer_value方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: get

# 需要導入模塊: from admitad.items.base import Item [as 別名]
# 或者: from admitad.items.base.Item import sanitize_integer_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_integer_value [as 別名]
    def get(self, **kwargs):
        """
        Args:
            campaign (int)
            website (int)
            limit (int)
            offset (int)
            order_by (list of str)

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

        filtering = {
            'filter_by': kwargs,
            'available': {
                'campaign': lambda x: Item.sanitize_integer_value(x, 'campaign', blank=True),
                'website': lambda x: Item.sanitize_integer_value(x, 'campaign', blank=True),
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_ordering(ordering) \
                   .set_filtering(filtering) \
                   .request(url=self.URL)
開發者ID:admitad,項目名稱:admitad-python-api,代碼行數:30,代碼來源:optcodes.py

示例3: get

# 需要導入模塊: from admitad.items.base import Item [as 別名]
# 或者: from admitad.items.base.Item import sanitize_integer_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: get

# 需要導入模塊: from admitad.items.base import Item [as 別名]
# 或者: from admitad.items.base.Item import sanitize_integer_value [as 別名]
    def get(self, **kwargs):
        """
        Args:
            website (int)
            active (bool)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'website': lambda x: Item.sanitize_integer_value(x, 'website', True),
                'active': lambda x: Item.sanitize_bool_integer_value(x, 'active', True)
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(url=self.URL)
開發者ID:admitad,項目名稱:admitad-python-api,代碼行數:23,代碼來源:retag.py

示例5: test_sanitize_fields

# 需要導入模塊: from admitad.items.base import Item [as 別名]
# 或者: from admitad.items.base.Item import sanitize_integer_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

示例6: get

# 需要導入模塊: from admitad.items.base import Item [as 別名]
# 或者: from admitad.items.base.Item import sanitize_integer_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

示例7: get

# 需要導入模塊: from admitad.items.base import Item [as 別名]
# 或者: from admitad.items.base.Item import sanitize_integer_value [as 別名]
    def get(self, **kwargs):
        """
        Args:
            date_start (date)
            date_end (date)
            status (int)
            limit (int)
            offset (int)

        """
        filtering = {
            'filter_by': kwargs,
            'available': {
                'date_start': lambda x: Item.sanitize_date(x, 'date_start', True),
                'date_end': lambda x: Item.sanitize_date(x, 'date_end', True),
                'status': lambda x: Item.sanitize_integer_value(x, 'status', True),
            }
        }

        return self.transport.get() \
                   .set_pagination(**kwargs) \
                   .set_filtering(filtering) \
                   .request(url=self.URL)
開發者ID:admitad,項目名稱:admitad-python-api,代碼行數:25,代碼來源:tickets.py

示例8: test_sanitize_integer_value

# 需要導入模塊: from admitad.items.base import Item [as 別名]
# 或者: from admitad.items.base.Item import sanitize_integer_value [as 別名]
    def test_sanitize_integer_value(self):
        self.assertEqual(Item.sanitize_integer_value(2, '', False), 2)
        self.assertEqual(Item.sanitize_integer_value(0, '', False), 0)
        self.assertEqual(Item.sanitize_integer_value(None, '', True), None)
        self.assertEqual(Item.sanitize_integer_value(2**64, '', False), 2**64)
        self.assertEqual(Item.sanitize_integer_value('64', '', False), '64')

        with self.assertRaises(ValueError):
            Item.sanitize_integer_value(None, '', False)
            Item.sanitize_integer_value(3.14, '', False)
            Item.sanitize_integer_value('foo', '', False)
開發者ID:admitad,項目名稱:admitad-python-api,代碼行數:13,代碼來源:test_base.py


注:本文中的admitad.items.base.Item.sanitize_integer_value方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。