Pep8 cleaning
This commit is contained in:
parent
7a2ddf671c
commit
3e9c168158
4 changed files with 58 additions and 29 deletions
|
|
@ -33,8 +33,7 @@ class LaCentraleBrowser(BaseBrowser):
|
|||
PROTOCOL = 'http'
|
||||
DOMAIN = 'www.lacentrale.fr'
|
||||
ENCODING = 'windows-1252'
|
||||
PAGES = {
|
||||
'http://www.lacentrale.fr/': MainPage,
|
||||
PAGES = {'http://www.lacentrale.fr/': MainPage,
|
||||
'http://www.lacentrale.fr/listing_auto.php?.*': ListingAutoPage,
|
||||
'http://www.lacentrale.fr/auto-occasion-annonce-.*': AnnoncePage,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ from weboob.capabilities.pricecomparison import Product, Price, Shop
|
|||
|
||||
__all__ = ['MainPage', 'ListingAutoPage', 'AnnoncePage']
|
||||
|
||||
|
||||
# I manage main page, ie do nothing yet
|
||||
class MainPage(BasePage):
|
||||
def iter_products(self, criteria):
|
||||
|
|
@ -37,14 +38,17 @@ class MainPage(BasePage):
|
|||
product._criteria = criteria
|
||||
yield product
|
||||
|
||||
|
||||
def get_decimal(s):
|
||||
return re.findall(r'\d+', s.replace(' ', ''))[0]
|
||||
|
||||
|
||||
def new_shop(id):
|
||||
shop = Shop(id)
|
||||
shop.set_empty_fields(NotLoaded)
|
||||
return shop
|
||||
|
||||
|
||||
def new_price(id, product, cost, title):
|
||||
price = Price(id)
|
||||
price.product = product
|
||||
|
|
@ -55,6 +59,7 @@ def new_price(id, product, cost, title):
|
|||
price.shop = new_shop(id)
|
||||
return price
|
||||
|
||||
|
||||
# I manage listing page and extract information
|
||||
class ListingAutoPage(BasePage):
|
||||
|
||||
|
|
@ -67,10 +72,12 @@ class ListingAutoPage(BasePage):
|
|||
|
||||
def _extract_id(self, tr):
|
||||
tdas = tr.cssselect('td.lcbrand a')
|
||||
if tdas is None or len(tdas)==0: return None
|
||||
if tdas is None or len(tdas) == 0:
|
||||
return None
|
||||
tda = tdas[0]
|
||||
m = re.search('annonce-(\d+)\.html', tda.get('href'))
|
||||
if not m: return None
|
||||
if not m:
|
||||
return None
|
||||
return m.group(1)
|
||||
|
||||
def iter_prices(self, product, numpage):
|
||||
|
|
@ -100,6 +107,7 @@ class ListingAutoPage(BasePage):
|
|||
return int(m.group(1))
|
||||
return None
|
||||
|
||||
|
||||
# I manage one car page (annonce) )and extract information
|
||||
class AnnoncePage(BasePage):
|
||||
|
||||
|
|
@ -115,7 +123,8 @@ class AnnoncePage(BasePage):
|
|||
for td in e.cssselect('td.InfoLib'):
|
||||
if name in td.text_content():
|
||||
ntd = td.getnext()
|
||||
if ntd is None: continue
|
||||
if ntd is None:
|
||||
continue
|
||||
return ntd.text_content().strip()
|
||||
return None
|
||||
|
||||
|
|
@ -124,7 +133,8 @@ class AnnoncePage(BasePage):
|
|||
for span in e.cssselect('span.VendeurLib'):
|
||||
if name in span.text_content():
|
||||
li = span.getparent()
|
||||
if li is None: continue
|
||||
if li is None:
|
||||
continue
|
||||
# get all text
|
||||
s = li.text_content()
|
||||
# get text without header
|
||||
|
|
|
|||
|
|
@ -1,8 +1,28 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright(C) 2014 Vicnet
|
||||
#
|
||||
# This file is part of weboob.
|
||||
#
|
||||
# weboob is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Affero General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# weboob is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with weboob. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
from weboob.tools.test import BackendTest
|
||||
|
||||
__all__ = ['LaCentraleTest']
|
||||
|
||||
|
||||
class LaCentraleTest(BackendTest):
|
||||
BACKEND = 'lacentrale'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue