Subversion Repositories SmartDukaan

Rev

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

Rev 3140 Rev 3486
Line 5... Line 5...
5
 
5
 
6
@author: ashish
6
@author: ashish
7
'''
7
'''
8
import sys
8
import sys
9
import csv
9
import csv
-
 
10
import xlrd
10
 
11
 
11
if __name__ == '__main__' and __package__ is None:
12
if __name__ == '__main__' and __package__ is None:
12
    import os
13
    import os
13
    sys.path.insert(0, os.getcwd())
14
    sys.path.insert(0, os.getcwd())
14
    
15
    
Line 46... Line 47...
46
    url = "http://static0.saholic.com/images/"
47
    url = "http://static0.saholic.com/images/"
47
    url = url + str(item.catalogItemId) + "/"
48
    url = url + str(item.catalogItemId) + "/"
48
    url = url + get_hyphenated_name(item) + "-default-0.jpg"
49
    url = url + get_hyphenated_name(item) + "-default-0.jpg"
49
    return url
50
    return url
50
 
51
 
-
 
52
def is_active(item):
-
 
53
    return item.itemStatus in [2, 3, 6]
-
 
54
 
51
def main():
55
def main():
52
    catalog_client = CatalogClient().get_client()
56
    catalog_client = CatalogClient().get_client()
53
    catalog_item_ids = [1000073, 1000079, 1000095, 1000100, 1000110, 1000111, 1000114, 1000120, 1000133, 1000135]
-
 
54
    item_details = []
57
    item_details = []
-
 
58
    filename = "/home/ashish/featurevalues.xls"
-
 
59
    workbook = xlrd.open_workbook(filename)
-
 
60
    sheet = workbook.sheet_by_index(0)
-
 
61
    num_rows = sheet.nrows
-
 
62
    
-
 
63
    writer = csv.writer(open("junglee.csv", "wb"), delimiter='\t', quoting=csv.QUOTE_MINIMAL)
-
 
64
    writer.writerow(["SKU","Title","Link","Price","Delivery Time","Recommended Browse Node","Standard Product ID",\
-
 
65
                 "Product ID Type","Category","Description","Shipping Cost","Image","List Price","Availability",\
-
 
66
                 "Brand","Manufacturer","Mfr part number","Model Number","Computer CPU speed","Hard disk size",\
-
 
67
                 "Included RAM size","Optical zoom","Digital zoom","Megapixels","Display size","Screen Resolution",\
-
 
68
                 "Display Technology","Flash drive Size","Memory Card Type","Camera type","Viewfinder type","Flash type",\
-
 
69
                 "Cellular Technology","Phone Operating System","Talk Time","Standby Time","User Input","Device Type",\
-
 
70
                 "Form Factor","Colour Name","Colour Map","Item package quantity","Age","Warranty","Assembly required",\
-
 
71
                 "Battery Type","Batteries Included","Batteries Required","Power Source","Power Adapter Included",\
-
 
72
                 "Shipping Weight","Weight","Length","Height","Width","Keywords1","Keywords2", "Keywords3","Keywords4",\
-
 
73
                 "Keywords5","Bullet point1","Bullet point2","Bullet point3","Bullet point4","Bullet point5",\
-
 
74
                 "Other image-url1","Other image-url2","Other image-url3","Other image-url4","Other image-url5",
-
 
75
                 "Offer note","Is Gift Wrap Available","Registered Parameter","Update Delete"])
-
 
76
    
55
    for catalog_item_id in catalog_item_ids:
77
    for rownum in range(2, num_rows):
-
 
78
        unused_categoryName, unused_entityName, entityID, unused_accessories, unused_softwareApplications, unused_pageTitle,\
-
 
79
        unused_metaDescription, metaKeywords, snippets, shortSnippet, tagline, warranty,\
-
 
80
        unused_skinSize, screenSize, unused_screenLeftUpperCornerDimension, unused_modelNameSynonyms, unused_modelNumberSynonyms,\
-
 
81
        weight, size, formFactor, color, screenType, screenSize, screenResolution, numberOfColors, keyboardType,\
-
 
82
        navigation, touchscreenType, sideControls, multimediaKeys, multipleSIM, voip, network2G,\
-
 
83
        network3G, gprs, edge, g3, wifi, bluetooth, usb, musicFormats, earphone, speakerPhone,\
-
 
84
        fmRadio, internetRadio, ringtoneTypes, fileFormats, streaming, liveTV, hdVideoPlayback,\
-
 
85
        resolution, flash, imageFormats, numberOfCameras, secondaryCamera, additionalCameraFeatures,\
-
 
86
        builtIn, ram, expansionType, expansionCapacity, batteryType, powerAdaptor, musicPlayback,\
-
 
87
        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,\
-
 
89
        unused_instantMessaging, unused_email = sheet.row_values(rownum)[0:85]
-
 
90
 
-
 
91
        if screenSize:
-
 
92
            screenSize = screenSize.split()[0]
-
 
93
        
-
 
94
        if screenResolution:
