Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
203 ashish 1
'''
2
Created on 02-Jun-2010
3
 
4
@author: gaurav
5
'''
6
 
7
from elixir import *
8
from datastore.DataCodeDefinition import *
9
 
274 ashish 10
key_dict = {'INFIBEAM_DOMAINNAME' : "infibeam",
11
    'INFIBEAM_URL' : "http://www.infibeam.com/Mobiles/search?page=",
12
    'INFIBEAM_HOMEPAGE' : "www.infibeam.com",
13
    'INFIBEAM_REFERER' : "www.google.com/search",
14
    'INFIBEAM_VATPLUSTAX' : 0,
287 ashish 15
    'INFIBEAM_REMOVELIST' : "Rs.;,;-;/;Rs",
274 ashish 16
    'INFIBEAM_XPATH1' : '//ul[@class="srch_result portrait"]/li',
17
    'INFIBEAM_XPATH2' : './/p/span[@class="title"]/text()',
18
    'INFIBEAM_XPATH3' : './/p/span[@class="price"]/text()',
19
    'INDIAPLAZA_DOMAINNAME' : "indiaplaza",
20
    'INDIAPLAZA_URL' : "http://www.indiaplaza.in/mobile-phones-Mobiles-1.htm?PageNo=",
21
    'INDIAPLAZA_HOMEPAGE' : "www.indiaplaza.com",
22
    'INDIAPLAZA_REFERER' : "www.google.com/search",
23
    'INDIAPLAZA_URL1' : "http://www.indiaplaza.in",
24
    'INDIAPLAZA_XPATH1' : '//tr/td/table[@id="browsesku"]',
25
    'INDIAPLAZA_XPATH2' : './/div[@class="skuimg"]/a/@title',
26
    'INDIAPLAZA_XPATH3' : './/div[@class="skuimg"]/a/@href',
27
    'INDIAPLAZA_DOMAINNAME1' : "indiaplaza1",
287 ashish 28
    'INDIAPLAZA_REMOVELIST' : "Rs.;,;-;/;Rs",
274 ashish 29
    'INDIAPLAZA_XPATH4' : './/div[@class="finDetHdr"]/h1/text()',
30
    'INDIAPLAZA_XPATH5' : './/div[@class="priceArea"]/span[1]/text()',
31
    'INDIAPLAZA_XPATH6' : './/div[@class="priceArea"]/div[@class="row"][2]/text()',
32
    'INDIAPLAZA_XPATH7' : './/div[@class="priceArea"]/div[@class="row"][2]/span/text()',
33
    'INDIAPLAZA_XPATH8' : './/div[@class="priceArea"]/div[@class="row"][3]/text()',
34
    'INDIAPLAZA_XPATH9' : './/div[@class="priceArea"]/div[@class="row"][4]/text()',
35
    'INDIAPLAZA_XPATH10' : './/div[@class="priceArea"]/div[@class="row"][1]/text()',
36
    'INDIAPLAZA_VAR1' : "Free shipping",
37
    'MOBILESTORE_DOMAINNAME0' : "mobilestore0",
38
    'MOBILESTORE_URL1' : "http://www.themobilestore.in/mobilestore/faces/tiles/product.jsp?productID=" ,    
39
    'MOBILESTORE_URL2' : "&catalogueID=3",
40
    'MOBILESTORE_HOMEPAGE' : "www.themobilestore.in",
41
    'MOBILESTORE_REFERER' : "www.google.com/search",
42
    'MOBILESTORE_XPATH3' : '//span[@id="productLayoutForm:categoryNavigation:navigationList_2:navigationList3"]/text()',
43
    'MOBILESTORE_XPATH4' : '//div[@id="priceComp"]//tr[2]/td[3]/span/text()',
44
    'MOBILESTORE_XPATH5' : '//span[@id="productLayoutForm:categoryNavigation:navigationList_1:navigationList3"]/text()',
45
    'MOBILESTORE_XPATH6' : '//span[@id="productLayoutForm:categoryNavigation:navigationList_0:navigationList3"]/text()',
46
    'MOBILESTORE_XPATH7' : '//div[@id="priceComp"]/b/text()',
47
    'MOBILESTORE_XPATH8' : '//span[@id="productLayoutForm:categoryNavigation:navigationList_0:navigationList1"]/text()',
48
    'UNIVERCELL_DOMAINNAME' : "univercell",
49
    'UNIVERCELL_URL' : "http://www.univercell.in/mobiles/populateStore.action",
50
    'UNIVERCELL_HOMEPAGE' : "http://www.univercell.in",
51
    'UNIVERCELL_REFERER' : "www.google.com/search",
52
    'UNIVERCELL_URL1' : "http://www.univercell.in",
53
    'UNIVERCELL_XPATH1' : '//div[@id="mobilesTab"]/table/tr[1]/td/table/tr',
54
    'UNIVERCELL_XPATH2' : './/a/text()',
55
    'UNIVERCELL_XPATH3' : './/a/@href',
56
    'UNIVERCELL_VAR1' : ";",
57
    'UNIVERCELL_VAR2' : "?",
58
    'UNIVERCELL_VAR3' : "populate",
59
    'UNIVERCELL_VAR4' : "rePopulate",
60
    'UNIVERCELL_DOMAINNAME1' : "univercell1",
287 ashish 61
    'UNIVERCELL_REMOVELIST' : "Rs.;,;-;/;Rs",
274 ashish 62
    'UNIVERCELL_XPATH4' : '//td[@class="gray-border"]',
63
    'UNIVERCELL_XPATH5' : './/tr[2]/td/a/text()',
64
    'UNIVERCELL_XPATH6' : './/tr[3]/th/label/text()',
65
    'UNIVERCELL_VATPLUSTAX' : 0,
66
    'BABUCHAK_DOMAINNAME' : "babuchak",
67
    'BABUCHAK_URL' : "http://www.shopping.babuchak.com/visitourstores.php?view=productListPage&category=108",
68
    'BABUCHAK_HOMEPAGE' : "http://www.shopping.babuchak.com",
69
    'BABUCHAK_REFERER' : "www.google.com/search",
70
    'BABUCHAK_URL1' : "http://www.shopping.babuchak.com/visitourstores.php",
71
    'BABUCHAK_XPATH1' : '//td[@class="mod-category-header"]',
72
    'BABUCHAK_XPATH2' : './/text()',
73
    'BABUCHAK_XPATH3' : './/a/@href',
74
    'BABUCHAK_DOMAINNAME1' : "babuchak1",
75
    'BABUCHAK_VAR1' : "&postPage=",
76
    'BABUCHAK_URL2' : "http://www.shopping.babuchak.com/visitourstores.php",
77
    'BABUCHAK_XPATH4' : '//td[@class="mod-item-body-title"]/a/@href',
78
    'BABUCHAK_DOMAINNAME2' : "babuchak2",
79
    'BABUCHAK_XPATH5' : '//td[@class="text-header"]/text()',
80
    'BABUCHAK_XPATH6' : '//td[@class="xl63"]//strong/span/text()',
81
    'BABUCHAK_XPATH7' : '//td[@class="mod-item-body-title"]/b/text()',
287 ashish 82
    'BABUCHAK_REMOVELIST' : "Rs.;,;-;/;Rs",
274 ashish 83
    'NAAPTOL_DOMAINNAME' : "naaptol",
84
    'NAAPTOL_URL' : "http://www.naaptol.com/sitemap.xml",
85
    'NAAPTOL_HOMEPAGE' : "http://www.naaptol.com",
86
    'NAAPTOL_REFERER' : "http://www.google.com",
87
    'NAAPTOL_XPATH1' : '//url/loc/text()',
88
    'NAAPTOL_CHKLIST1' : ["mobile_phones/pdas_and_smartphones" ,"mobile_phones/gsm_handsets" ,"mobile_phones/cdma_handsets"],
89
    'NAAPTOL_DOMAINNAME1' : "naaptol1",
90
    'NAAPTOL_DOMAINNAME2' : "naaptol2",
91
    'NAAPTOL_CHKLIST2' : ['price'],
92
    'NAAPTOL_PART' : "features",
287 ashish 93
    'NAAPTOL_REMOVELIST' : "Rs.;,",
274 ashish 94
    'NAAPTOL_XPATH2' : '//table[@class ="ProductDetails"]//td[@class="Price"]/span/text()',
95
    'NAAPTOL_XPATH3' : '//table[@class ="ProductDetails"]//td[@class="Price"]/span/script/text()',
96
    'NAAPTOL_XPATH4' : '//div[@id="OnlineSellers"]//div[@class="ProductResultHead"]//div[@class="headingstyle"]/text()',
97
    'NAAPTOL_XPATH5' : '//div[@id="onSellerContents"]//td[@class="price"]',
98
    'NAAPTOL_XPATH6' : '//div[@id="onSellerContents"]//tr[@class="DottedBorder"]/td/a[@id="storeInfoPop',
99
    'NAAPTOL_XPATH7' : '"]/span/text()',
100
    'NAAPTOL_XPATH8' : '//div[@id="LocalStores"]//div[@class="ProductResultHead"]//div[@class="headingstyle"]/text()',
101
    'NAAPTOL_XPATH9' : '//div[@id="offSellerContents"]//td[@class="price"]',
102
    'NAAPTOL_XPATH10' : '//div[@id="offSellerContents"]//span[@class="LocalStoreHeading"]/text()'
103
    }
