本文整理汇总了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)
示例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)
示例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)
示例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)