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