Subversion Repositories SmartDukaan

Rev

Rev 224 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 224 Rev 254
Line 6... Line 6...
6
 
6
 
7
from datastore.DataAccessor import DataHelper
7
from datastore.DataAccessor import DataHelper
8
import sys
8
import sys
9
from StdFormatConv.SplitBrandandModel import *
9
from StdFormatConv.SplitBrandandModel import *
10
from StdFormatConv.RefineModel import *
10
from StdFormatConv.RefineModel import *
-
 
11
import os
11
 
12
 
12
'''
13
'''
13
Get all the naaptol phones first.
14
Get all the naaptol phones first.
14
Postprocess the phones and brake the phone name column into 
15
Postprocess the phones and brake the phone name column into 
15
brand and model name respectively
16
brand and model name respectively
16
'''
17
'''
17
 
18
ds = os.sep
18
da = DataHelper()
19
da = DataHelper()
19
da.initxy()
20
da.initxy()
20
 
21
 
21
site = "www.naaptol.com"
22
site = "www.naaptol.com"
22
 
23
 
Line 41... Line 42...
41
 
42
 
42
if not phones:
43
if not phones:
43
    print "Error while getting phones"
44
    print "Error while getting phones"
44
    sys.exit(-1)
45
    sys.exit(-1)
45
 
46
 
46
file_to_write = "/home/gaurav/filterednaaptol.csv"
47
file_to_write = ds+"tmp"+ds+"filterednaaptol.csv"
47
 
48
 
48
data_file = open(file_to_write,"w")
49
data_file = open(file_to_write,"w")
49
csv_data =  "%s, %s, %s, %s, %s, %s, %s" %("brand", "model", "shown_price", "final_price", "extra_info", "supplier_name", "mode of selling")
50
csv_data =  "%s, %s, %s, %s, %s, %s, %s" %("brand", "model", "shown_price", "final_price", "extra_info", "supplier_name", "mode of selling")
50
data_file.write(csv_data)
51
data_file.write(csv_data)
51
data_file.write("\n")
52
data_file.write("\n")
Line 71... Line 72...
71
        final_price = quoted_price = sup.price 
72
        final_price = quoted_price = sup.price 
72
        
73
        
73
        supId = da.get_suppId(sup_name)
74
        supId = da.get_suppId(sup_name)
74
        da.add_prices(modId, supId,quoted_price,final_price,extra_info)
75
        da.add_prices(modId, supId,quoted_price,final_price,extra_info)
75
        csv_data =  "%s, %s, %d, %d, %s, %s, %s" %(vendor_name, model_name, quoted_price, final_price,extra_info,sup_name, "offline")
76
        csv_data =  "%s, %s, %d, %d, %s, %s, %s" %(vendor_name, model_name, quoted_price, final_price,extra_info,sup_name, "offline")
76
        print "%s, %s, %d, %d, %s %s" %(vendor_name, model_name, quoted_price, final_price,extra_info, sup_name)
-
 
77
        data_file.write(csv_data)
77
        data_file.write(csv_data)
78
        data_file.write("\n")
78
        data_file.write("\n")
79
    
79
    
80
    sups = da.get_ntonlinespbynid(phone.id)
80
    sups = da.get_ntonlinespbynid(phone.id)
81
    for sup in sups:    
81
    for sup in sups:    
82
        sup_name = sup.name
82
        sup_name = sup.name
83
        final_price = quoted_price = sup.price 
83
        final_price = quoted_price = sup.price 
84
        supId = da.get_suppId(sup_name)
84
        supId = da.get_suppId(sup_name)
85
        da.add_prices(modId, supId,quoted_price,final_price,extra_info)
85
        da.add_prices(modId, supId,quoted_price,final_price,extra_info)
86
        csv_data =  "%s, %s, %d, %d, %s, %s, %s" %(vendor_name, model_name, quoted_price, final_price,extra_info,sup_name, "online")
86
        csv_data =  "%s, %s, %d, %d, %s, %s, %s" %(vendor_name, model_name, quoted_price, final_price,extra_info,sup_name, "online")
87
        print "%s, %s, %d, %d, %s %s" %(vendor_name, model_name, quoted_price, final_price,extra_info, sup_name)
-
 
88
        data_file.write(csv_data)
87
        data_file.write(csv_data)
89
        data_file.write("\n")
88
        data_file.write("\n")
90
 
89
 
91
data_file.close()
90
data_file.close()
92
 
91