本文整理匯總了Python中price_watch.models.Product.fetch_all方法的典型用法代碼示例。如果您正苦於以下問題:Python Product.fetch_all方法的具體用法?Python Product.fetch_all怎麽用?Python Product.fetch_all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類price_watch.models.Product
的用法示例。
在下文中一共展示了Product.fetch_all方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: set_package_ratio
# 需要導入模塊: from price_watch.models import Product [as 別名]
# 或者: from price_watch.models.Product import fetch_all [as 別名]
def set_package_ratio():
"""Walk through products and set `package` and `package_ratio`"""
keeper = StorageManager(FileStorage('storage.fs'))
products = Product.fetch_all(keeper)
for product in products:
try:
product.package = product.get_package()
product.package_ratio = product.package.get_ratio(product.category)
print(green(u'Product "{}" updated'.format(product)))
except AttributeError, e:
print(red(u'{} removed'.format(product)))
keeper.delete(product)
except PackageLookupError, e:
logging.debug(e.message.encode('utf-8'))
print(yellow(e.message))
示例2: test_fetch_all
# 需要導入模塊: from price_watch.models import Product [as 別名]
# 或者: from price_watch.models.Product import fetch_all [as 別名]
def test_fetch_all(self):
products = Product.fetch_all(self.keeper)
for product in products:
self.assertIsInstance(product, Product)