Rev 287 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 02-Jun-2010@author: gaurav'''from elixir import *from datastore.DataCodeDefinition import *key_dict = {'INFIBEAM_DOMAINNAME' : "infibeam",'INFIBEAM_URL' : "http://www.infibeam.com/Mobiles/search?page=",'INFIBEAM_HOMEPAGE' : "www.infibeam.com",'INFIBEAM_REFERER' : "www.google.com/search",'INFIBEAM_VATPLUSTAX' : 0,'INFIBEAM_REMOVELIST' : "Rs.;,;-;/;Rs",'INFIBEAM_XPATH1' : '//ul[@class="srch_result portrait"]/li','INFIBEAM_XPATH2' : './/p/span[@class="title"]/text()','INFIBEAM_XPATH3' : './/p/span[@class="price"]/text()','INDIAPLAZA_DOMAINNAME' : "indiaplaza",'INDIAPLAZA_URL' : "http://www.indiaplaza.in/mobile-phones-Mobiles-1.htm?PageNo=",'INDIAPLAZA_HOMEPAGE' : "www.indiaplaza.com",'INDIAPLAZA_REFERER' : "www.google.com/search",'INDIAPLAZA_URL1' : "http://www.indiaplaza.in",'INDIAPLAZA_XPATH1' : '//tr/td/table[@id="browsesku"]','INDIAPLAZA_XPATH2' : './/div[@class="skuimg"]/a/@title','INDIAPLAZA_XPATH3' : './/div[@class="skuimg"]/a/@href','INDIAPLAZA_DOMAINNAME1' : "indiaplaza1",'INDIAPLAZA_REMOVELIST' : "Rs.;,;-;/;Rs",'INDIAPLAZA_XPATH4' : './/div[@class="finDetHdr"]/h1/text()','INDIAPLAZA_XPATH5' : './/div[@class="priceArea"]/span[1]/text()','INDIAPLAZA_XPATH6' : './/div[@class="priceArea"]/div[@class="row"][2]/text()','INDIAPLAZA_XPATH7' : './/div[@class="priceArea"]/div[@class="row"][2]/span/text()','INDIAPLAZA_XPATH8' : './/div[@class="priceArea"]/div[@class="row"][3]/text()','INDIAPLAZA_XPATH9' : './/div[@class="priceArea"]/div[@class="row"][4]/text()','INDIAPLAZA_XPATH10' : './/div[@class="priceArea"]/div[@class="row"][1]/text()','INDIAPLAZA_VAR1' : "Free shipping",'MOBILESTORE_DOMAINNAME0' : "mobilestore0",'MOBILESTORE_URL1' : "http://www.themobilestore.in/mobilestore/faces/tiles/product.jsp?productID=" ,'MOBILESTORE_URL2' : "&catalogueID=3",'MOBILESTORE_HOMEPAGE' : "www.themobilestore.in",'MOBILESTORE_REFERER' : "www.google.com/search",'MOBILESTORE_XPATH3' : '//span[@id="productLayoutForm:categoryNavigation:navigationList_2:navigationList3"]/text()','MOBILESTORE_XPATH4' : '//div[@id="priceComp"]//tr[2]/td[3]/span/text()','MOBILESTORE_XPATH5' : '//span[@id="productLayoutForm:categoryNavigation:navigationList_1:navigationList3"]/text()','MOBILESTORE_XPATH6' : '//span[@id="productLayoutForm:categoryNavigation:navigationList_0:navigationList3"]/text()','MOBILESTORE_XPATH7' : '//div[@id="priceComp"]/b/text()','MOBILESTORE_XPATH8' : '//span[@id="productLayoutForm:categoryNavigation:navigationList_0:navigationList1"]/text()','UNIVERCELL_DOMAINNAME' : "univercell",'UNIVERCELL_URL' : "http://www.univercell.in/mobiles/populateStore.action",'UNIVERCELL_HOMEPAGE' : "http://www.univercell.in",'UNIVERCELL_REFERER' : "www.google.com/search",'UNIVERCELL_URL1' : "http://www.univercell.in",'UNIVERCELL_XPATH1' : '//div[@id="mobilesTab"]/table/tr[1]/td/table/tr','UNIVERCELL_XPATH2' : './/a/text()','UNIVERCELL_XPATH3' : './/a/@href','UNIVERCELL_VAR1' : ";",'UNIVERCELL_VAR2' : "?",'UNIVERCELL_VAR3' : "populate",'UNIVERCELL_VAR4' : "rePopulate",'UNIVERCELL_DOMAINNAME1' : "univercell1",'UNIVERCELL_REMOVELIST' : "Rs.;,;-;/;Rs",'UNIVERCELL_XPATH4' : '//td[@class="gray-border"]','UNIVERCELL_XPATH5' : './/tr[2]/td/a/text()','UNIVERCELL_XPATH6' : './/tr[3]/th/label/text()','UNIVERCELL_VATPLUSTAX' : 0,'BABUCHAK_DOMAINNAME' : "babuchak",'BABUCHAK_URL' : "http://www.shopping.babuchak.com/visitourstores.php?view=productListPage&category=108",'BABUCHAK_HOMEPAGE' : "http://www.shopping.babuchak.com",'BABUCHAK_REFERER' : "www.google.com/search",'BABUCHAK_URL1' : "http://www.shopping.babuchak.com/visitourstores.php",'BABUCHAK_XPATH1' : '//td[@class="mod-category-header"]','BABUCHAK_XPATH2' : './/text()','BABUCHAK_XPATH3' : './/a/@href','BABUCHAK_DOMAINNAME1' : "babuchak1",'BABUCHAK_VAR1' : "&postPage=",'BABUCHAK_URL2' : "http://www.shopping.babuchak.com/visitourstores.php",'BABUCHAK_XPATH4' : '//td[@class="mod-item-body-title"]/a/@href','BABUCHAK_DOMAINNAME2' : "babuchak2",'BABUCHAK_XPATH5' : '//td[@class="text-header"]/text()','BABUCHAK_XPATH6' : '//td[@class="xl63"]//strong/span/text()','BABUCHAK_XPATH7' : '//td[@class="mod-item-body-title"]/b/text()','BABUCHAK_REMOVELIST' : "Rs.;,;-;/;Rs",'NAAPTOL_DOMAINNAME' : "naaptol",'NAAPTOL_URL' : "http://www.naaptol.com/sitemap.xml",'NAAPTOL_HOMEPAGE' : "http://www.naaptol.com",'NAAPTOL_REFERER' : "http://www.google.com",'NAAPTOL_XPATH1' : '//url/loc/text()','NAAPTOL_CHKLIST1' : "mobile_phones/pdas_and_smartphones;mobile_phones/gsm_handsets;mobile_phones/cdma_handsets",'NAAPTOL_DOMAINNAME1' : "naaptol1",'NAAPTOL_DOMAINNAME2' : "naaptol2",'NAAPTOL_CHKLIST2' : 'price','NAAPTOL_PART' : "features",'NAAPTOL_REMOVELIST' : "Rs.;,",'NAAPTOL_XPATH2' : '//table[@class ="ProductDetails"]//td[@class="Price"]/span/text()','NAAPTOL_XPATH3' : '//table[@class ="ProductDetails"]//td[@class="Price"]/span/script/text()','NAAPTOL_XPATH4' : '//div[@id="OnlineSellers"]//div[@class="ProductResultHead"]//div[@class="headingstyle"]/text()','NAAPTOL_XPATH5' : '//div[@id="onSellerContents"]//td[@class="price"]','NAAPTOL_XPATH6' : '//div[@id="onSellerContents"]//tr[@class="DottedBorder"]/td/a[@id="storeInfoPop','NAAPTOL_XPATH7' : '"]/span/text()','NAAPTOL_XPATH8' : '//div[@id="LocalStores"]//div[@class="ProductResultHead"]//div[@class="headingstyle"]/text()','NAAPTOL_XPATH9' : '//div[@id="offSellerContents"]//td[@class="price"]','NAAPTOL_XPATH10' : '//div[@id="offSellerContents"]//span[@class="LocalStoreHeading"]/text()'}def initialize_table():"""Documentation for method initialize_tableIt calls a method init() so that when one needs to access the helper methods ofthis class to access database, the database tables are in the scope"""init()def set_code_word(key,value,description):"""Documentation for method set_code_wordThis method is used to set a code_word through input from form"""try:cw = code_words.query.filter_by(key=key).one()#print value#print descriptioncw.value = valuecw.description = descriptionexcept:cw = code_words()cw.key = keycw.value = valuecw.description = descriptionsession.commit()def get_code_word_byId(id):"""Documentation for method get_code_word_byIdThis method is used to retrieve a code_word given its id"""try:cw = code_words.query.filter_by(id=id).one()except:cw = "EMPTY"return cwdef get_code_word(key):"""Documentation for method get_code_wordThis method is used to retrieve the value of a code_word given its key i.e name"""try:cw = code_words.query.filter_by(key=key).one()cw = cw.valueprint keyprint cwexcept:try:cw = key_dict[key]except:cw = "EMPTY"return cwdef get_allcode_words(key):"""Documentation for method get_allcode_wordsThis method is used to retrieve all the code_words given the key i.e name"""try:cw = code_words.query.all()except:try:cw = key_dict.values()except:cw = "EMPTY"return cwdef get_code_word_byKey(key):"""Documentation for method get_code_word_byKeyThis method is used to retrieve the code_word given its key i.e name"""try:cw = code_words.query.filter_by(key=key).one()except:try:cw = key_dict[key]except:cw = "EMPTY"return cw