Make the "base" recipe more complete
This commit is contained in:
parent
32d7b53e63
commit
73d93f2d09
3 changed files with 29 additions and 1 deletions
|
|
@ -90,6 +90,7 @@ class BaseRecipe(Recipe):
|
|||
self.write('__init__.py', self.template('init'))
|
||||
self.write('backend.py', self.template('base_backend'))
|
||||
self.write('browser.py', self.template('base_browser'))
|
||||
self.write('pages.py', self.template('base_pages'))
|
||||
|
||||
|
||||
class ComicRecipe(Recipe):
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
<%inherit file="layout.py"/>
|
||||
from weboob.tools.browser import BaseBrowser
|
||||
|
||||
from .pages import Page1, Page2
|
||||
|
||||
|
||||
__all__ = ['${r.classname}Browser']
|
||||
|
||||
|
|
@ -10,4 +12,14 @@ class ${r.classname}Browser(BaseBrowser):
|
|||
DOMAIN = 'www.${r.name}.com'
|
||||
ENCODING = None
|
||||
|
||||
PAGES = {}
|
||||
PAGES = {
|
||||
'%s://%s/page1\?id=.+' % (PROTOCOL, DOMAIN): Page1,
|
||||
'%s://%s/page2' % (PROTOCOL, DOMAIN): Page2,
|
||||
}
|
||||
|
||||
def get_stuff(self, _id):
|
||||
self.location('%s://%s/page1?id=%s' % (self.PROTOCOL, self.DOMAIN, _id))
|
||||
assert self.is_on_page(Page1)
|
||||
self.page.do_stuff(_id)
|
||||
assert self.is_on_page(Page2)
|
||||
return self.page.do_more_stuff()
|
||||
|
|
|
|||
15
tools/boilerplate_data/base_pages.py
Normal file
15
tools/boilerplate_data/base_pages.py
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
<%inherit file="layout.py"/>
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
__all__ = ['Page1', 'Page2']
|
||||
|
||||
|
||||
class Page1(BasePage):
|
||||
def do_stuff(self, _id):
|
||||
raise NotImplementedError()
|
||||
|
||||
|
||||
class Page2(BasePage):
|
||||
def do_more_stuff(self):
|
||||
raise NotImplementedError()
|
||||
Loading…
Add table
Add a link
Reference in a new issue