Merge branch 'testing' of github.com:ProgVal/Limnoria into testing

This commit is contained in:
Valentin Lorentz 2012-05-02 21:33:12 +02:00
commit 96b0ae0e1e
5 changed files with 134 additions and 50 deletions

View File

@ -347,11 +347,17 @@ class Google(callbacks.PluginRegexp):
urlig = self._googleUrlIG(expr) urlig = self._googleUrlIG(expr)
js = utils.web.getUrl(urlig) js = utils.web.getUrl(urlig)
# fix bad google json # fix bad google json
js = js.replace('lhs:','"lhs":').replace('rhs:','"rhs":').replace('error:','"error":').replace('icc:','"icc":') js = js \
.replace('lhs:','"lhs":') \
.replace('rhs:','"rhs":') \
.replace('error:','"error":') \
.replace('icc:','"icc":') \
.replace('\\', '\\\\')
js = simplejson.loads(js) js = simplejson.loads(js)
if js['error'] == '': if js['error'] == '':
irc.reply("%s = %s" % (js['lhs'].encode('utf8'), js['rhs'].encode('utf8'),)) irc.reply("%s = %s" % (js['lhs'].encode('utf8').decode('string_escape'),
js['rhs'].encode('utf8').decode('string_escape'),))
return return
url = self._googleUrl(expr) url = self._googleUrl(expr)

View File

@ -1,29 +1,36 @@
# PluginDownloader plugin in Limnoria. # PluginDownloader plugin in Limnoria.
# Copyright (C) 2011 Limnoria # Copyright (C) 2011 Limnoria
# Mika Suomalainen <mika.henrik.mainio@hotmail.com>, 2011. # Mika Suomalainen <mika.henrik.mainio@hotmail.com>, 2011, 2012.
# #
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"POT-Creation-Date: 2012-03-11 20:58+UTC\n" "POT-Creation-Date: 2012-04-29 19:20+EEST\n"
"PO-Revision-Date: 2012-03-15 08:34+0200\n" "PO-Revision-Date: 2012-04-29 20:48+0200\n"
"Last-Translator: Mika Suomalainen <mika.henrik.mainio@hotmail.com>\n" "Last-Translator: Mika Suomalainen <mika.henrik.mainio@hotmail.com>\n"
"Language-Team: \n" "Language-Team: Finnish <>\n"
"Language: \n" "Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
#: plugin.py:219 #: plugin.py:245
msgid "" msgid ""
"Add the help for \"@plugin help PluginDownloader\" here\n" "This plugin allows you to install unofficial plugins from\n"
" This should describe *how* to use this plugin." " multiple repositories easily. Use the \"repolist\" command to see list of\n"
" available repositories and \"repolist <repository>\" to list plugins, \n"
" which are available in that repository. When you want to install plugin,\n"
" just run command \"install <repository> <plugin>\"."
msgstr "" msgstr ""
"Lisää ohjeteksti komennolle \"@plugin help PluginDownloader\" tähän.\n" "Tämä lisäosa sallii epävirallisten lisäosien asentamisen monista ohjelmistolähteistä\n"
" Tämän pitäisi kuvata *kuinka* tätä lisäosaa käytetään." " helposti. Käytä \"repolist\" komentoa nähdäksesi listan saatavilla olevista\n"
" ohjelmistolähteistä ja \"repolist <ohjelmistolähde>\" saadaksesi listan lisäosista,\n"
" jotka ovat saatavilla kyseisessä ohjelmistolähteessä. Kun tahdot asentaa lisäosan,\n"
" suorita vain komento \"install <ohjelmistolähde> <lisäosa>\"."
#: plugin.py:224 #: plugin.py:253
msgid "" msgid ""
"[<repository>]\n" "[<repository>]\n"
"\n" "\n"
@ -31,37 +38,43 @@ msgid ""
" If <repository> is not given, returns a list of available\n" " If <repository> is not given, returns a list of available\n"
" repositories." " repositories."
msgstr "" msgstr ""
"[<pakettivarasto>]\n" "[<ohjelmistolähde>]\n"
"\n" "\n"
" Näyttää listan lisäosista, jotka löytyvät <pakettivarastosta>.\n" " Näyttää listan lisäosista, jotka löytyvät <ohjelmistolähteestä>. Jos\n"
" Jos <pakettivarasto> ei ole annettu, palauttaa listan kaikista saataville olevista \n" " <ohjelmistolähdettä> ei ole annettu, palauttaa listan kaikista saataville olevista\n"
" pakettivarastoista." " ohjelmistolähteistä."
#: plugin.py:232 #: plugin.py:261
#: plugin.py:243 #: plugin.py:272
msgid ", " msgid ", "
msgstr ", " msgstr ", "
#: plugin.py:234 #: plugin.py:263
#: plugin.py:253 #: plugin.py:282
msgid "This repository does not exist or is not known by this bot." msgid "This repository does not exist or is not known by this bot."
msgstr "Tämä pakettivarasto ei ole olemassakaan tai tämä botti ei tiedä siitä." msgstr "Tämä ohjelmistolähde ei ole olemassakaan tai tämä botti ei tiedä siitä."
#: plugin.py:241 #: plugin.py:270
msgid "No plugin found in this repository." msgid "No plugin found in this repository."
msgstr "Lisäosaa ei löytynyt tästä pakettivarastosta." msgstr "Lisäosaa ei löytynyt tästä ohjelmistolähteestä."
#: plugin.py:248 #: plugin.py:277
msgid "" msgid ""
"<repository> <plugin>\n" "<repository> <plugin>\n"
"\n" "\n"
" Downloads and installs the <plugin> from the <repository>." " Downloads and installs the <plugin> from the <repository>."
msgstr "" msgstr ""
"<pakettivarasto> <lisäosa>\n" "<ohjelmistolähde> <lisäosa>\n"
"\n" "\n"
" Lataa ja asentaa <lisäosan> <pakettivarastosta>." " Lataa ja asentaa <lisäosan> <ohjelmistolähteestä>."
#: plugin.py:258 #: plugin.py:287
msgid "This plugin does not exist in this repository." msgid "This plugin does not exist in this repository."
msgstr "Tämä lisäosa ei ole tässä pakettivarastossa." msgstr "Tämä lisäosa ei ole tässä ohjelmistolähteessä."
#~ msgid ""
#~ "Add the help for \"@plugin help PluginDownloader\" here\n"
#~ " This should describe *how* to use this plugin."
#~ msgstr ""
#~ "Lisää ohjeteksti komennolle \"@plugin help PluginDownloader\" tähän.\n"
#~ " Tämän pitäisi kuvata *kuinka* tätä lisäosaa käytetään."

