本文整理汇总了Python中admitad.items.base.Item.sanitize_string_array方法的典型用法代码示例。如果您正苦于以下问题:Python Item.sanitize_string_array方法的具体用法?Python Item.sanitize_string_array怎么用?Python Item.sanitize_string_array使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类admitad.items.base.Item
的用法示例。
在下文中一共展示了Item.sanitize_string_array方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_array [as 别名]
def create(self, attachments, **kwargs):
"""
Args:
attachments (list of str)
campaign (int)
website (int)
order_id (str)
order_date (date)
order_price (float)
appeal_id (str)
comment (str)
"""
data = Item.sanitize_fields(self.CREATE_FIELDS, **kwargs)
files = [('attachment', open(item, 'rb')) for item in Item.sanitize_string_array(attachments, 'attachments')]
return self.transport.post().set_data(data).set_files(files).request(url=self.CREATE_URL)
示例2: get
# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_array [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)
示例3: test_sanitize_string_array
# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_string_array [as 别名]
def test_sanitize_string_array(self):
self.assertEqual(Item.sanitize_string_array(None, '', None, None, True), None)
self.assertListEqual(Item.sanitize_string_array([], '', None, None, True), [])
self.assertListEqual(Item.sanitize_string_array('foo', ''), ['foo'])
self.assertListEqual(Item.sanitize_string_array([''], '', None, None, True), [''])
self.assertListEqual(Item.sanitize_string_array(['foo', 'bar'], '', 10, 2, False), ['foo', 'bar'])
self.assertListEqual(Item.sanitize_string_array(['foo', 'bar'], '', None, None, False), ['foo', 'bar'])
with self.assertRaises(ValueError):
Item.sanitize_string_array(None, '', False)
Item.sanitize_string_array([], '', False)
Item.sanitize_string_array([''], '', False)
Item.sanitize_string_array(['foobarbaz'], '', 5, 3, False)
Item.sanitize_string_array(['foobarbaz'], '', 5, None, False)
Item.sanitize_string_array(['foo'], '', None, 5, False)