pax_global_header 0000666 0000000 0000000 00000000064 13514067645 0014525 g ustar 00root root 0000000 0000000 52 comment=d55ee1b5fb5ebdd456ab724438e5913e5a54d0c9
woob-d55ee1b5fb5ebdd456ab724438e5913e5a54d0c9-modules-pastealacon/ 0000775 0000000 0000000 00000000000 13514067645 0023577 5 ustar 00root root 0000000 0000000 woob-d55ee1b5fb5ebdd456ab724438e5913e5a54d0c9-modules-pastealacon/modules/ 0000775 0000000 0000000 00000000000 13514067645 0025247 5 ustar 00root root 0000000 0000000 woob-d55ee1b5fb5ebdd456ab724438e5913e5a54d0c9-modules-pastealacon/modules/pastealacon/ 0000775 0000000 0000000 00000000000 13514067645 0027541 5 ustar 00root root 0000000 0000000 woob-d55ee1b5fb5ebdd456ab724438e5913e5a54d0c9-modules-pastealacon/modules/pastealacon/__init__.py 0000664 0000000 0000000 00000001522 13514067645 0031652 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2011 Laurent Bachelier
#
# This file is part of a weboob module.
#
# This weboob module 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.
#
# This weboob module 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 this weboob module. If not, see .
from .module import PastealaconModule
__all__ = ['PastealaconModule']
woob-d55ee1b5fb5ebdd456ab724438e5913e5a54d0c9-modules-pastealacon/modules/pastealacon/browser.py 0000664 0000000 0000000 00000007475 13514067645 0031613 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2011-2014 Laurent Bachelier
#
# This file is part of a weboob module.
#
# This weboob module 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.
#
# This weboob module 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 this weboob module. If not, see .
import re
from weboob.capabilities.paste import BasePaste, PasteNotFound
from weboob.browser.filters.standard import BrowserURL, CleanText, DateTime, Env, Field, RawText, Regexp
from weboob.browser.pages import HTMLPage
from weboob.browser.browsers import PagesBrowser
from weboob.browser.url import URL
from weboob.browser.elements import ItemElement, method
from weboob.exceptions import BrowserHTTPNotFound
class Spam(Exception):
def __init__(self):
super(Spam, self).__init__("Detected as spam and unable to handle the captcha")
class PastealaconPaste(BasePaste):
# all pastes are public
public = True
# TODO perhaps move this logic elsewhere, remove this and id2url from capability
# (page_url is required by pastoob)
@property
def page_url(self):
return self.url
class PastePage(HTMLPage):
@method
class fill_paste(ItemElement):
klass = PastealaconPaste
obj_id = Env('id')
obj_title = Regexp(CleanText('id("content")/h3'), r'Posted by (.+) on .+ \(')
obj__date = DateTime(Regexp(CleanText('id("content")/h3'), r'Posted by .+ on (.+) \('))
obj_contents = RawText('//textarea[@id="code"]')
obj_url = BrowserURL('paste', id=Field('id'))
def parse(self, el):
# there is no 404, try to detect if there really is a content
if len(el.xpath('id("content")/div[@class="syntax"]//ol')) != 1:
raise PasteNotFound()
class CaptchaPage(HTMLPage):
pass
class PostPage(HTMLPage):
def post(self, paste, expiration=None):
form = self.get_form(name='editor')
form['code2'] = paste.contents
form['poster'] = paste.title
if expiration:
form['expiry'] = expiration
form.submit()
class PastealaconBrowser(PagesBrowser):
BASEURL = 'http://paste.alacon.org/'
paste = URL(r'(?P\d+)', PastePage)
captcha = URL(r'%s' % re.escape('pastebin.php?captcha=1'), CaptchaPage)
raw = URL(r'%s(?P\d+)' % re.escape('pastebin.php?dl='))
post = URL(r'$', PostPage)
@paste.id2url
def get_paste(self, url):
url = self.absurl(url, base=True)
m = self.paste.match(url)
if m:
return PastealaconPaste(m.groupdict()['id'])
def fill_paste(self, paste):
"""
Get as much as information possible from the paste page
"""
self.paste.stay_or_go(id=paste.id)
return self.page.fill_paste(paste)
def get_contents(self, _id):
"""
Get the contents from the raw URL
This is the fastest and safest method if you only want the content.
Returns unicode.
"""
try:
# despite what the HTTP header says, it is iso8859
return self.raw.open(id=_id).content.decode('iso8859-15')
except BrowserHTTPNotFound:
raise PasteNotFound()
def post_paste(self, paste, expiration=None):
self.post.stay_or_go().post(paste, expiration=expiration)
if self.captcha.is_here():
raise Spam()
self.page.fill_paste(paste)
woob-d55ee1b5fb5ebdd456ab724438e5913e5a54d0c9-modules-pastealacon/modules/pastealacon/favicon.png 0000664 0000000 0000000 00000004633 13514067645 0031702 0 ustar 00root root 0000000 0000000 PNG
IHDR @ @ iq sRGB bKGD pHYs tIME7Uk tEXtComment Created with GIMPW IDATx{T?;ٙ]XV\Qb.Tj`F4GӐj1ilS[Fcc"ES1EQ4Z>hQ`]>f1gu2e7Mn2|={5PC
5PC
GJA0P :
@ ,~|d
G*`+PtZ_a`NUHGT,$|8``
cӋDz:z
<:?Pb`WŮLKUF|
*x~V1̈́L56?>D(>2^27c#vNP&,?5D87"ij# = dHL HV3Y\Xύ9d(\W l
!(xB B&S&0B\qG+{4L/ldUpk8 `-Bϟ2zBU flI4cg {mZ{{g/vA*{8 a_Zy{9S~=/_43ob}Wڶfo''CpgQv`۴aUypwBt; כ<{Ułsύ 3|g u(-A[ft?
-b`$yg"*
M$O{Yk57dsm7IgW\xv3Å 'Qr},o!|u\+x{*?vS`Ό545&x^.nk}HD"Dlw{p
ht/IvNsِ4 ],0+]cAAklK=QEl2=oE6ś窼C87TG0dԓgk c
q.Ho(t^Ztt|#@X!'_79'hqNx rI+vudO_xj |l#4;|Ȝ|ޮ| <oKuؒŭٜG2a
):=' [h;h/c6Q[rCi' @]ڂ(Ncf&ƌoI+MkO$imQFwu
18wЍ%oە~k `;\K%C!@
I`BPn97ƭyjxkZ qNf9z
㢯iM!x3?U
N)h+}+a!:@y9/t_]E#hEOU4BZH+=Vvߊf
AhFHI5k>wZ N!d^+\B{QH
+nv?v@ϿaTP,{Va#+H+~@N6|·:sP~gZ+4"!$*Ru'/}
)@h5+ղvhKSZt$rra%R ;+h]*~^Oʇ;*hNy ^ؕjY=t
09teZAInf `淓s.kDv)G!v\JMkY洫