From 1b1e1d178713416730d9b2315f77d67a726977f0 Mon Sep 17 00:00:00 2001 From: Dennis Kaarsemaker Date: Thu, 13 Jul 2006 22:21:54 +0200 Subject: [PATCH] * Don't display 'in xxx minutes' for current meeting * Support buntudot * Support multiple databases in the web interface * Show architecture for package info if not all/any --- Encyclopedia/factoids.cgi | 16 +++++++++------- Encyclopedia/factoids.tmpl | 8 +++++++- Encyclopedia/plugin.py | 26 ++++++++++++++++++++++---- Webcal/plugin.py | 8 ++++---- index.html | 3 ++- 5 files changed, 44 insertions(+), 17 deletions(-) diff --git a/Encyclopedia/factoids.cgi b/Encyclopedia/factoids.cgi index 64af980..7aad3e6 100755 --- a/Encyclopedia/factoids.cgi +++ b/Encyclopedia/factoids.cgi @@ -30,6 +30,8 @@ def q(txt): database = 'ubuntu' form = cgi.FieldStorage() +if 'db' in form: + database = form['db'].value try: page = int(form['page'].value) except: @@ -50,14 +52,14 @@ num = cur.fetchall()[0][0] npages = int(ceil(num / float(NUM_PER_PAGE))) out('·') for i in range(npages): - out(' %d ·' % (order_by, i, i+1)) + out(' %d ·' % (database, order_by, i, i+1)) out('
Order by
·') -out(' %s ·' % ('name ASC', page, 'Name +')) -out(' %s ·' % ('name DESC', page, 'Name -')) -out(' %s ·' % ('popularity ASC', page, 'Popularity +')) -out(' %s ·' % ('popularity DESC', page, 'Popularity -')) -out(' %s ·' % ('added ASC', page, 'Date added +')) -out(' %s ·' % ('added DESC', page, 'Date added -')) +out(' %s ·' % (database, 'name ASC', page, 'Name +')) +out(' %s ·' % (database, 'name DESC', page, 'Name -')) +out(' %s ·' % (database, 'popularity ASC', page, 'Popularity +')) +out(' %s ·' % (database, 'popularity DESC', page, 'Popularity -')) +out(' %s ·' % (database, 'added ASC', page, 'Date added +')) +out(' %s ·' % (database, 'added DESC', page, 'Date added -')) out('') diff --git a/Encyclopedia/factoids.tmpl b/Encyclopedia/factoids.tmpl index 1ed5c9d..0a91aef 100644 --- a/Encyclopedia/factoids.tmpl +++ b/Encyclopedia/factoids.tmpl @@ -124,10 +124,16 @@ div.log {

Ubotu factoids

+More help: wiki.ubuntu.com · +help.ubuntu.com
+More factoids: Ubuntu · +buntudot +

%s

-Factoid database file
+Ubuntu factoid database file
+Buntudot factoid database file
©2006 Dennis Kaarsemaker

