FortyTwo: Remove plugin.

master
Valentin Lorentz 2013-02-01 19:24:49 +01:00
parent afc32c6c1d
commit 472052f973
10 changed files with 2 additions and 536 deletions

View File

@ -1,5 +0,0 @@
This plugin is designed for the channel #42 @ Geeknode, which deals with
the .42 tld. Check out http://42registry.org/ for more informations.
There is no reason to use this plugin for other usage, but I publish it
anyway, because libre software is the Good.

View File

@ -1,66 +0,0 @@
###
# Copyright (c) 2011, Valentin Lorentz
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions, and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions, and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the author of this software nor the name of
# contributors to this software may be used to endorse or promote products
# derived from this software without specific prior written consent.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
###
"""
Add a description of the plugin (to be presented to the user inside the wizard)
here. This should describe *what* the plugin does.
"""
import supybot
import supybot.world as world
# Use this for the version of this plugin. You may wish to put a CVS keyword
# in here if you're keeping the plugin in CVS or some similar system.
__version__ = ""
# XXX Replace this with an appropriate author or supybot.Author instance.
__author__ = supybot.authors.progval
# This is a dictionary mapping supybot.Author instances to lists of
# contributions.
__contributors__ = {}
# This is a url where the most recent plugin package can be downloaded.
__url__ = '' # 'http://supybot.com/Members/yourname/42Chan/download'
import config
import plugin
reload(plugin) # In case we're being reloaded.
# Add more reloads here if you add third-party modules and want them to be
# reloaded when this plugin is reloaded. Don't forget to import them as well!
if world.testing:
import test
Class = plugin.Class
configure = config.configure
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -1,65 +0,0 @@
###
# Copyright (c) 2011, Valentin Lorentz
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions, and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions, and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the author of this software nor the name of
# contributors to this software may be used to endorse or promote products
# derived from this software without specific prior written consent.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
###
import supybot.conf as conf
import supybot.registry as registry
try:
from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring
_ = PluginInternationalization('FortyTwo')
except:
# This are useless functions that's allow to run the plugin on a bot
# without the i18n plugin
_ = lambda x:x
internationalizeDocstring = lambda x:x
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
# a bool that specifies whether the user identified himself as an advanced
# user or not. You should effect your configuration by manipulating the
# registry as appropriate.
from supybot.questions import expect, anything, something, yn
conf.registerPlugin('FortyTwo', True)
FortyTwo = conf.registerPlugin('FortyTwo')
# This is where your configuration variables (if any) should go. For example:
# conf.registerGlobalValue(FortyTwo, 'someConfigVariableName',
# registry.Boolean(False, _("""Help for someConfigVariableName.""")))
conf.registerGlobalValue(FortyTwo, 'lifetime',
registry.Integer(60, _("""Defines the cache lifetime (in seconds).""")))
conf.registerGlobalValue(FortyTwo, 'source',
registry.String('http://search.42/domains.xml',
_("""Defines where the XML data file is.""")))
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -1 +0,0 @@
# Stub so local is a module, used for third-party modules

View File

@ -1,66 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: Supybot-fr\n"
"POT-Creation-Date: 2011-01-01 16:50+CET\n"
"PO-Revision-Date: \n"
"Last-Translator: Valentin Lorentz <progval@gmail.com>\n"
"Language-Team: Supybot-fr <progval@gmail.com>\n"
"Language: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Poedit-Language: Français\n"
"X-Poedit-Country: France\n"
#: plugin.py:52
msgid "Unknown node '%s'"
msgstr "Nœud '%s' inconnu"
#: plugin.py:71
msgid ""
"Add the help for \"@plugin help 42Chan\" here\n"
" This should describe *how* to use this plugin."
msgstr ""
#: plugin.py:75
msgid ""
"[--domain <glob>] [--purpose <glob>] [--resolve <true|false>] [--http <integer>]\n"
"\n"
" Returns all the domains that matches the search. --domain and\n"
" --purpose take a glob (a string with wildcards) that have to match\n"
" the results, --resolves means the domain is resolved, and --http is\n"
" the HTTP response status (000 for a domain that isn't resolved)."
msgstr ""
"[--domain <glob>] [--purpose <glob>] [--resolve <true|false>] [--http <entier>]\n"
"\n"
"Retourne tous les domaines qui correspondent à la recherche. --domain et --purpose reçoivent un glob (une chaîne avec des jokers), qui doit correspondre aux résultats. --resolves correspond au fait que le domaine soit résolu, et --http correspond au code de réponse HTTP (000 pour un domaine qui n'est pas résolu)."
#: plugin.py:103
#: plugin.py:131
msgid "No such domain"
msgstr "Ce domaine n'existe pas"
#: plugin.py:105
msgid ", "
msgstr ", "
#: plugin.py:113
msgid ""
"takes no arguments\n"
"\n"
" Fetches data from the domains list source."
msgstr ""
"ne prend pas d'argument\n"
"\n"
"Récupère les données depuis la source de la liste de domaines."
#: plugin.py:121
msgid ""
"<domain>\n"
"\n"
" Returns the purpose of the given domain."
msgstr ""
"<domaine>\n"
"\n"
"Retourne la description du domaine donné."

