Subversion Repositories SmartDukaan

Rev

Rev 224 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
224 ashish 1
'''
2
Created on 06-Jun-2010
3
 
4
@author: gaurav
5
'''
6
from datastore.DataAccessor import DataHelper
7
import sys
8
from StdFormatConv.SplitBrandandModel import *
9
from StdFormatConv.RefineModel import *
254 ashish 10
import os
224 ashish 11
 
12
'''
13
Get all the babuchak phones first.
14
Postprocess the phones and brake the phone name column into 
15
brand and model name respectively
16
'''
17
 
254 ashish 18
ds = os.sep
224 ashish 19
da = DataHelper()
20
da.initxy()
21
 
22
sup_name = "babuchak"
23
phones = DataHelper()
24
 
25
phones = phones.get_allbabuchakphones()
26
 
27
if not phones:
28
    print "Error while getting phones"
29
    sys.exit(-1)
30
 
254 ashish 31
file_to_write = ds+"tmp"+ds+"filteredbabuchak.csv"
224 ashish 32
 
33
data_file = open(file_to_write,"w")
34
csv_data =  "%s, %s, %s, %s, %s" %("brand", "model", "shown_price", "final_price","extra_info")
35
data_file.write(csv_data)
36
data_file.write("\n")
37
for phone in phones:
38
    unparsed_name = getunformatted(phone.name)
39
 
40
    vendor_name, phone_name,e_info = getbrandandmodel(unparsed_name)
41
    if vendor_name == "":
42
        vendor_name = "unknown"
43
    model_name,extra_info = getrefinedmodel(phone_name)   
44
    extra_info = e_info + extra_info
45
    if extra_info.endswith(','):
46
        extra_info = extra_info[0:len(extra_info)-1]
47
 
48
    da.add_models(vendor_name, model_name)          
49
    csv_data =  "%s, %s, %d, %d, %s" %(vendor_name, model_name, phone.shown_price, phone.final_price,extra_info)
50
    modId = da.get_modId(vendor_name,model_name)
51
    supId = da.get_suppId(sup_name)
52
    da.add_prices(modId, supId, phone.shown_price, phone.final_price,extra_info)
53
    data_file.write(csv_data)
254 ashish 54
    data_file.write("\n")    
224 ashish 55
data_file.close()
56