Subversion Repositories SmartDukaan

Rev

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

Rev 3505 Rev 3584
Line 19... Line 19...
19
    title = item.brand
19
    title = item.brand
20
    if item.modelName:
20
    if item.modelName:
21
        title = title + ' ' + item.modelName
21
        title = title + ' ' + item.modelName
22
    if item.modelNumber:
22
    if item.modelNumber:
23
        title = title + ' ' + item.modelNumber
23
        title = title + ' ' + item.modelNumber
-
 
24
    if item.color:
-
 
25
        title = title + " | " + item.color
24
    return title
26
    return title
25
 
27
 
26
def get_hyphenated_name(item):
28
def get_hyphenated_name(item):
27
    productUrl = item.brand
29
    productUrl = item.brand
28
    if item.modelName:
30
    if item.modelName:
Line 78... Line 80...
78
        else:
80
        else:
79
            itemNumberTypeMap[key] = 'UPC'
81
            itemNumberTypeMap[key] = 'UPC'
80
    print itemNumberMap
82
    print itemNumberMap
81
    return itemNumberMap, itemNumberTypeMap
83
    return itemNumberMap, itemNumberTypeMap
82
 
84
 
-
 
85
 
-
 
86
def normalize_form_factor(formFactor):
-
 
87
    if formFactor == 'Candybar':
-
 
88
        formFactor = 'candy-bar'
-
 
89
    elif formFactor == 'Slider':
-
 
90
        formFactor = 'slide'
-
 
91
    elif formFactor == 'Flip':
-
 
92
        formFactor = 'flip'
-
 
93
    elif formFactor == 'Clamshell':
-
 
94
        formFactor = 'flip'
-
 
95
    else:
-
 
96
        formFactor = ''
-
 
97
    return formFactor
-
 
98
 
-
 
99
 
-
 
100
def normalize_operating_system(opsys):
-
 
101
    if 'Android' in opsys:
-
 
102
        opsys = 'Android'
-
 
103
    elif 'Symbian' in opsys:
-
 
104
        opsys = 'Symbian'
-
 
105
    elif 'BlackBerry' in opsys:
-
 
106
        opsys = 'Blackberry'
-
 
107
    elif 'Windows' in opsys:
-
 
108
        opsys = 'Windows Phone'
-
 
109
    elif 'bada' in opsys or 'Bada' in opsys:
-
 
110
        opsys = 'Bada'
-
 
111
    elif 'iOS' in opsys:
-
 
112
        opsys = 'iOS'
-
 
113
    else:
-
 
114
        opsys = ''
-
 
115
    return opsys
-
 
116
 
-
 
117
 
-
 
118
def normalize_battery_type(batteryType):
-
 
119
    if 'Li-Ion' in batteryType or 'Li-ion' in batteryType or 'Lithium-ion' in batteryType:
-
 
120
        batteryType = 'lithium_ion'
-
 
121
    elif 'Li-Po' in batteryType:
-
 
122
        batteryType = 'lithium_metal'
-
 
123
    else:
-
 
124
        batteryType = ''
-
 
125
    return batteryType
-
 
126
 
-
 
127
 
-
 
128
def get_cellular_technology(multipleSIM, network3G):
-
 
129
    cellularTechnology = ''
-
 
130
    if multipleSIM == 'Dual-SIM':
-
 
131
        cellularTechnology = 'Dual SIM'
-
 
132
    if not cellularTechnology:
-
 
133
        if network3G != '':
-
 
134
            cellularTechnology = '3G'
-
 
135
        else:
-
 
136
            cellularTechnology = 'GSM'
-
 
137
    return cellularTechnology
-
 
138
 
-
 
139
 
-
 
140
def normalize_screen_type(screenType):
-
 
141
    if 'LCD' in screenType or 'Nova' in screenType or 'Retina' in screenType:
-
 
142
        screenType = 'LCD'
-
 
143
    elif 'LED' in screenType:
-
 
144
        screenType = 'LED'
-
 
145
    else:
-
 
146
        screenType = ''
-
 
147
    return screenType
-
 
148
 
83
def main():
149
def main():
84
    itemNumberMap, itemNumberTypeMap = load_item_numbers() 
150
    itemNumberMap, itemNumberTypeMap = load_item_numbers() 
85
    catalog_client = CatalogClient().get_client()
151
    catalog_client = CatalogClient().get_client()
86
    item_details = []
152
    item_details = []
87
    filename = "/home/ashish/featurevalues.xls"
153
    filename = "/home/ashish/featurevalues.xls"
Line 126... Line 192...
126
            screenSize = screenSize.split()[0]
192
            screenSize = screenSize.split()[0]
127
        
193
        
