Subversion Repositories SmartDukaan

Rev

Rev 3313 | Rev 3453 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3313 Rev 3350
Line 1... Line 1...
1
'''
1
'''
2
Created on 26-Aug-2011
2
Created on 26-Aug-2011
3
 
3
 
4
@author: Varun Gupta
4
@author: Varun Gupta
5
'''
5
'''
6
import json
6
import json, sys, os
-
 
7
 
-
 
8
cmd_folder = os.path.dirname(os.path.abspath(os.environ["HOME"] + "/code/trunk/PyProj/src/shop2020/"))
-
 
9
if cmd_folder not in sys.path:
-
 
10
    sys.path.insert(0, cmd_folder)
-
 
11
 
-
 
12
from shop2020.clients.CatalogClient import CatalogClient
7
 
13
 
8
def isValidRule(rule):
14
def isValidRule(rule):
9
    try:
15
    try:
10
        if rule is None:
16
        if rule is None:
11
            return False
17
            return False
Line 21... Line 27...
21
    
27
    
22
    except KeyError:
28
    except KeyError:
23
        return False
29
        return False
24
    
30
    
25
def extractBrandAndName(full_name):
31
def extractBrandAndName(full_name):
26
    brands = ('Micromax', 'BlackBerry', 'Blackberry', 'Motorola', 'Alcatel', 'Sony Ericsson', 'Apple', \
32
#    brands = ('Micromax', 'BlackBerry', 'Blackberry', 'Motorola', 'Alcatel', 'Sony Ericsson', 'Apple', 'Spice', 'Nokia', 'HTC', 'Samsung', 'LG', 'Dell')
27
              'Spice', 'Nokia', 'HTC', 'Samsung', 'LG', 'Dell')
-
 
28
    
33
    
-
 
34
    try:
-
 
35
        client = CatalogClient().get_client()
-
 
36
        brands = client.getAllBrandsByCategory(10001)
-
 
37
        brands.append('Blackberry') #To resolve issue of 'BlackBerry' and 'Blackberry'
-
 
38
        
-
 
39
        print brands
-
 
40
        
29
    for brand in brands:
41
        for brand in brands:
30
        if full_name.startswith(brand):  return (brand, full_name.replace(brand, '').strip())
42
            if full_name.startswith(brand):  return (brand, full_name.replace(brand, '').strip())
-
 
43
    except Exception as e:
-
 
44
        print e
31
    
45
    
32
    return ("", full_name)
46
    return ("", full_name)
33
 
47
 
34
def getItemsWithTopScore(items):
48
def getItemsWithTopScore(items):
35
    filterd_items = []
49
    filterd_items = []