本文整理汇总了Python中admitad.items.base.Item.sanitize_date方法的典型用法代码示例。如果您正苦于以下问题:Python Item.sanitize_date方法的具体用法?Python Item.sanitize_date怎么用?Python Item.sanitize_date使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类admitad.items.base.Item
的用法示例。
在下文中一共展示了Item.sanitize_date方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_date [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: test_sanitize_date
# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_date [as 别名]
def test_sanitize_date(self):
self.assertEqual(Item.sanitize_date(None, '', True), None)
self.assertEqual(Item.sanitize_date(datetime(2020, 1, 1), '', False), '01.01.2020')
self.assertEqual(Item.sanitize_date(date(2020, 1, 1), '', False), '01.01.2020')
self.assertEqual(Item.sanitize_date('01.01.2020', '', False), '01.01.2020')
with self.assertRaises(ValueError):
Item.sanitize_date(None, '', False)
Item.sanitize_date('01/01/2020', '', True)
示例3: get
# 需要导入模块: from admitad.items.base import Item [as 别名]
# 或者: from admitad.items.base.Item import sanitize_date [as 别名]
def get(self, **kwargs):
"""
Args:
date_start (date)
date_end (date)
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)
}
}
return self.transport.get() \
.set_pagination(**kwargs) \
.set_filtering(filtering) \
.request(url=self.URL)