packages: supybot/json.patch (NEW), supybot/karma-plugin.patch (NEW), supyb...
glen
glen at pld-linux.org
Wed Dec 15 12:13:33 CET 2010
Author: glen Date: Wed Dec 15 11:13:33 2010 GMT
Module: packages Tag: HEAD
---- Log message:
- new, based on fc package
---- Files affected:
packages/supybot:
json.patch (NONE -> 1.1) (NEW), karma-plugin.patch (NONE -> 1.1) (NEW), supybot.spec (NONE -> 1.1) (NEW)
---- Diffs:
================================================================
Index: packages/supybot/json.patch
diff -u /dev/null packages/supybot/json.patch:1.1
--- /dev/null Wed Dec 15 12:13:33 2010
+++ packages/supybot/json.patch Wed Dec 15 12:13:27 2010
@@ -0,0 +1,30 @@
+diff --git a/plugins/Google/plugin.py b/plugins/Google/plugin.py
+index e1b6bee..98fd7dd 100644
+--- a/plugins/Google/plugin.py
++++ b/plugins/Google/plugin.py
+@@ -42,15 +42,21 @@ import supybot.ircmsgs as ircmsgs
+ import supybot.ircutils as ircutils
+ import supybot.callbacks as callbacks
+
++simplejson = None
++
++try:
++ simplejson = utils.python.universalImport('json')
++except ImportError:
++ pass
++
+ try:
+- simplejson = utils.python.universalImport('json', 'simplejson',
+- 'local.simplejson')
+ # The 3rd party simplejson module was included in Python 2.6 and renamed to
+ # json. Unfortunately, this conflicts with the 3rd party json module.
+ # Luckily, the 3rd party json module has a different interface so we test
+ # to make sure we aren't using it.
+- if hasattr(simplejson, 'read'):
+- raise ImportError
++ if simplejson is None or hasattr(simplejson, 'read'):
++ simplejson = utils.python.universalImport('simplejson',
++ 'local.simplejson')
+ except ImportError:
+ raise callbacks.Error, \
+ 'You need Python2.6 or the simplejson module installed to use ' \
================================================================
Index: packages/supybot/karma-plugin.patch
diff -u /dev/null packages/supybot/karma-plugin.patch:1.1
--- /dev/null Wed Dec 15 12:13:33 2010
+++ packages/supybot/karma-plugin.patch Wed Dec 15 12:13:27 2010
@@ -0,0 +1,184 @@
+diff -uNr Supybot-0.83.4.1-orig/plugins/Karma/plugin.py Supybot-0.83.4.1/plugins/Karma/plugin.py
+--- Supybot-0.83.4.1-orig/plugins/Karma/plugin.py 2009-05-25 12:38:12.000000000 -0500
++++ Supybot-0.83.4.1/plugins/Karma/plugin.py 2010-06-03 12:17:20.355768834 -0500
+@@ -49,7 +49,7 @@
+
+ def _getDb(self, channel):
+ try:
+- import sqlite
++ from pysqlite2 import dbapi2
+ except ImportError:
+ raise callbacks.Error, 'You need to have PySQLite installed to ' \
+ 'use Karma. Download it at ' \
+@@ -58,9 +58,9 @@
+ if filename in self.dbs:
+ return self.dbs[filename]
+ if os.path.exists(filename):
+- self.dbs[filename] = sqlite.connect(filename)
++ self.dbs[filename] = dbapi2.connect(filename)
+ return self.dbs[filename]
+- db = sqlite.connect(filename)
++ db = dbapi2.connect(filename)
+ self.dbs[filename] = db
+ cursor = db.cursor()
+ cursor.execute("""CREATE TABLE karma (
+@@ -80,12 +80,16 @@
+ db = self._getDb(channel)
+ thing = thing.lower()
+ cursor = db.cursor()
+- cursor.execute("""SELECT added, subtracted FROM karma
+- WHERE normalized=%s""", thing)
+- if cursor.rowcount == 0:
++ sql = """SELECT added, subtracted FROM karma
++ WHERE normalized='%s'""" % thing
++ cursor.execute(sql)
++ results = cursor.fetchall()
++ print results
++ if results == []:
+ return None
+ else:
+- return map(int, cursor.fetchone())
++ return results[0]
++ #return map(int, results)
+
+ def gets(self, channel, things):
+ db = self._getDb(channel)
+@@ -93,7 +97,7 @@
+ normalizedThings = dict(zip(map(lambda s: s.lower(), things), things))
+ criteria = ' OR '.join(['normalized=%s'] * len(normalizedThings))
+ sql = """SELECT name, added-subtracted FROM karma
+- WHERE %s ORDER BY added-subtracted DESC""" % criteria
++ WHERE '%s' ORDER BY added-subtracted DESC""" % criteria
+ cursor.execute(sql, *normalizedThings)
+ L = [(name, int(karma)) for (name, karma) in cursor.fetchall()]
+ for (name, _) in L:
+@@ -106,53 +110,49 @@
+ db = self._getDb(channel)
+ cursor = db.cursor()
+ cursor.execute("""SELECT name, added-subtracted FROM karma
+- ORDER BY added-subtracted DESC LIMIT %s""", limit)
++ ORDER BY added-subtracted DESC LIMIT '%s'""" % limit)
+ return [(t[0], int(t[1])) for t in cursor.fetchall()]
+
+ def bottom(self, channel, limit):
+ db = self._getDb(channel)
+ cursor = db.cursor()
+ cursor.execute("""SELECT name, added-subtracted FROM karma
+- ORDER BY added-subtracted ASC LIMIT %s""", limit)
++ ORDER BY added-subtracted ASC LIMIT '%s'""" % limit)
+ return [(t[0], int(t[1])) for t in cursor.fetchall()]
+
+ def rank(self, channel, thing):
+ db = self._getDb(channel)
+ cursor = db.cursor()
+ cursor.execute("""SELECT added-subtracted FROM karma
+- WHERE name=%s""", thing)
+- if cursor.rowcount == 0:
++ WHERE name='%s'""" % thing)
++ if cursor.rowcount <= 0:
+ return None
+- karma = int(cursor.fetchone()[0])
++ karma = int(cursor.fetchall()[0])
+ cursor.execute("""SELECT COUNT(*) FROM karma
+- WHERE added-subtracted > %s""", karma)
+- rank = int(cursor.fetchone()[0])
++ WHERE added-subtracted > '%s'""" % karma)
++ rank = int(cursor.fetchall()[0])
+ return rank+1
+
+ def size(self, channel):
+ db = self._getDb(channel)
+ cursor = db.cursor()
+ cursor.execute("""SELECT COUNT(*) FROM karma""")
+- return int(cursor.fetchone()[0])
++ return int(cursor.fetchall()[0])
+
+ def increment(self, channel, name):
+ db = self._getDb(channel)
+ cursor = db.cursor()
+ normalized = name.lower()
+- cursor.execute("""INSERT INTO karma VALUES (NULL, %s, %s, 0, 0)""",
+- name, normalized)
+- cursor.execute("""UPDATE karma SET added=added+1
+- WHERE normalized=%s""", normalized)
++ cursor.execute("""INSERT INTO karma VALUES (NULL, '%s', '%s', 0, 0)""" % (name, normalized))
++ cursor.execute("""UPDATE karma SET added=added+1 WHERE normalized='%s'""" % normalized)
+ db.commit()
+
+ def decrement(self, channel, name):
+ db = self._getDb(channel)
+ cursor = db.cursor()
+ normalized = name.lower()
+- cursor.execute("""INSERT INTO karma VALUES (NULL, %s, %s, 0, 0)""",
+- name, normalized)
+- cursor.execute("""UPDATE karma SET subtracted=subtracted+1
+- WHERE normalized=%s""", normalized)
++ cursor.execute("""INSERT INTO karma VALUES (NULL, '%s', '%s', 0, 0)""" % (name, normalized))
++ cursor.execute("""UPDATE karma SET subtracted=subtracted+1 WHERE normalized='%s'""" % normalized)
+ db.commit()
+
+ def most(self, channel, kind, limit):
+@@ -164,7 +164,7 @@
+ orderby = 'added+subtracted'
+ else:
+ raise ValueError, 'invalid kind'
+- sql = """SELECT name, %s FROM karma ORDER BY %s DESC LIMIT %s""" % \
++ sql = """SELECT name, '%s' FROM karma ORDER BY '%s' DESC LIMIT '%s'""" % \
+ (orderby, orderby, limit)
+ db = self._getDb(channel)
+ cursor = db.cursor()
+@@ -176,7 +176,7 @@
+ cursor = db.cursor()
+ normalized = name.lower()
+ cursor.execute("""UPDATE karma SET subtracted=0, added=0
+- WHERE normalized=%s""", normalized)
++ WHERE normalized='%s'""" % normalized)
+ db.commit()
+
+ def dump(self, channel, filename):
+@@ -200,13 +200,13 @@
+ for (name, added, subtracted) in reader:
+ normalized = name.lower()
+ cursor.execute("""INSERT INTO karma
+- VALUES (NULL, %s, %s, %s, %s)""",
+- name, normalized, added, subtracted)
++ VALUES (NULL, '%s', '%s', '%s', '%s')""" %
++ (name, normalized, added, subtracted))
+ db.commit()
+ fd.close()
+
+ KarmaDB = plugins.DB('Karma',
+- {'sqlite': SqliteKarmaDB})
++ {'pysqlite2': SqliteKarmaDB})
+
+ class Karma(callbacks.Plugin):
+ callBefore = ('Factoids', 'MoobotFactoids', 'Infobot')
+@@ -249,6 +249,10 @@
+ elif thing:
+ self.db.decrement(channel, self._normalizeThing(thing))
+ self._respond(irc, channel)
++ t = self.db.get(channel, thing)
++ (added, subtracted) = t
++ total = added - subtracted
++ irc.reply('Karma for %s (%s)' % (thing, total))
+
+ def invalidCommand(self, irc, msg, tokens):
+ channel = msg.args[0]
+diff -uNr Supybot-0.83.4.1-orig/plugins/Karma/test.py Supybot-0.83.4.1/plugins/Karma/test.py
+--- Supybot-0.83.4.1-orig/plugins/Karma/test.py 2009-05-25 12:38:12.000000000 -0500
++++ Supybot-0.83.4.1/plugins/Karma/test.py 2010-06-03 12:12:41.090762813 -0500
+@@ -30,11 +30,11 @@
+ from supybot.test import *
+
+ try:
+- import sqlite
++ import pysqlite2
+ except ImportError:
+- sqlite = None
++ pysqlite2 = None
+
+-if sqlite is not None:
++if pysqlite2 is not None:
+ class KarmaTestCase(ChannelPluginTestCase):
+ plugins = ('Karma',)
+ def testKarma(self):
================================================================
Index: packages/supybot/supybot.spec
diff -u /dev/null packages/supybot/supybot.spec:1.1
--- /dev/null Wed Dec 15 12:13:33 2010
+++ packages/supybot/supybot.spec Wed Dec 15 12:13:27 2010
@@ -0,0 +1,107 @@
+# $Revision$, $Date$
+%define origname Supybot
+Summary: Cross-platform IRC bot written in Python
+Name: supybot
+Version: 0.83.4.1
+Release: 1
+Group: Applications/Networking
+# The entire source code is BSD except for
+# Supybot-0.83.4/plugins/Math/local/convertcore.py which is GPL v2
+License: BSD and GPL v2
+URL: http://supybot.com
+Source0: http://downloads.sourceforge.net/supybot/%{origname}-%{version}.tar.bz2
+# Fix a conflict between python-json and the built in json module
+# in Python 2.6. Already submitted and commited upstream.
+Patch0: json.patch
+#fix karma plugin to actually work should go upstream
+Patch1: karma-plugin.patch
+BuildRequires: python-distribute
+Requires: python-dateutil
+Requires: python-dictclient
+Requires: python-feedparser
+Requires: python-simplejson
+Requires: python-twisted-core
+Requires: python-twisted-names
+Obsoletes: Supybot
+BuildArch: noarch
+BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
+
+%description
+Supybot is a robust, user-friendly, and programmer-friendly Python IRC
+bot. It aims to be an adequate replacement for most existing IRC bots.
+It includes a very flexible and powerful ACL system for controlling
+access to commands, as well as more than 50 builtin plugins providing
+around 400 actual commands.
+
+%prep
+%setup -q -n %{origname}-%{version}
+%patch0 -p1
+%patch1 -p1
+
+%build
+#CFLAGS="%{optflags}" %{__python} -c 'import setuptools; execfile("setup.py")' build
+CC="%{__cc}" \
+CFLAGS="%{rpmcflags}" \
+%{__python} setup.py build
+
+%install
+rm -rf $RPM_BUILD_ROOT
+%{__python} setup.py install \
+ --skip-build \
+ --optimize=2 \
+ --root=$RPM_BUILD_ROOT
+
+install -d $RPM_BUILD_ROOT%{_mandir}/man1
+cp -a docs/man/supybot.1 $RPM_BUILD_ROOT%{_mandir}/man1
+cp -a docs/man/supybot-adduser.1 $RPM_BUILD_ROOT%{_mandir}/man1
+cp -a docs/man/supybot-botchk.1 $RPM_BUILD_ROOT%{_mandir}/man1
+cp -a docs/man/supybot-plugin-create.1 $RPM_BUILD_ROOT%{_mandir}/man1
+cp -a docs/man/supybot-plugin-doc.1 $RPM_BUILD_ROOT%{_mandir}/man1
+cp -a docs/man/supybot-test.1 $RPM_BUILD_ROOT%{_mandir}/man1
+cp -a docs/man/supybot-wizard.1 $RPM_BUILD_ROOT%{_mandir}/man1
+
+# These are provided in python-feedparser, python-dateutil,
+# python-dictclient, and python-simplejson
+rm -rf $RPM_BUILD_ROOT%{py_sitescriptdir}/supybot/plugins/RSS/local
+rm -rf $RPM_BUILD_ROOT%{py_sitescriptdir}/supybot/plugins/Time/local
+rm -rf $RPM_BUILD_ROOT%{py_sitescriptdir}/supybot/plugins/Dict/local
+rm -rf $RPM_BUILD_ROOT%{py_sitescriptdir}/supybot/plugins/Google/local
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+
+%files
+%defattr(644,root,root,755)
+%doc ACKS ChangeLog LICENSE README RELNOTES
+%doc docs/{ADVANCED_PLUGIN_CONFIG,ADVANCED_PLUGIN_TESTING,CAPABILITIES}
+%doc docs/{CONFIGURATION,FAQ,GETTING_STARTED,PLUGIN_TUTORIAL,STYLE}
+%doc docs/{USING_UTILS,USING_WRAP}
+%attr(755,root,root) %{_bindir}/supybot
+%attr(755,root,root) %{_bindir}/supybot-adduser
+%attr(755,root,root) %{_bindir}/supybot-botchk
+%attr(755,root,root) %{_bindir}/supybot-plugin-create
+%attr(755,root,root) %{_bindir}/supybot-plugin-doc
+%attr(755,root,root) %{_bindir}/supybot-plugin-package
+%attr(755,root,root) %{_bindir}/supybot-test
+%attr(755,root,root) %{_bindir}/supybot-wizard
+%{py_sitescriptdir}/supybot
+%if "%{py_ver}" > "2.4"
+%{py_sitescriptdir}/supybot-*.egg-info
+%endif
+%{_mandir}/man1/supybot.1*
+%{_mandir}/man1/supybot-adduser.1*
+%{_mandir}/man1/supybot-botchk.1*
+%{_mandir}/man1/supybot-plugin-create.1*
+%{_mandir}/man1/supybot-plugin-doc.1*
+%{_mandir}/man1/supybot-test.1*
+%{_mandir}/man1/supybot-wizard.1*
+
+%define date %(echo `LC_ALL="C" date +"%a %b %d %Y"`)
+%changelog
+* %{date} PLD Team <feedback at pld-linux.org>
+All persons listed below can be reached at <cvs_login>@pld-linux.org
+
+$Log$
+Revision 1.1 2010/12/15 11:13:27 glen
+- new, based on fc package
================================================================
More information about the pld-cvs-commit
mailing list