本文整理匯總了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)