View File

@ -1,71 +0,0 @@
msgid ""
msgstr ""
"Project-Id-Version: Supybot-fr\n"
"POT-Creation-Date: 2011-02-26 09:49+CET\n"
"PO-Revision-Date: 2011-07-29 11:33+0200\n"
"Last-Translator: skizzhg <skizzhg@gmx.com>\n"
"Language-Team: Italian <skizzhg@gmx.com>\n"
"Language: it\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
#: plugin.py:52
msgid "Unknown node '%s'"
msgstr "Nodo \"%s\" sconosciuto"
#: plugin.py:71
#, docstring
msgid ""
"Add the help for \"@plugin help 42Chan\" here\n"
" This should describe *how* to use this plugin."
msgstr ""
#: plugin.py:75
#, docstring
msgid ""
"[--domain <glob>] [--purpose <glob>] [--resolve <true|false>] [--http <integer>]\n"
"\n"
" Returns all the domains that matches the search. --domain and\n"
" --purpose take a glob (a string with wildcards) that have to match\n"
" the results, --resolves means the domain is resolved, and --http is\n"
" the HTTP response status (000 for a domain that isn't resolved)."
msgstr ""
"[--domain <glob>] [--purpose <glob>] [--resolve <true|false>] [--http <intero>]\n"
"\n"
" Restituisce tutti i domini che corrispondono alla ricerca. --domain e\n"
" --purpose accettano un glob pattern (una stringa con wildcard) che deve\n"
" corrispondere ai risultati, --resolves significa che il dominio è stato\n"
" risolto e --http lo stato di risposta HTTP (000 per un dominio non risolto)."
#: plugin.py:103 plugin.py:131
msgid "No such domain"
msgstr "Nessun dominio"
#: plugin.py:105
msgid ", "
msgstr ", "
#: plugin.py:113
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Fetches data from the domains list source."
msgstr ""
"non necessita argomenti\n"
"\n"
" Recupera i dati dalla fonte dell'elenco dei domini."
#: plugin.py:121
#, docstring
msgid ""
"<domain>\n"
"\n"
" Returns the purpose of the given domain."
msgstr ""
"<dominio>\n"
"\n"
" Restituisce la descrizione del dato dominio."

View File

@ -1,63 +0,0 @@
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2011-01-01 16:50+CET\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"
#: plugin.py:52
msgid "Unknown node '%s'"
msgstr ""
#: plugin.py:71
#, docstring
msgid ""
"Add the help for \"@plugin help 42Chan\" here\n"
" This should describe *how* to use this plugin."
msgstr ""
#: plugin.py:75
#, docstring
msgid ""
"[--domain <glob>] [--purpose <glob>] [--resolve <true|false>] [--http <integer>]\n"
"\n"
" Returns all the domains that matches the search. --domain and\n"
" --purpose take a glob (a string with wildcards) that have to match\n"
" the results, --resolves means the domain is resolved, and --http is\n"
" the HTTP response status (000 for a domain that isn't resolved)."
msgstr ""
#: plugin.py:103 plugin.py:131
msgid "No such domain"
msgstr ""
#: plugin.py:105
msgid ", "
msgstr ""
#: plugin.py:113
#, docstring
msgid ""
"takes no arguments\n"
"\n"
" Fetches data from the domains list source."
msgstr ""
#: plugin.py:121
#, docstring
msgid ""
"<domain>\n"
"\n"
" Returns the purpose of the given domain."
msgstr ""

View File

