Subversion Repositories SmartDukaan

Rev

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

Rev 4003 Rev 4090
Line 1... Line 1...
1
#!/usr/bin/python
1
#!/usr/bin/python
2
 
2
 
3
'''
3
'''
-
 
4
Generates a TSV file to be uploaded to Amazon's seller central.
-
 
5
It has three input sources:
-
 
6
 1. The catalog database which it reads from the local database.
-
 
7
 2. FeatureValues.xls which is generated using the FeatureValueExtractor
-
 
8
  script in the ContentStore project.
-
 
9
 3. ItemNumbers.xls which is fetched from Nilesh to get UPC/EAN
-
 
10
 of all handsets since Amazon is adamant that they'll not accept data w/o it.
-
 
11
 
-
 
12
Once the CSV file is generated, a header should be added to it.
-
 
13
 
-
 
14
@attention: The columns and their order in the featurevalues.xls can
-
 
15
change depending on the object model. As such the output should be 
-
 
16
checked manually. 
-
 
17
 
4
Created on 01-Sep-2011
18
Created on 01-Sep-2011
5
 
19
 
6
@author: ashish
20
@author: Chandranshu
7
'''
21
'''
8
import sys
22
import sys
9
import csv
23
import csv
10
import xlrd
24
import xlrd
11
 
25
 
Line 14... Line 28...
14
    sys.path.insert(0, os.getcwd())
28
    sys.path.insert(0, os.getcwd())
15
    
29
    
16
from shop2020.clients.CatalogClient import CatalogClient
30
from shop2020.clients.CatalogClient import CatalogClient
17
 
31
 
18
def get_title(item):
32
def get_title(item):
-
 
33
    '''
-
 
34
    Returns the title of the Item in the format required by Amazon:
-
 
35
    <Brand> <Model Name> <Model Number> | <Color>
-
 
36
    '''
19
    title = item.brand
37
    title = item.brand
20
    if item.modelName:
38
    if item.modelName:
21
        title = title + ' ' + item.modelName
39
        title = title + ' ' + item.modelName
22
    if item.modelNumber:
40
    if item.modelNumber:
23
        title = title + ' ' + item.modelNumber
41
        title = title + ' ' + item.modelNumber
24
    if item.color:
42
    if item.color:
25
        title = title + " | " + item.color
43
        title = title + " | " + item.color
26
    return title
44
    return title
27
 
45
 
28
def get_hyphenated_name(item):
46
def get_hyphenated_name(item):
-
 
47
    '''
-
 
48
    Returns the URL path for a mobile phone.
-
 
49
    '''
29
    productUrl = item.brand
50
    productUrl = item.brand
30
    if item.modelName:
51
    if item.modelName:
31
        productUrl = productUrl + "-" + item.modelName
52
        productUrl = productUrl + "-" + item.modelName
32
    if item.modelNumber:
53
    if item.modelNumber:
33
        productUrl = productUrl + '-' + item.modelNumber
54
        productUrl = productUrl + '-' + item.modelNumber
Line 36... Line 57...
36
    productUrl = productUrl.replace("--", "-")
57
    productUrl = productUrl.replace("--", "-")
37
    productUrl = productUrl.lower()
58
    productUrl = productUrl.lower()
38
    return productUrl
59
    return productUrl
39
 
60
 
40
def get_url(item):
61
def get_url(item):
-
 
62
    '''
-
 
63
    Returns the complete URL of a phone.
-
 
64
    '''
41
    url = "http://www.saholic.com/mobile-phones/"
65
    url = "http://www.saholic.com/mobile-phones/"
42
    productUrl = get_hyphenated_name(item)
66
    productUrl = get_hyphenated_name(item)
43
    productUrl = productUrl + "-" + str(item.catalogItemId)
67
    productUrl = productUrl + "-" + str(item.catalogItemId)
44
    url = url + productUrl;
68
    url = url + productUrl;
45
    url = url.replace("--", "-");
69
    url = url.replace("--", "-");
46
    return url;
70
    return url;
47
 
71
 
48
def get_image_url(item):
72
def get_image_url(item):
-
 
73
    '''
-
 
74
    Returns the complete URL of the default image.
-
 
75
    
-
 
76
    @deprecated: The name of image is now available in the FeatureValues file. 
-
 
77
    '''
49
    url = "http://static0.saholic.com/images/"
78
    url = "http://static0.saholic.com/images/"
50
    url = url + str(item.catalogItemId) + "/"
79
    url = url + str(item.catalogItemId) + "/"
51
    url = url + get_hyphenated_name(item) + "-default-0.jpg"
80
    url = url + get_hyphenated_name(item) + "-default-0.jpg"
52
    return url
81
    return url
53
 
82
 
Line 264... Line 293...
264
                         stdProductIdType, "Wireless", tagline, '0', 'http://' + str(image_url), item.mrp, "TRUE",\
293
                         stdProductIdType, "Wireless", tagline, '0', 'http://' + str(image_url), item.mrp, "TRUE",\
265
                         item.brand, "", "", item.modelNumber, "", builtIn,\
294
                         item.brand, "", "", item.modelNumber, "", builtIn,\
266
                         ram, "", "", "", screenSize, screenResolution,\
295
                         ram, "", "", "", screenSize, screenResolution,\
267
                         screenType, "", "", "", "", "",\
296
                         screenType, "", "", "", "", "",\
268
                         cellularTechnology, opsys,\
297
                         cellularTechnology, opsys,\
269
                         #talktime2G, standy2G, - use these values after converting them to minutes and hours respectively
298
                         #talktime2G, standy2G, - TODO: use these values after converting them to minutes and hours respectively
270
                         '', '', userInput, "",\
299
                         '', '', userInput, "",\
271
                         formFactor, item.color, "", "1", "", warranty, "FALSE",\
300
                         formFactor, item.color, "", "1", "", warranty, "FALSE",\
272
                         batteryType, "TRUE","TRUE", "battery-powered", "TRUE",\
301
                         batteryType, "TRUE","TRUE", "battery-powered", "TRUE",\
273
                         "", weight, length, width, height, keywords[0].strip(), keywords[1].strip(), keywords[2].strip(), keywords[3].strip(),\
302
                         "", weight, length, width, height, keywords[0].strip(), keywords[1].strip(), keywords[2].strip(), keywords[3].strip(),\
274
                         keywords[4].strip(), "", "","","","",\
303
                         keywords[4].strip(), "", "","","","",\