Easy spacing fixes, trailing stuff
Remove useless trailing \ Remove trailing spaces Add missing empty lines autopep8 -ir -j2 --select=E301,E302,E502,W291,W293,W391 . Diff quickly checked.
This commit is contained in:
parent
c21d1f7925
commit
7094931c92
231 changed files with 474 additions and 67 deletions
|
|
@ -167,7 +167,7 @@ class DLFPBackend(BaseBackend, ICapMessages, ICapMessagesPost, ICapContent):
|
|||
date=com.date,
|
||||
parent=parent,
|
||||
content=com.body,
|
||||
signature=com.signature + \
|
||||
signature=com.signature +
|
||||
'<br />'.join(['Score: %d' % com.score,
|
||||
'URL: %s' % com.url]),
|
||||
children=[],
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ from .pages.wiki import WikiEditPage
|
|||
from .tools import id2url, url2id
|
||||
|
||||
# Browser
|
||||
|
||||
|
||||
class DLFP(BaseBrowser):
|
||||
DOMAIN = 'linuxfr.org'
|
||||
PROTOCOL = 'https'
|
||||
|
|
|
|||
|
|
@ -23,8 +23,10 @@ from logging import warning
|
|||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
class Message(object):
|
||||
TIMESTAMP_REGEXP = re.compile(r'(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})')
|
||||
|
||||
def __init__(self, id, timestamp, login, message, is_me):
|
||||
self.id = id
|
||||
self.timestamp = timestamp
|
||||
|
|
@ -40,6 +42,7 @@ class Message(object):
|
|||
else:
|
||||
warning('Unable to parse timestamp "%s"' % timestamp)
|
||||
|
||||
|
||||
class BoardIndexPage(BasePage):
|
||||
def is_logged(self):
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
from weboob.tools.browser import BasePage
|
||||
|
||||
|
||||
class DLFPPage(BasePage):
|
||||
def is_logged(self):
|
||||
for form in self.document.getiterator('form'):
|
||||
|
|
@ -28,6 +29,7 @@ class DLFPPage(BasePage):
|
|||
|
||||
return True
|
||||
|
||||
|
||||
class IndexPage(DLFPPage):
|
||||
def get_login_token(self):
|
||||
form = self.parser.select(self.document.getroot(), 'form#new_account_sidebar', 1)
|
||||
|
|
@ -35,5 +37,6 @@ class IndexPage(DLFPPage):
|
|||
if i.attrib['name'] == 'authenticity_token':
|
||||
return i.attrib['value']
|
||||
|
||||
|
||||
class LoginPage(DLFPPage):
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -26,10 +26,12 @@ from ..tools import url2id
|
|||
|
||||
from .index import DLFPPage
|
||||
|
||||
|
||||
class RSSComment(DLFPPage):
|
||||
def on_loaded(self):
|
||||
pass
|
||||
|
||||
|
||||
class Content(object):
|
||||
TAGGABLE = False
|
||||
|
||||
|
|
@ -50,6 +52,7 @@ class Content(object):
|
|||
def is_taggable(self):
|
||||
return False
|
||||
|
||||
|
||||
class Comment(Content):
|
||||
def __init__(self, article, div, reply_id):
|
||||
Content.__init__(self, article.browser)
|
||||
|
|
@ -105,6 +108,7 @@ class Comment(Content):
|
|||
def __repr__(self):
|
||||
return u"<Comment id=%r author=%r title=%r>" % (self.id, self.author, self.title)
|
||||
|
||||
|
||||
class Article(Content):
|
||||
TAGGABLE = True
|
||||
|
||||
|
|
@ -149,11 +153,13 @@ class Article(Content):
|
|||
for c in comment.iter_all_comments():
|
||||
yield c
|
||||
|
||||
|
||||
class CommentPage(DLFPPage):
|
||||
def get_comment(self):
|
||||
article = Article(self.browser, self.url, None)
|
||||
return Comment(article, self.parser.select(self.document.getroot(), 'li.comment', 1), 0)
|
||||
|
||||
|
||||
class ContentPage(DLFPPage):
|
||||
def on_loaded(self):
|
||||
self.article = None
|
||||
|
|
@ -192,9 +198,11 @@ class ContentPage(DLFPPage):
|
|||
def get_tag_url(self):
|
||||
return self.parser.select(self.document.getroot(), 'div.tag_in_place', 1).find('a').attrib['href']
|
||||
|
||||
|
||||
class NewCommentPage(DLFPPage):
|
||||
pass
|
||||
|
||||
|
||||
class NewTagPage(DLFPPage):
|
||||
def _is_tag_form(self, form):
|
||||
return form.action.endswith('/tags')
|
||||
|
|
@ -204,6 +212,7 @@ class NewTagPage(DLFPPage):
|
|||
self.browser['tags'] = tag
|
||||
self.browser.submit()
|
||||
|
||||
|
||||
class NodePage(DLFPPage):
|
||||
def get_errors(self):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ from weboob.tools.browser import BrokenPageError
|
|||
|
||||
from .index import DLFPPage
|
||||
|
||||
|
||||
class WikiEditPage(DLFPPage):
|
||||
def get_body(self):
|
||||
try:
|
||||
|
|
|
|||
|
|
@ -31,9 +31,11 @@ REGEXPS = {'/users/%s/journaux/%s': 'D%s.%s',
|
|||
'/forums/%s/posts/%s': 'B%s.%s',
|
||||
}
|
||||
|
||||
|
||||
def f2re(f):
|
||||
return '.*' + f.replace('%s', '([^ /]+)')
|
||||
|
||||
|
||||
def rssid(entry):
|
||||
m = RSSID_RE.match(entry.id)
|
||||
if not m:
|
||||
|
|
@ -53,6 +55,7 @@ def rssid(entry):
|
|||
else:
|
||||
return '%s.%s' % (ind, m.group(2))
|
||||
|
||||
|
||||
def id2url(id):
|
||||
m = ID2URL_RE.match(id)
|
||||
if not m:
|
||||
|
|
@ -67,6 +70,7 @@ def id2url(id):
|
|||
else:
|
||||
return url_re % m.group(3)
|
||||
|
||||
|
||||
def url2id(url):
|
||||
for url_re, id_re in REGEXPS.iteritems():
|
||||
m = re.match(f2re(url_re), url)
|
||||
|
|
@ -75,6 +79,7 @@ def url2id(url):
|
|||
|
||||
return id_re % m.groups()
|
||||
|
||||
|
||||
def id2threadid(id):
|
||||
m = ID2URL_RE.match(id)
|
||||
if m:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue