Subversion Repositories SmartDukaan

Rev

Rev 3139 | Rev 3486 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3139 chandransh 1
#!/usr/bin/python
2
 
3
'''
4
Created on 01-Sep-2011
5
 
6
@author: ashish
7
'''
8
import sys
3140 chandransh 9
import csv
3139 chandransh 10
 
11
if __name__ == '__main__' and __package__ is None:
12
    import os
13
    sys.path.insert(0, os.getcwd())
14
 
15
from shop2020.clients.CatalogClient import CatalogClient
16
 
17
def get_title(item):
18
    title = item.brand
19
    if item.modelName:
20
        title = title + ' ' + item.modelName
21
    if item.modelNumber:
22
        title = title + ' ' + item.modelNumber
23
    return title
24
 
25
def get_hyphenated_name(item):
26
    productUrl = item.brand
27
    if item.modelName:
28
        productUrl = productUrl + "-" + item.modelName
29
    if item.modelNumber:
30
        productUrl = productUrl + '-' + item.modelNumber
31
    productUrl = productUrl.replace("/", "-")
32
    productUrl = productUrl.replace(" ", "-")
33
    productUrl = productUrl.replace("--", "-")
34
    productUrl = productUrl.lower()
35
    return productUrl
36
 
37
def get_url(item):
38
    url = "http://www.saholic.com/mobile-phones/"
39
    productUrl = get_hyphenated_name(item)
40
    productUrl = productUrl + "-" + str(item.catalogItemId)
41
    url = url + productUrl;
42
    url = url.replace("--", "-");
43
    return url;
44
 
45
def get_image_url(item):
46
    url = "http://static0.saholic.com/images/"
47
    url = url + str(item.catalogItemId) + "/"
48
    url = url + get_hyphenated_name(item) + "-default-0.jpg"
49
    return url
50
 
51
def main():
52
    catalog_client = CatalogClient().get_client()
53
    catalog_item_ids = [1000073, 1000079, 1000095, 1000100, 1000110, 1000111, 1000114, 1000120, 1000133, 1000135]
54
    item_details = []
55
    for catalog_item_id in catalog_item_ids:
56
        items = catalog_client.getItemsByCatalogId(catalog_item_id)
57
        item = items[0]
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]);
3140 chandransh 59
 
60
    writer = csv.writer(open("junglee.csv", "wb"), delimiter=',', quoting=csv.QUOTE_MINIMAL)
61
    for item_detail in item_details:
62
        writer.writerow(item_detail)
3139 chandransh 63
 
64
if __name__ == '__main__':
65
    main()