128
        if screenResolution:
194
        if screenResolution:
129
            screenResolution = screenResolution.rsplit(' ', 1)[0]
195
            screenResolution = screenResolution.rsplit(' ', 1)[0]
130
 
196
 
131
        if 'LCD' in screenType or 'Nova' in screenType or 'Retina' in screenType:
197
        screenType = normalize_screen_type(screenType)
132
            screenType = 'LCD'
-
 
133
        elif 'LED' in screenType:
-
 
134
            screenType = 'LED'
-
 
135
        else:
-
 
136
            screenType = ''
-
 
137
 
198
 
138
        cellularTechnology = ''
-
 
139
        if multipleSIM == 'Dual-SIM':
-
 
140
            cellularTechnology = 'Dual SIM'
199
        cellularTechnology = get_cellular_technology(multipleSIM, network3G)
141
        if not cellularTechnology:
-
 
142
            if network3G != '':
-
 
143
                cellularTechnology = '3G'
-
 
144
            else:
-
 
145
                cellularTechnology = 'GSM'
-
 
146
 
200
 
147
        if 'Android' in opsys:
-
 
148
            opsys = 'Android'
-
 
149
        elif 'Symbian' in opsys:
-
 
150
            opsys = 'Symbian'
-
 
151
        elif 'BlackBerry' in opsys:
-
 
152
            opsys = 'Blackberry'
-
 
153
        elif 'Windows' in opsys:
-
 
154
            opsys = 'Windows Phone'
-
 
155
        elif 'bada' in opsys or 'Bada' in opsys:
201
        opsys = normalize_operating_system(opsys)
156
            opsys = 'Bada'
-
 
157
        elif 'iOS' in opsys:
-
 
158
            opsys = 'iOS'
-
 
159
        else:
-
 
160
            opsys = ''
-
 
161
        
202
        
162
        userInput = "keypad"
203
        userInput = "keypad"
163
        if touchscreenType != "":
204
        if touchscreenType != "":
164
            userInput = "touchscreen"
205
            userInput = "touchscreen"
165
 
206
 
166
        if formFactor == 'Candybar':
-
 
167
            formFactor = 'candy-bar'
207
        formFactor = normalize_form_factor(formFactor)
168
        elif formFactor == 'Slider':
-
 
169
            formFactor = 'slide'
-
 
170
        elif formFactor == 'Flip':
-
 
171
            formFactor = 'flip'
-
 
172
 
208
 
173
        if warranty:
209
        if warranty:
174
            warranty = warranty + " manufacturer warranty"
210
            warranty = warranty + " manufacturer warranty"
175
 
211
 
176
        if 'Li-Ion' in batteryType or 'Li-ion' in batteryType or 'Lithium-ion' in batteryType:
-
 
177
            batteryType = 'lithium_ion'
-
 
178
        elif 'Li-Po' in batteryType:
-
 
179
            batteryType = 'lithium_metal'
212
        batteryType = normalize_battery_type(batteryType)
180
        else:
-
 
181
            batteryType = ''
-
 
182
        
213
        
183
        weight_parts = weight.split()
214
        weight_parts = weight.split()
184
        if len(weight_parts) > 1:
215
        if len(weight_parts) > 1:
185
            weight = weight_parts[0]
216
            weight = weight_parts[0]
186
            try:
217
            try:
Line 219... Line 250...
219
                         cellularTechnology, opsys,\
250
                         cellularTechnology, opsys,\
220
                         #talktime2G, standy2G, - use these values after converting them to minutes and hours respectively
251
                         #talktime2G, standy2G, - use these values after converting them to minutes and hours respectively
221
                         '', '', userInput, "",\
252
                         '', '', userInput, "",\
222
                         formFactor, item.color, "", "1", "", warranty, "FALSE",\
253
                         formFactor, item.color, "", "1", "", warranty, "FALSE",\
223
                         batteryType, "TRUE","TRUE", "battery-powered", "TRUE",\
254
                         batteryType, "TRUE","TRUE", "battery-powered", "TRUE",\
224
                         "", weight, length, width, height, keywords[0], keywords[1], keywords[2], keywords[3],\
255
                         "", weight, length, width, height, keywords[0].strip(), keywords[1].strip(), keywords[2].strip(), keywords[3].strip(),\
225
                         keywords[4], "", "","","","",\
256
                         keywords[4].strip(), "", "","","","",\
226
                         "","","","","",\
257
                         "","","","","",\
227
                         "","","",""]);
258
                         "","","",""]);
228
    
259
    
229
    for item_detail in item_details:
260
    for item_detail in item_details:
230
        writer.writerow(item_detail)
261
        writer.writerow(item_detail)