pax_global_header 0000666 0000000 0000000 00000000064 12043305005 0014502 g ustar 00root root 0000000 0000000 52 comment=4a1e4b5afa156a6973ff097c2143d5ffcb0d0e32
woob-4a1e4b5afa156a6973ff097c2143d5ffcb0d0e32-modules-ebonics/ 0000775 0000000 0000000 00000000000 12043305005 0022664 5 ustar 00root root 0000000 0000000 woob-4a1e4b5afa156a6973ff097c2143d5ffcb0d0e32-modules-ebonics/modules/ 0000775 0000000 0000000 00000000000 12043305005 0024334 5 ustar 00root root 0000000 0000000 woob-4a1e4b5afa156a6973ff097c2143d5ffcb0d0e32-modules-ebonics/modules/ebonics/ 0000775 0000000 0000000 00000000000 12043305005 0025756 5 ustar 00root root 0000000 0000000 woob-4a1e4b5afa156a6973ff097c2143d5ffcb0d0e32-modules-ebonics/modules/ebonics/__init__.py 0000664 0000000 0000000 00000001436 12043305005 0030073 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2012 Romain Bignon
#
# 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 .
from .backend import EbonicsBackend
__all__ = ['EbonicsBackend']
woob-4a1e4b5afa156a6973ff097c2143d5ffcb0d0e32-modules-ebonics/modules/ebonics/backend.py 0000664 0000000 0000000 00000003777 12043305005 0027735 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2012 Romain Bignon
#
# 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 .
import urllib
from weboob.capabilities.translate import ICapTranslate, Translation, TranslationFail, LanguageNotSupported
from weboob.tools.backend import BaseBackend
from weboob.tools.browser import StandardBrowser
__all__ = ['EbonicsBackend']
class EbonicsBackend(BaseBackend, ICapTranslate):
NAME = 'ebonics'
MAINTAINER = u'Romain Bignon'
EMAIL = 'romain@weboob.org'
VERSION = '0.e'
LICENSE = 'AGPLv3+'
DESCRIPTION = u'English to Ebonics translation service'
BROWSER = StandardBrowser
def translate(self, lan_from, lan_to, text):
if lan_from != 'English' or lan_to != 'Nigger!':
raise LanguageNotSupported()
with self.browser:
data = {'English': text.encode('utf-8')}
doc = self.browser.location('http://joel.net/EBONICS/Translator', urllib.urlencode(data))
try:
text = doc.getroot().cssselect('div.translateform div.bubble1 div.bubblemid')[0].text
except IndexError:
raise TranslationFail()
if text is None:
raise TranslationFail()
translation = Translation(0)
translation.lang_src = unicode(lan_from)
translation.lang_dst = unicode(lan_to)
translation.text = unicode(text).strip()
return translation
woob-4a1e4b5afa156a6973ff097c2143d5ffcb0d0e32-modules-ebonics/modules/ebonics/test.py 0000664 0000000 0000000 00000001701 12043305005 0027306 0 ustar 00root root 0000000 0000000 # -*- coding: utf-8 -*-
# Copyright(C) 2012 Romain Bignon
#
# 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 .
from weboob.tools.test import BackendTest
__all__ = ['EbonicsTest']
class EbonicsTest(BackendTest):
BACKEND = 'ebonics'
def test_translate(self):
self.backend.translate('English', 'Nigger!', 'I like penis.')