Rev 3350 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 26-Aug-2011@author: Varun Gupta'''def isValidRule(rule):try:if rule is None:return Falseelif rule['url'] is None:return Falseelif rule['source'] is None:return Falseelse:return Trueexcept KeyError:return Falsedef extractBrandAndName(full_name):brands = ('Micromax', 'BlackBerry', 'Motorola', 'Alcatel', 'Sony Ericsson', 'Apple', \'Spice', 'Nokia', 'HTC', 'Samsung', 'LG', 'Dell')for brand in brands:if full_name.startswith(brand): return (brand, full_name.replace(brand, '').strip())return ("", full_name)def getItemsWithTopScore(items):filterd_items = []top_score = -1.0for item in items:if item['score'] >= top_score:filterd_items.append(item)top_score = item['score']else:return filterd_itemsreturn filterd_itemsdef isPriceSame(items):for i in range(0, items.__len__() - 1):if items[i]['price'] != items[i + 1]['price']: return Falsereturn True