104
 
105
 
238 ashish 106
def initialize_table():
264 ashish 107
    """
108
    Documentation for method initialize_table
109
    It calls a method init() so that when one needs to access the helper methods of 
110
    this class to access database, the database tables are in the scope 
111
    """
238 ashish 112
    init()
264 ashish 113
 
114
def set_code_word(key,value,description):
115
    """
116
    Documentation for method set_code_word 
117
    This method is used to set a code_word through input from form
118
    """
119
    try:
120
        cw = code_words.query.filter_by(key=key).one()
121
        #print value
122
        #print description
123
        cw.value = value
124
        cw.description = description
125
    except:
126
        cw = code_words()
127
        cw.key = key
128
        cw.value = value
129
        cw.description = description
130
    session.commit()
238 ashish 131
 
203 ashish 132
def get_code_word_byId(id):
264 ashish 133
    """
134
    Documentation for method get_code_word_byId 
135
    This method is used to retrieve a code_word given its id
136
    """
238 ashish 137
    try:
138
        cw = code_words.query.filter_by(id=id).one()
139
    except:
140
        cw = "EMPTY"
203 ashish 141
    return cw
142
 
238 ashish 143
def get_code_word(key):
264 ashish 144
    """
145
    Documentation for method get_code_word 
146
    This method is used to retrieve the value of a code_word given its key i.e name
147
    """
238 ashish 148
    try:
149
        cw = code_words.query.filter_by(key=key).one()
150
        cw = cw.value
151
        print key
152
        print cw
153
    except:
274 ashish 154
        try:
155
            cw = key_dict[key]
156
        except:    
157
            cw = "EMPTY"
203 ashish 158
    return cw
159
 
160
def get_allcode_words(key):
264 ashish 161
    """
162
    Documentation for method get_allcode_words 
163
    This method is used to retrieve all the code_words given the key i.e name
164
    """
238 ashish 165
    try:
166
        cw = code_words.query.all()
167
    except:
274 ashish 168
        try:
169
            cw = key_dict.values()
170
        except:    
171
            cw = "EMPTY"
203 ashish 172
    return cw
173
 
238 ashish 174
def get_code_word_byKey(key):
264 ashish 175
    """
176
    Documentation for method get_code_word_byKey 
177
    This method is used to retrieve the code_word given its key i.e name
178
    """
238 ashish 179
    try:
180
        cw = code_words.query.filter_by(key=key).one()
181
    except:
274 ashish 182
        try:
183
            cw = key_dict[key]
184
        except:    
185
            cw = "EMPTY"
238 ashish 186
    return cw