| Line 50... |
Line 50... |
| 50 |
return url
|
50 |
return url
|
| 51 |
|
51 |
|
| 52 |
def is_active(item):
|
52 |
def is_active(item):
|
| 53 |
return item.itemStatus in [2, 3, 6]
|
53 |
return item.itemStatus in [2, 3, 6]
|
| 54 |
|
54 |
|
| - |
|
55 |
def get_key(brand, model_number, color):
|
| - |
|
56 |
model_number_str = ''
|
| - |
|
57 |
try:
|
| - |
|
58 |
model_number_str = str(int(model_number))
|
| - |
|
59 |
except:
|
| - |
|
60 |
model_number_str = str(model_number)
|
| - |
|
61 |
if '(' in model_number_str:
|
| - |
|
62 |
model_number_str = model_number_str.split('(')[0]
|
| - |
|
63 |
return brand.strip().lower() + '|' + model_number_str.strip().lower() + '|' + color.strip().lower()
|
| - |
|
64 |
|
| - |
|
65 |
def load_item_numbers():
|
| - |
|
66 |
filename = "/home/ashish/itemNumbers.xls"
|
| - |
|
67 |
workbook = xlrd.open_workbook(filename)
|
| - |
|
68 |
sheet = workbook.sheet_by_index(0)
|
| - |
|
69 |
num_rows = sheet.nrows
|
| - |
|
70 |
itemNumberMap = {}
|
| - |
|
71 |
itemNumberTypeMap = {}
|
| - |
|
72 |
for rownum in range(1, num_rows):
|
| - |
|
73 |
itemNumber, unused_description, unused_pc, unused_pg, unused_tech, brand, model_number, color = sheet.row_values(rownum)[0:8]
|
| - |
|
74 |
key = get_key(brand, model_number, color)
|
| - |
|
75 |
itemNumberMap[key] = str(itemNumber)
|
| - |
|
76 |
if len(str(itemNumber)) == 13:
|
| - |
|
77 |
itemNumberTypeMap[key] = 'EAN'
|
| - |
|
78 |
else:
|
| - |
|
79 |
itemNumberTypeMap[key] = 'UPC'
|
| - |
|
80 |
print itemNumberMap
|
| - |
|
81 |
return itemNumberMap, itemNumberTypeMap
|
| - |
|
82 |
|
| 55 |
def main():
|
83 |
def main():
|
| - |
|
84 |
itemNumberMap, itemNumberTypeMap = load_item_numbers()
|
| 56 |
catalog_client = CatalogClient().get_client()
|
85 |
catalog_client = CatalogClient().get_client()
|
| 57 |
item_details = []
|
86 |
item_details = []
|
| 58 |
filename = "/home/ashish/featurevalues.xls"
|
87 |
filename = "/home/ashish/featurevalues.xls"
|
| 59 |
workbook = xlrd.open_workbook(filename)
|
88 |
workbook = xlrd.open_workbook(filename)
|
| 60 |
sheet = workbook.sheet_by_index(0)
|
89 |
sheet = workbook.sheet_by_index(0)
|
| Line 86... |
Line 115... |
| 86 |
builtIn, ram, expansionType, expansionCapacity, batteryType, powerAdaptor, musicPlayback,\
|
115 |
builtIn, ram, expansionType, expansionCapacity, batteryType, powerAdaptor, musicPlayback,\
|
| 87 |
videoPlayback, tvPlayback, talktime2G, talktime3G, standy2G, standby3G, types, markupLanguages,\
|
116 |
videoPlayback, tvPlayback, talktime2G, talktime3G, standy2G, standby3G, types, markupLanguages,\
|
| 88 |
unused_http_protocols, unused_browser, unused_mail_protocols, opsys, unused_java, unused_flashPlayer, unused_drm, unused_securityFeatures, unused_gpsType, unused_mms, unused_sms, unused_ems,\
|
117 |
unused_http_protocols, unused_browser, unused_mail_protocols, opsys, unused_java, unused_flashPlayer, unused_drm, unused_securityFeatures, unused_gpsType, unused_mms, unused_sms, unused_ems,\
|
| 89 |
unused_instantMessaging, unused_email = sheet.row_values(rownum)[0:85]
|
118 |
unused_instantMessaging, unused_email = sheet.row_values(rownum)[0:85]
|
| 90 |
|
119 |
|
| - |
|
120 |
items = catalog_client.getItemsByCatalogId(entityID)
|
| - |
|
121 |
active_items = filter(is_active, items)
|
| - |
|
122 |
if not active_items:
|
| - |
|
123 |
continue
|
| - |
|
124 |
|
| 91 |
if screenSize:
|
125 |
if screenSize:
|
| 92 |
screenSize = screenSize.split()[0]
|
126 |
screenSize = screenSize.split()[0]
|
| 93 |
|
127 |
|
| 94 |
if screenResolution:
|
128 |
if screenResolution:
|
| 95 |
screenResolution = screenResolution.rsplit(' ', 1)[0]
|
129 |
screenResolution = screenResolution.rsplit(' ', 1)[0]
|
| Line 155... |
Line 189... |
| 155 |
keywords = metaKeywords.split(",")
|
189 |
keywords = metaKeywords.split(",")
|
| 156 |
if len(keywords) < 5:
|
190 |
if len(keywords) < 5:
|
| 157 |
length = len(keywords)
|
191 |
length = len(keywords)
|
| 158 |
while length < 5:
|
192 |
while length < 5:
|
| 159 |
keywords.append('')
|
193 |
keywords.append('')
|
| 160 |
length = length + 1
|
194 |
length = length + 1
|
| 161 |
|
- |
|
| 162 |
items = catalog_client.getItemsByCatalogId(entityID)
|
- |
|
| 163 |
active_items = filter(is_active, items)
|
- |
|
| 164 |
if not active_items:
|
- |
|
| 165 |
continue
|
- |
|
| 166 |
|
- |
|
| 167 |
suffix = ''
|
- |
|
| 168 |
color = ''
|
- |
|
| 169 |
if len(active_items) > 1:
|
- |
|
| 170 |
suffix = ' (multiple colors available)'
|
- |
|
| 171 |
else:
|
- |
|
| 172 |
color = active_items[0].color
|
- |
|
| 173 |
|
- |
|
| 174 |
item = active_items[0]
|
- |
|
| 175 |
|
195 |
|
| - |
|
196 |
for item in active_items:
|
| - |
|
197 |
stdProductId = ''
|
| - |
|
198 |
stdProductIdType = ''
|
| - |
|
199 |
if not item.color:
|
| - |
|
200 |
item.color = ''
|
| - |
|
201 |
key = get_key(item.brand, item.modelNumber, item.color)
|
| - |
|
202 |
if itemNumberMap.has_key(key):
|
| - |
|
203 |
stdProductId = itemNumberMap[key]
|
| - |
|
204 |
stdProductIdType = itemNumberTypeMap[key]
|
| 176 |
item_details.append(
|
205 |
item_details.append(
|
| 177 |
[entityID, get_title(item) + suffix, get_url(item), item.sellingPrice, '1', '803546031', 'NA',\
|
206 |
[item.id, get_title(item), get_url(item), item.sellingPrice, "1", "803546031", stdProductId,\
|
| 178 |
'UPC', 'Wireless', tagline, '0', get_image_url(item), item.mrp, 'TRUE',\
|
207 |
stdProductIdType, "Wireless", tagline, '0', get_image_url(item), item.mrp, "TRUE",\
|
| 179 |
item.brand, '', '', item.modelNumber, "", builtIn,\
|
208 |
item.brand, "", "", item.modelNumber, "", builtIn,\
|
| 180 |
ram, "", "", "", screenSize, screenResolution,\
|
209 |
ram, "", "", "", screenSize, screenResolution,\
|
| 181 |
screenType, "", "", "", "", "",\
|
210 |
screenType, "", "", "", "", "",\
|
| 182 |
cellularTechnology, opsys, talktime2G, standy2G, userInput, "",\
|
211 |
cellularTechnology, opsys, talktime2G, standy2G, userInput, "",\
|
| 183 |
formFactor, color, "", "1", "", warranty, "FALSE",\
|
212 |
formFactor, item.color, "", "1", "", warranty, "FALSE",\
|
| 184 |
batteryType, "TRUE","TRUE", "battery-powered", "TRUE",\
|
213 |
batteryType, "TRUE","TRUE", "battery-powered", "TRUE",\
|
| 185 |
"", weight, length, width, height, keywords[0], keywords[1], keywords[2], keywords[3],\
|
214 |
"", weight, length, width, height, keywords[0], keywords[1], keywords[2], keywords[3],\
|
| 186 |
keywords[4], "", "","","","",\
|
215 |
keywords[4], "", "","","","",\
|
| 187 |
"","","","","",\
|
216 |
"","","","","",\
|
| 188 |
"","","",""]);
|
217 |
"","","",""]);
|
| 189 |
|
218 |
|
| 190 |
for item_detail in item_details:
|
219 |
for item_detail in item_details:
|
| 191 |
writer.writerow(item_detail)
|
220 |
writer.writerow(item_detail)
|
| 192 |
|
221 |
|
| 193 |
if __name__ == '__main__':
|
222 |
if __name__ == '__main__':
|