diff --git a/Encyclopedia/plugin.py b/Encyclopedia/plugin.py index f3bf850..ecc235c 100644 --- a/Encyclopedia/plugin.py +++ b/Encyclopedia/plugin.py @@ -26,6 +26,8 @@ datadir = '/home/dennis/ubugtu/data/facts' def r(repo,section): if 'seveas' in repo: return 'Seveas' + if 'buntudot' in repo: + return 'buntudot' if '/' in section: return section[:section.find('/')] return 'main' @@ -114,6 +116,7 @@ class Encyclopedia(callbacks.PluginRegexp): db,channel = fallback if channel not in self.databases: self.databases[channel] = sqlite.connect(os.path.join(datadir, '%s.db' % db)) + self.databases[channel].name = db return self.databases[channel] def searchfactoid(self, irc, msg, match): @@ -183,7 +186,7 @@ class Encyclopedia(callbacks.PluginRegexp): try: factoid = get_factoid(db, factoid, channel) if not factoid: - irc.reply('I know nothing about %s - try searching bots.ubuntulinux.nl, help.ubuntu.com and wiki.ubuntu.com' % match.group('factoid')) + irc.reply('I know nothing about %s - try searching http://bots.ubuntulinux.nl/factoids.cgi?db=%s' % (match.group('factoid'),db.name)) return # Output factoid if noalias: @@ -401,9 +404,10 @@ class Encyclopedia(callbacks.PluginRegexp): if not self._precheck(irc, msg, timeout=(msg.args[0],match.group('package'), match.group('distro'))): return distro = 'dapper' - if (match.group('distro') in ('warty','hoary','breezy','dapper','edgy','breezy-seveas','dapper-seveas')): + if (match.group('distro') in ('warty','hoary','breezy','dapper','edgy','breezy-seveas','dapper-seveas','dapper-buntudot')): distro = match.group('distro') data = commands.getoutput(self.aptcommand % (distro, distro, distro, 'show', match.group('package'))) + data2 = commands.getoutput(self.aptcommand % (distro, distro, distro, 'showsrc', match.group('package'))) if not data or 'E: No packages found' in data: irc.reply('Package %s does not exist in %s' % (match.group('package'), distro)) else: @@ -418,9 +422,23 @@ class Encyclopedia(callbacks.PluginRegexp): if apt_pkg.VersionCompare(maxp['Version'], p['Version']) < 0: maxp = p del parser - irc.reply("%s: %s. In repository %s, is %s. Version %s (%s), package size %s kB, installed size %s kB" % + maxp2 = {'Version': '0'} + packages2 = [x.strip() for x in data2.split('\n\n')] + for p in packages2: + if not p.strip(): + continue + parser = FeedParser.FeedParser() + parser.feed(p) + p = parser.close() + if apt_pkg.VersionCompare(maxp2['Version'], p['Version']) < 0: + maxp2 = p + del parser + archs = '' + if maxp2['Architecture'] not in ('all','any'): + archs = ' (Only available for %s)' % maxp2['Architecture'] + irc.reply("%s: %s. In repository %s, is %s. Version %s (%s), package size %s kB, installed size %s kB%s" % (maxp['Package'], maxp['Description'].split('\n')[0], r(distro, maxp['Section']), - maxp['Priority'], maxp['Version'], distro, int(maxp['Size'])/1024, maxp['Installed-Size'])) + maxp['Priority'], maxp['Version'], distro, int(maxp['Size'])/1024, maxp['Installed-Size'], archs)) def find(self, irc, msg, match): r"^!?find\s+(?P\S+)(\s+(?P\S+))?" diff --git a/Webcal/plugin.py b/Webcal/plugin.py index 12a2ad1..4c611c4 100644 --- a/Webcal/plugin.py +++ b/Webcal/plugin.py @@ -41,10 +41,10 @@ def diff(delta): if delta.seconds > 3600: h = '%d hour%s ' % (int(delta.seconds/3600),s) s = '' - seconds = delta.seconds % 3600 - if seconds > 120 or seconds < 60: + minutes = (delta.seconds % 3600) / 60 + if minutes != 1: s = 's' - return '%s%d minute%s' % (h,(seconds/60),s) + return '%s%d minute%s' % (h,minutes,s) class Webcal(callbacks.Plugin): """@schedule : display the schedule in your timezone""" @@ -89,7 +89,7 @@ class Webcal(callbacks.Plugin): if ev0.startDate < now or (delta.days == 0 and delta.seconds < 10 * 60): preamble = 'Current meeting: %s' % ev0.summary.replace('Meeting','').strip() if num_events == 1: - return '%s in %s' % (preamble, diff(delta)) + return preamble events = events[1:] preamble += ' | ' # n_e = 1 -> next meeting diff --git a/index.html b/index.html index 44da374..9d622b0 100644 --- a/index.html +++ b/index.html @@ -15,7 +15,8 @@

Plugins

The plugins used by these bots can be found in the bzr branch located at - http://bots.ubuntulinux.nl + https://bots.ubuntulinux.nl - Tarballs of the plugins can be found in the tarballs folder

Bugs and feature requests can be filed at

FactoidValueAuthor