@ -1,141 +0,0 @@
###
# Copyright (c) 2011, Valentin Lorentz
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions, and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions, and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the author of this software nor the name of
# contributors to this software may be used to endorse or promote products
# derived from this software without specific prior written consent.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
###
import re
import time
import fnmatch
from xml.dom import minidom
import supybot.utils as utils
from supybot.commands import *
import supybot.plugins as plugins
import supybot.ircutils as ircutils
import supybot.callbacks as callbacks
try:
from supybot.i18n import PluginInternationalization
from supybot.i18n import internationalizeDocstring
_ = PluginInternationalization('FortyTwo')
except:
# This are useless functions that's allow to run the plugin on a bot
# without the i18n plugin
_ = lambda x:x
internationalizeDocstring = lambda x:x
class Domain:
def __init__(self, dom, warnings):
self.domain = None
self.purpose = None
for node in dom.childNodes:
if not node.nodeName in 'domain purpose'.split():
warnings.append(_("Unknown node '%s'") % node.nodeName)
continue
try:
data = node.firstChild.data
except AttributeError:
# Empty purpose, for instance
data = ''
self.__dict__.update({node.nodeName: data})
assert None not in (self.domain, self.purpose)
@internationalizeDocstring
class FortyTwo(callbacks.Plugin):
"""Add the help for "@plugin help 42Chan" here
This should describe *how* to use this plugin."""
@internationalizeDocstring
def find(self, irc, msg, args, optlist):
"""[--domain <glob>] [--purpose <glob>]
Returns all the domains that matches the search. --domain and
--purpose take a glob (a string with wildcards) that have to match
the results, --resolves means the domain is resolved, and --http is
the HTTP response status (000 for a domain that isn't resolved)."""
def translate(glob):
return re.compile(fnmatch.translate(glob), re.I)
domain, purpose = translate('*'), translate('*')
resolve, http = None, None
for name, value in optlist:
if name == 'domain': domain = translate(value)
if name == 'purpose': purpose = translate(value)
if not hasattr(self, '_lastRefresh') or \
self._lastRefresh<time.time()-self.registryValue('lifetime'):
self._refreshCache()
results = []
for obj in self._domains:
if not domain.match(obj.domain) or not purpose.match(obj.purpose):
continue
results.append(obj.domain)
if results == []:
irc.error(_('No such domain'))
else:
irc.reply(_(', ').join(results))
find = wrap(find, [getopts({'domain': 'glob', 'purpose': 'glob'})])
@internationalizeDocstring
def fetch(self, irc, msg, args):
"""takes no arguments
Fetches data from the domains list source."""
self._refreshCache()
irc.replySuccess()
@internationalizeDocstring
def purpose(self, irc, msg, args, domain):
"""<domain>
Returns the purpose of the given domain."""
if not hasattr(self, '_lastRefresh') or \
self._lastRefresh<time.time()-self.registryValue('lifetime'):
self._refreshCache()
for obj in self._domains:
if obj.domain == domain:
irc.reply(obj.purpose)
return
irc.error(_('No such domain'))
purpose = wrap(purpose, ['somethingWithoutSpaces'])
def _refreshCache(self):
self._lastRefresh = time.time()
xml = utils.web.getUrl(self.registryValue('source'))
dom = minidom.parseString(xml)
warnings = []
root = None
for child in dom.childNodes:
if child.nodeName == 'domains':
root = child
break
assert root is not None
self._domains = [Domain(child, warnings) for child in root.childNodes
if child.nodeName == 'item']
Class = FortyTwo
# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:

View File

@ -1,56 +0,0 @@
###
# Copyright (c) 2011, Valentin Lorentz
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions, and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions, and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of the author of this software nor the name of
# contributors to this software may be used to endorse or promote products
# derived from this software without specific prior written consent.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
###
from supybot.test import *
class FortyTwoTestCase(PluginTestCase):
plugins = ('FortyTwo',)
def testCache(self):
self.assertNotError('fetch')
def testFind(self):
self.assertNotError('find')
self.assertNotError('find --domain nic.42')
self.assertNotError('find --domain n?c.42')
self.assertError('find --domain egiergergrkghoerhergejrgerhg')
self.assertNotError('find --purpose *42registry*')
self.assertNotError('find --purpose *42regi?try*')
self.assertError('find --purpose egiergergrkghoerhergejrgerhg')
self.assertResponse('find --domain nic?42', 'nic.42')
def testPurpose(self):
self.assertError('purpose')
self.assertError('purpose irjroirgjrkgr.42')
self.assertResponse('purpose nic.42',
'Another redirection to register.42registry.org')
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:

View File

@ -34,8 +34,8 @@ class SeeksTestCase(PluginTestCase):
plugins = ('Seeks',)
def testSearch(self):
self.assertRegexp('seeks search supybot', 'supybot.com')
# If supybot.com is not the first result, it is a major problem ;)
self.assertRegexp('seeks search supybot',
'http://sourceforge.net/projects/supybot/')
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79: