From 7fadad0e3dffd1921f5101c759b05f31a6934217 Mon Sep 17 00:00:00 2001 From: Mika Suomalainen Date: Sun, 29 Apr 2012 19:25:44 +0300 Subject: [PATCH 1/7] PluginDownloader: add @plugin help PluginDownloader. --- plugins/PluginDownloader/messages.pot | 23 +++++++++++++---------- plugins/PluginDownloader/plugin.py | 7 +++++-- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/plugins/PluginDownloader/messages.pot b/plugins/PluginDownloader/messages.pot index d259b524b..f76b858db 100644 --- a/plugins/PluginDownloader/messages.pot +++ b/plugins/PluginDownloader/messages.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE 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: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -15,14 +15,17 @@ msgstr "" "Generated-By: pygettext.py 1.5\n" -#: plugin.py:219 +#: plugin.py:245 #, docstring msgid "" -"Add the help for \"@plugin help PluginDownloader\" here\n" -" This should describe *how* to use this plugin." +"This plugin allows you to install unofficial plugins from\n" +" multiple repositories easily. Use the \"repolist\" command to see list of\n" +" available repositories and \"repolist \" to list plugins, \n" +" which are available in that repository. When you want to install plugin,\n" +" just run command \"install \"." msgstr "" -#: plugin.py:224 +#: plugin.py:253 #, docstring msgid "" "[]\n" @@ -32,19 +35,19 @@ msgid "" " repositories." msgstr "" -#: plugin.py:232 plugin.py:243 +#: plugin.py:261 plugin.py:272 msgid ", " msgstr "" -#: plugin.py:234 plugin.py:253 +#: plugin.py:263 plugin.py:282 msgid "This repository does not exist or is not known by this bot." msgstr "" -#: plugin.py:241 +#: plugin.py:270 msgid "No plugin found in this repository." msgstr "" -#: plugin.py:248 +#: plugin.py:277 #, docstring msgid "" " \n" @@ -52,7 +55,7 @@ msgid "" " Downloads and installs the from the ." msgstr "" -#: plugin.py:258 +#: plugin.py:287 msgid "This plugin does not exist in this repository." msgstr "" diff --git a/plugins/PluginDownloader/plugin.py b/plugins/PluginDownloader/plugin.py index 80b79d86b..546e53a23 100644 --- a/plugins/PluginDownloader/plugin.py +++ b/plugins/PluginDownloader/plugin.py @@ -242,8 +242,11 @@ repositories = { } class PluginDownloader(callbacks.Plugin): - """Add the help for "@plugin help PluginDownloader" here - This should describe *how* to use this plugin.""" + """This plugin allows you to install unofficial plugins from + multiple repositories easily. Use the "repolist" command to see list of + available repositories and "repolist " to list plugins, + which are available in that repository. When you want to install plugin, + just run command "install ".""" @internationalizeDocstring def repolist(self, irc, msg, args, repository): From 5f5a9f79e12bdb3f5c1626ca74a94bf703901f20 Mon Sep 17 00:00:00 2001 From: Mika Suomalainen Date: Sun, 29 Apr 2012 20:32:20 +0300 Subject: [PATCH 2/7] PluginDownloader: update l10n-fi. --- plugins/PluginDownloader/locale/fi.po | 54 ++++++++++++++++++--------- 1 file changed, 36 insertions(+), 18 deletions(-) diff --git a/plugins/PluginDownloader/locale/fi.po b/plugins/PluginDownloader/locale/fi.po index bdf8a79cd..f9cb056e9 100644 --- a/plugins/PluginDownloader/locale/fi.po +++ b/plugins/PluginDownloader/locale/fi.po @@ -1,29 +1,42 @@ # PluginDownloader plugin in Limnoria. # Copyright (C) 2011 Limnoria -# Mika Suomalainen , 2011. +# Mika Suomalainen , 2011, 2012. # msgid "" msgstr "" "Project-Id-Version: \n" -"POT-Creation-Date: 2012-03-11 20:58+UTC\n" -"PO-Revision-Date: 2012-03-15 08:34+0200\n" +"POT-Creation-Date: 2012-04-29 19:20+EEST\n" +"PO-Revision-Date: 2012-04-29 20:32+0300\n" "Last-Translator: Mika Suomalainen \n" -"Language-Team: \n" +"Language-Team: Finnish <>\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: pygettext.py 1.5\n" +"Plural-Forms: nplurals=2; plural=(n!=1);\n" -#: plugin.py:219 +#: plugin.py:245 msgid "" -"Add the help for \"@plugin help PluginDownloader\" here\n" -" This should describe *how* to use this plugin." +"This plugin allows you to install unofficial plugins from\n" +" multiple repositories easily. Use the \"repolist\" command to see list " +"of\n" +" available repositories and \"repolist \" to list plugins, \n" +" which are available in that repository. When you want to install " +"plugin,\n" +" just run command \"install \"." 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." +"Tämä lisäosa sallii epävirallisten lisäosien asentamisen monista " +"ohjelmistolähteistä\n" +" helposti. Käytä \"repolist\" komentoa nähdäksesi listan saatavilla " +"olevista\n" +" ohjelmistolähteistä ja \"repolist \" saadaksesi listan " +"lisäosista,\n" +" jotka ovat saatavilla kyseisessä ohjelmistolähteessä. Kun tahdot asentaa " +"lisäosan,\n" +" suorita vain komento \"install \"." -#: plugin.py:224 +#: plugin.py:253 msgid "" "[]\n" "\n" @@ -34,24 +47,23 @@ msgstr "" "[]\n" "\n" " Näyttää listan lisäosista, jotka löytyvät .\n" -" Jos ei ole annettu, palauttaa listan kaikista saataville olevista \n" +" Jos ei ole annettu, palauttaa listan kaikista " +"saataville olevista \n" " pakettivarastoista." -#: plugin.py:232 -#: plugin.py:243 +#: plugin.py:261 plugin.py:272 msgid ", " msgstr ", " -#: plugin.py:234 -#: plugin.py:253 +#: plugin.py:263 plugin.py:282 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ä." -#: plugin.py:241 +#: plugin.py:270 msgid "No plugin found in this repository." msgstr "Lisäosaa ei löytynyt tästä pakettivarastosta." -#: plugin.py:248 +#: plugin.py:277 msgid "" " \n" "\n" @@ -61,7 +73,13 @@ msgstr "" "\n" " Lataa ja asentaa ." -#: plugin.py:258 +#: plugin.py:287 msgid "This plugin does not exist in this repository." msgstr "Tämä lisäosa ei ole tässä pakettivarastossa." +#~ 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." From 9dcb9763464456aeca46584a9a63a78a5b13e9b7 Mon Sep 17 00:00:00 2001 From: Mika Suomalainen Date: Sun, 29 Apr 2012 20:42:25 +0300 Subject: [PATCH 3/7] PluginDownloader: fix l10n-fi. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "pakettivarasto" --> "ohjelmistolähde" --- plugins/PluginDownloader/locale/fi.po | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/plugins/PluginDownloader/locale/fi.po b/plugins/PluginDownloader/locale/fi.po index f9cb056e9..5167159b2 100644 --- a/plugins/PluginDownloader/locale/fi.po +++ b/plugins/PluginDownloader/locale/fi.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2012-04-29 19:20+EEST\n" -"PO-Revision-Date: 2012-04-29 20:32+0300\n" +"PO-Revision-Date: 2012-04-29 20:42+0300\n" "Last-Translator: Mika Suomalainen \n" "Language-Team: Finnish <>\n" "Language: \n" @@ -44,12 +44,12 @@ msgid "" " If is not given, returns a list of available\n" " repositories." msgstr "" -"[]\n" +"[]\n" "\n" -" Näyttää listan lisäosista, jotka löytyvät .\n" -" Jos ei ole annettu, palauttaa listan kaikista " -"saataville olevista \n" -" pakettivarastoista." +" Näyttää listan lisäosista, jotka löytyvät . Jos\n" +" ei ole annettu, palauttaa listan kaikista saataville " +"olevista\n" +" ohjelmistolähteistä." #: plugin.py:261 plugin.py:272 msgid ", " @@ -57,11 +57,12 @@ msgstr ", " #: plugin.py:263 plugin.py:282 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:270 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:277 msgid "" @@ -69,13 +70,13 @@ msgid "" "\n" " Downloads and installs the from the ." msgstr "" -" \n" +" \n" "\n" -" Lataa ja asentaa ." +" Lataa ja asentaa ." #: plugin.py:287 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" From f8a3de463251767364c7b25427372fee95da667c Mon Sep 17 00:00:00 2001 From: Mika Suomalainen Date: Sun, 29 Apr 2012 20:49:11 +0300 Subject: [PATCH 4/7] PluginDownloader: fix l10n-fi. check_trans.py doesn't like GTranslator, it seems. --- plugins/PluginDownloader/locale/fi.po | 32 +++++++++++---------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/plugins/PluginDownloader/locale/fi.po b/plugins/PluginDownloader/locale/fi.po index 5167159b2..1637bf7f2 100644 --- a/plugins/PluginDownloader/locale/fi.po +++ b/plugins/PluginDownloader/locale/fi.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "POT-Creation-Date: 2012-04-29 19:20+EEST\n" -"PO-Revision-Date: 2012-04-29 20:42+0300\n" +"PO-Revision-Date: 2012-04-29 20:48+0200\n" "Last-Translator: Mika Suomalainen \n" "Language-Team: Finnish <>\n" "Language: \n" @@ -19,21 +19,15 @@ msgstr "" #: plugin.py:245 msgid "" "This plugin allows you to install unofficial plugins from\n" -" multiple repositories easily. Use the \"repolist\" command to see list " -"of\n" +" multiple repositories easily. Use the \"repolist\" command to see list of\n" " available repositories and \"repolist \" to list plugins, \n" -" which are available in that repository. When you want to install " -"plugin,\n" +" which are available in that repository. When you want to install plugin,\n" " just run command \"install \"." msgstr "" -"Tämä lisäosa sallii epävirallisten lisäosien asentamisen monista " -"ohjelmistolähteistä\n" -" helposti. Käytä \"repolist\" komentoa nähdäksesi listan saatavilla " -"olevista\n" -" ohjelmistolähteistä ja \"repolist \" saadaksesi listan " -"lisäosista,\n" -" jotka ovat saatavilla kyseisessä ohjelmistolähteessä. Kun tahdot asentaa " -"lisäosan,\n" +"Tämä lisäosa sallii epävirallisten lisäosien asentamisen monista ohjelmistolähteistä\n" +" helposti. Käytä \"repolist\" komentoa nähdäksesi listan saatavilla olevista\n" +" ohjelmistolähteistä ja \"repolist \" saadaksesi listan lisäosista,\n" +" jotka ovat saatavilla kyseisessä ohjelmistolähteessä. Kun tahdot asentaa lisäosan,\n" " suorita vain komento \"install \"." #: plugin.py:253 @@ -47,18 +41,18 @@ msgstr "" "[]\n" "\n" " Näyttää listan lisäosista, jotka löytyvät . Jos\n" -" ei ole annettu, palauttaa listan kaikista saataville " -"olevista\n" +" ei ole annettu, palauttaa listan kaikista saataville olevista\n" " ohjelmistolähteistä." -#: plugin.py:261 plugin.py:272 +#: plugin.py:261 +#: plugin.py:272 msgid ", " msgstr ", " -#: plugin.py:263 plugin.py:282 +#: plugin.py:263 +#: plugin.py:282 msgid "This repository does not exist or is not known by this bot." -msgstr "" -"Tämä ohjelmistolähde 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:270 msgid "No plugin found in this repository." From 9cba1e4d0819f959ccff0901152da100bf1948e4 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Sun, 29 Apr 2012 17:55:41 +0000 Subject: [PATCH 5/7] PluginDownloader: Add @info command. --- plugins/PluginDownloader/messages.pot | 32 ++++++++++---- plugins/PluginDownloader/plugin.py | 62 ++++++++++++++++++++++----- 2 files changed, 76 insertions(+), 18 deletions(-) diff --git a/plugins/PluginDownloader/messages.pot b/plugins/PluginDownloader/messages.pot index f76b858db..016729934 100644 --- a/plugins/PluginDownloader/messages.pot +++ b/plugins/PluginDownloader/messages.pot @@ -5,7 +5,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2012-04-29 19:20+EEST\n" +"POT-Creation-Date: 2012-04-29 17:55+UTC\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -15,7 +15,7 @@ msgstr "" "Generated-By: pygettext.py 1.5\n" -#: plugin.py:245 +#: plugin.py:260 #, docstring msgid "" "This plugin allows you to install unofficial plugins from\n" @@ -25,7 +25,7 @@ msgid "" " just run command \"install \"." msgstr "" -#: plugin.py:253 +#: plugin.py:268 #, docstring msgid "" "[]\n" @@ -35,19 +35,19 @@ msgid "" " repositories." msgstr "" -#: plugin.py:261 plugin.py:272 +#: plugin.py:276 plugin.py:287 msgid ", " msgstr "" -#: plugin.py:263 plugin.py:282 +#: plugin.py:278 plugin.py:297 plugin.py:322 msgid "This repository does not exist or is not known by this bot." msgstr "" -#: plugin.py:270 +#: plugin.py:285 msgid "No plugin found in this repository." msgstr "" -#: plugin.py:277 +#: plugin.py:292 #, docstring msgid "" " \n" @@ -55,7 +55,23 @@ msgid "" " Downloads and installs the from the ." msgstr "" -#: plugin.py:287 +#: plugin.py:302 plugin.py:327 msgid "This plugin does not exist in this repository." msgstr "" +#: plugin.py:317 +#, docstring +msgid "" +" \n" +"\n" +" Displays informations on the in the ." +msgstr "" + +#: plugin.py:331 +msgid "No README found for this plugin" +msgstr "" + +#: plugin.py:334 +msgid "This plugin has no description." +msgstr "" + diff --git a/plugins/PluginDownloader/plugin.py b/plugins/PluginDownloader/plugin.py index 546e53a23..89db121cd 100644 --- a/plugins/PluginDownloader/plugin.py +++ b/plugins/PluginDownloader/plugin.py @@ -130,19 +130,24 @@ class GithubRepository(GitRepository): # Remember we pop(0)ed the path 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): + archive = self._download(plugin) + prefix = archive.getnames()[0] + dirname = ''.join((self._path, plugin)) directories = conf.supybot.directories.plugins() directory = self._getWritableDirectoryFromList(directories) 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: assert archive.getmember(prefix + dirname).isdir() @@ -161,8 +166,18 @@ class GithubRepository(GitRepository): open(newFileName, 'a').write(extractedFile.read()) finally: archive.close() - fileObject2.close() - del archive, fileObject, fileObject2 + del archive + + 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): for directory in directories: @@ -297,6 +312,33 @@ class PluginDownloader(callbacks.Plugin): install = wrap(install, ['owner', 'something', 'something']) + @internationalizeDocstring + def info(self, irc, msg, args, repository, plugin): + """ + + Displays informations on the in the .""" + 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) Class = PluginDownloader From c310d74a19ab5179ccca75b1cd455f5d8f8bbcd4 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 1 May 2012 13:15:54 +0000 Subject: [PATCH 6/7] Enfore capability checks when supybot.reply.error.noCapability is False. --- src/callbacks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/callbacks.py b/src/callbacks.py index 37d4c1078..95ab6cc63 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -478,6 +478,7 @@ class RichReplyMethods(object): else: log.debug('Not sending capability error, ' 'supybot.reply.error.noCapability is False.') + raise Error, 'error' else: log.warning('Denying %s for some unspecified capability ' '(or a default).', self.msg.prefix) From 207f6ec2da26c83a4d5ccfef46eda770113c9858 Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Wed, 2 May 2012 15:36:34 +0000 Subject: [PATCH 7/7] Google: Fix bad json format. --- plugins/Google/plugin.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py index 9478ea10d..18adb7cfa 100644 --- a/plugins/Google/plugin.py +++ b/plugins/Google/plugin.py @@ -347,11 +347,17 @@ class Google(callbacks.PluginRegexp): urlig = self._googleUrlIG(expr) js = utils.web.getUrl(urlig) # 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) 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 url = self._googleUrl(expr)