-
 
95
            screenResolution = screenResolution.rsplit(' ', 1)[0]
-
 
96
 
-
 
97
        if 'LCD' in screenType or 'Nova' in screenType or 'Retina' in screenType:
-
 
98
            screenType = 'LCD'
-
 
99
        elif 'LED' in screenType:
-
 
100
            screenType = 'LED'
-
 
101
        else:
-
 
102
            screenType = ''
-
 
103
 
-
 
104
        cellularTechnology = ''
-
 
105
        if multipleSIM == 'Dual-SIM':
-
 
106
            cellularTechnology = 'Dual SIM'
-
 
107
        if not cellularTechnology:
-
 
108
            if network3G != '':
-
 
109
                cellularTechnology = '3G'
-
 
110
            else:
-
 
111
                cellularTechnology = 'GSM'
-
 
112
 
-
 
113
        if 'Android' in opsys:
-
 
114
            opsys = 'Android'
-
 
115
        elif 'Symbian' in opsys:
-
 
116
            opsys = 'Symbian'
-
 
117
        elif 'BlackBerry' in opsys:
-
 
118
            opsys = 'Blackberry'
-
 
119
        elif 'Windows' in opsys:
-
 
120
            opsys = 'Windows Phone'
-
 
121
        elif 'bada' in opsys or 'Bada' in opsys:
-
 
122
            opsys = 'Bada'
-
 
123
        elif 'iOS' in opsys:
-
 
124
            opsys = 'iOS'
-
 
125
        else:
-
 
126
            opsys = ''
-
 
127
        
-
 
128
        userInput = "keypad"
-
 
129
        if touchscreenType != "":
-
 
130
            userInput = "touchscreen"
-
 
131
 
-
 
132
        if formFactor == 'Candybar':
-
 
133
            formFactor = 'candy-bar'
-
 
134
        elif formFactor == 'Slider':
-
 
135
            formFactor = 'slide'
-
 
136
        elif formFactor == 'Flip':
-
 
137
            formFactor = 'flip'
-
 
138
 
-
 
139
        if warranty:
-
 
140
            warranty = warranty + " manufacturer warranty"
-
 
141
 
-
 
142
        if 'Li-Ion' in batteryType or 'Li-ion' in batteryType or 'Lithium-ion' in batteryType:
-
 
143
            batteryType = 'lithium_ion'
-
 
144
        elif 'Li-Po' in batteryType:
-
 
145
            batteryType = 'lithium_metal'
-
 
146
        else:
-
 
147
            batteryType = ''
-
 
148
        
-
 
149
        if size == "Not available" or size == '':
-
 
150
            length, width, height = ["", "", ""]
-
 
151
        else:
-
 
152
            list = size.split()
-
 
153
            length, width, height = [list[0], list[2], list[4]] 
-
 
154
        
-
 
155
        keywords = metaKeywords.split(",")
-
 
156
        if len(keywords) < 5:
-
 
157
            length = len(keywords)
-
 
158
            while length < 5:
-
 
159
                keywords.append('')
-
 
160
                length = length + 1 
-
 
161
        
56
        items = catalog_client.getItemsByCatalogId(catalog_item_id)
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
            
57
        item = items[0]
174
        item = active_items[0]
-
 
175
        
-
 
176
        item_details.append(
58
        item_details.append([catalog_item_id, get_title(item), get_url(item), item.sellingPrice, '1', '803028031', 'NA', 'UPC', 'Wireless', 'Description', '0', get_image_url(item), item.mrp, 'TRUE', '', item.brand, '', item.modelNumber]);
177
                    [entityID, get_title(item) + suffix, get_url(item), item.sellingPrice, '1', '803546031', 'NA',\
-
 
178
                     'UPC', 'Wireless', tagline, '0', get_image_url(item), item.mrp, 'TRUE',\
-
 
179
                     item.brand, '', '', item.modelNumber, "", builtIn,\
-
 
180
                     ram, "", "", "", screenSize, screenResolution,\
-
 
181
                     screenType, "", "", "", "", "",\
-
 
182
                     cellularTechnology, opsys, talktime2G, standy2G, userInput, "",\
-
 
183
                     formFactor, color, "", "1", "", warranty, "FALSE",\
-
 
184
                     batteryType, "TRUE","TRUE", "battery-powered", "TRUE",\
-
 
185
                     "", weight, length, width, height, keywords[0], keywords[1], keywords[2], keywords[3],\
-
 
186
                     keywords[4], "", "","","","",\
-
 
187
                     "","","","","",\
-
 
188
                     "","","",""]);
59
    
189
    
60
    writer = csv.writer(open("junglee.csv", "wb"), delimiter=',', quoting=csv.QUOTE_MINIMAL)
-
 
61
    for item_detail in item_details:
190
    for item_detail in item_details:
62
        writer.writerow(item_detail)
191
        writer.writerow(item_detail)
63
 
192
 
64
if __name__ == '__main__':
193
if __name__ == '__main__':
65
    main()
194
    main()
66
195