View File

@ -5,7 +5,7 @@
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2012-03-11 20:58+UTC\n" "POT-Creation-Date: 2012-04-29 17:55+UTC\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -15,14 +15,17 @@ msgstr ""
"Generated-By: pygettext.py 1.5\n" "Generated-By: pygettext.py 1.5\n"
#: plugin.py:219 #: plugin.py:260
#, docstring #, docstring
msgid "" msgid ""
"Add the help for \"@plugin help PluginDownloader\" here\n" "This plugin allows you to install unofficial plugins from\n"
" This should describe *how* to use this plugin." " multiple repositories easily. Use the \"repolist\" command to see list of\n"
" available repositories and \"repolist <repository>\" to list plugins, \n"
" which are available in that repository. When you want to install plugin,\n"
" just run command \"install <repository> <plugin>\"."
msgstr "" msgstr ""
#: plugin.py:224 #: plugin.py:268
#, docstring #, docstring
msgid "" msgid ""
"[<repository>]\n" "[<repository>]\n"
@ -32,19 +35,19 @@ msgid ""
" repositories." " repositories."
msgstr "" msgstr ""
#: plugin.py:232 plugin.py:243 #: plugin.py:276 plugin.py:287
msgid ", " msgid ", "
msgstr "" msgstr ""
#: plugin.py:234 plugin.py:253 #: plugin.py:278 plugin.py:297 plugin.py:322
msgid "This repository does not exist or is not known by this bot." msgid "This repository does not exist or is not known by this bot."
msgstr "" msgstr ""
#: plugin.py:241 #: plugin.py:285
msgid "No plugin found in this repository." msgid "No plugin found in this repository."
msgstr "" msgstr ""
#: plugin.py:248 #: plugin.py:292
#, docstring #, docstring
msgid "" msgid ""
"<repository> <plugin>\n" "<repository> <plugin>\n"
@ -52,7 +55,23 @@ msgid ""
" Downloads and installs the <plugin> from the <repository>." " Downloads and installs the <plugin> from the <repository>."
msgstr "" msgstr ""
#: plugin.py:258 #: plugin.py:302 plugin.py:327
msgid "This plugin does not exist in this repository." msgid "This plugin does not exist in this repository."
msgstr "" msgstr ""
#: plugin.py:317
#, docstring
msgid ""
"<repository> <plugin>\n"
"\n"
" Displays informations on the <plugin> in the <repository>."
msgstr ""
#: plugin.py:331
msgid "No README found for this plugin"
msgstr ""
#: plugin.py:334
msgid "This plugin has no description."
msgstr ""

View File

@ -130,19 +130,24 @@ class GithubRepository(GitRepository):
# Remember we pop(0)ed the path # Remember we pop(0)ed the path
return None return None
def _download(self, plugin):
try:
fileObject = urllib2.urlopen(self._downloadUrl)
fileObject2 = StringIO()
fileObject2.write(fileObject.read())
fileObject.close()
fileObject2.seek(0)
return tarfile.open(fileobj=fileObject2, mode='r:gz')
finally:
del fileObject
def install(self, plugin): def install(self, plugin):
archive = self._download(plugin)
prefix = archive.getnames()[0]
dirname = ''.join((self._path, plugin))
directories = conf.supybot.directories.plugins() directories = conf.supybot.directories.plugins()
directory = self._getWritableDirectoryFromList(directories) directory = self._getWritableDirectoryFromList(directories)
assert directory is not None assert directory is not None
dirname = ''.join((self._path, plugin))
fileObject = urllib2.urlopen(self._downloadUrl)
fileObject2 = StringIO()
fileObject2.write(fileObject.read())
fileObject.close()
fileObject2.seek(0)
archive = tarfile.open(fileobj=fileObject2, mode='r:gz')
prefix = archive.getnames()[0]
try: try:
assert archive.getmember(prefix + dirname).isdir() assert archive.getmember(prefix + dirname).isdir()
@ -161,8 +166,18 @@ class GithubRepository(GitRepository):
open(newFileName, 'a').write(extractedFile.read()) open(newFileName, 'a').write(extractedFile.read())
finally: finally:
archive.close() archive.close()
fileObject2.close() del archive
del archive, fileObject, fileObject2
def getInfo(self, plugin):
archive = self._download(plugin)
prefix = archive.getnames()[0]
dirname = ''.join((self._path, plugin))
print repr(prefix + dirname + '/README.txt')
for file in archive.getmembers():
print repr(file)
if file.name == prefix + dirname + '/README.txt':
extractedFile = archive.extractfile(file)
return extractedFile.read()
def _getWritableDirectoryFromList(self, directories): def _getWritableDirectoryFromList(self, directories):
for directory in directories: for directory in directories:
@ -242,8 +257,11 @@ repositories = {
} }
class PluginDownloader(callbacks.Plugin): class PluginDownloader(callbacks.Plugin):
"""Add the help for "@plugin help PluginDownloader" here """This plugin allows you to install unofficial plugins from
This should describe *how* to use this plugin.""" multiple repositories easily. Use the "repolist" command to see list of
available repositories and "repolist <repository>" to list plugins,
which are available in that repository. When you want to install plugin,
just run command "install <repository> <plugin>"."""
@internationalizeDocstring @internationalizeDocstring
def repolist(self, irc, msg, args, repository): def repolist(self, irc, msg, args, repository):
@ -294,6 +312,33 @@ class PluginDownloader(callbacks.Plugin):
install = wrap(install, ['owner', 'something', 'something']) install = wrap(install, ['owner', 'something', 'something'])
@internationalizeDocstring
def info(self, irc, msg, args, repository, plugin):
"""<repository> <plugin>
Displays informations on the <plugin> in the <repository>."""
global repositories
if repository not in repositories:
irc.error(_(
'This repository does not exist or is not known by '
'this bot.'
))
elif plugin not in repositories[repository].getPluginList():
irc.error(_('This plugin does not exist in this repository.'))
else:
info = repositories[repository].getInfo(plugin)
if info is None:
irc.error(_('No README found for this plugin'))
else:
if info.startswith('Insert a description of your plugin here'):
irc.error(_('This plugin has no description.'))
else:
info = info.split('\n\n')[0]
for line in info.split('\n'):
if line != '':
irc.reply(line)
info = wrap(info, ['something', optional('something')])
PluginDownloader = internationalizeDocstring(PluginDownloader) PluginDownloader = internationalizeDocstring(PluginDownloader)
Class = PluginDownloader Class = PluginDownloader

View File

@ -478,6 +478,7 @@ class RichReplyMethods(object):
else: else:
log.debug('Not sending capability error, ' log.debug('Not sending capability error, '
'supybot.reply.error.noCapability is False.') 'supybot.reply.error.noCapability is False.')
raise Error, 'error'
else: else:
log.warning('Denying %s for some unspecified capability ' log.warning('Denying %s for some unspecified capability '
'(or a default).', self.msg.prefix) '(or a default).', self.msg.prefix)