debian/0000755000000000000000000000000011754613161007173 5ustar debian/changelog0000644000000000000000000000717511754612537011065 0ustar ibid (0.1.1+dfsg-4) unstable; urgency=low * Actually change the Depends to jinja2 * Bump standards version to 3.9.3, no changes needed. * Update machine readable copyright file to format 1.0. -- Stefano Rivera Tue, 15 May 2012 19:46:20 -0700 ibid (0.1.1+dfsg-3) unstable; urgency=low * Document bundled extlinks.py in copyright. * Correct DEP3 headers (first line of Description is the subject) * Use dh_sphinxdoc. - Bump python-sphinx Build-Depends. - Don't link jquery.js to libjs-jquery. * Don't compress Sphinx _sources. * Use Jinja2 instead of Jinja. (Closes: #634910) * Drop Suggests on python-silc, to allow silc-toolkit to be removed from Debian. (Closes: #629221) * sqlalchemy-0.7.diff: Update SQLAlchemy 0.6 patch for 0.7 support. (Closes: #634913) * pyfiglet-0.6.diff: Support pyfiglet 0.6 (only). * Bump Standards-Version to 3.9.2 (no changes needed). * Drop ${python:Breaks}, no longer used. -- Stefano Rivera Fri, 19 Aug 2011 12:02:28 +0200 ibid (0.1.1+dfsg-2) unstable; urgency=low * Team upload. * Rebuild to add Python 2.7 support -- Piotr Ożarowski Sun, 08 May 2011 16:46:00 +0200 ibid (0.1.1+dfsg-1) unstable; urgency=low * New upstream bug-fix release. - Built documentation is included, removed in get-orig-source. * Update my e-mail address. * Update debian/copyright format. youtube-dl is now public domain. * Move mysqldb | psycopg2 to suggests, Ibid will use the stdlib sqlite3 by default. * Refresh patches. -- Stefano Rivera Thu, 24 Feb 2011 01:21:35 +0200 ibid (0.1.0+dfsg-3) experimental; urgency=low [ Jakub Wilk ] * Set maintainer to Python Applications Packaging Team. [ Stefano Rivera ] * Don't compress objects.inv. Thanks to Michael Fladischer for the report. (Closes: #608753) * Switch from pycentral to dh_python2. - Use X-Python-Version, and ${python:Breaks}. - Drop XB-Python-Version. - Version python-all Build-Depends to >= 2.6.5-13~. * Install data with dh_install instead of for loop in debian/rules. * Don't install ibid.static module, it's shipped in /usr/share/ibid. * Reorganise docs: Install rst as Sphinx _sources, so searching works. - Build docs in build/docs * Use twisted-plugins-cache trigger, drop postinst and postrm. - Version python-twisted-core dependency to >= 10.0.0-3~. * debian/control: - Wrap and sort multi-line fields. - Bump Standards-Version to 3.9.1 (no changes needed). * debian/copyright: Bump year. -- Stefano Rivera Fri, 07 Jan 2011 23:01:06 +0200 ibid (0.1.0+dfsg-2) unstable; urgency=low * Don't leak uid and umask into source tarball. * Suggest nmap. * Apply sqlalchemy-0.6-support.patch, allowing Debian to transition to SQLAlchemy 0.6 (Closes: #584761) -- Stefano Rivera Thu, 17 Jun 2010 19:23:29 +0200 ibid (0.1.0+dfsg-1) unstable; urgency=low * Initial upstream release. * Patches: - Update separate-data patch. Upstream incorporated fixes to make this patch much simpler and less invasive. - Add fortune-path.diff: Change fortune's default location to be absolute path /usr/games/fortune. * debian/rules: - Run test suite with all python interpreters. - Respect nocheck in DEB_BUILD_OPTIONS. * debian/control: - Unversion dependency on python-imdbpy. -- Stefano Rivera Wed, 10 Mar 2010 20:32:28 +0200 ibid (0+bzr881+dfsg-1) experimental; urgency=low * Initial release (Closes: #565885) -- Stefano Rivera Sun, 07 Feb 2010 00:10:35 +0200 debian/rules0000755000000000000000000000353711621157460010261 0ustar #!/usr/bin/make -f PKGDIR=$(CURDIR)/debian/ibid %: dh $@ --with python2,sphinxdoc TRIAL=$(shell which trial) override_dh_auto_test: ifeq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS))) set -e; \ for ver in $(shell pyversions -vr); do \ PYTHONPATH=. python$$ver $(TRIAL) --reporter=text ibid; \ done endif override_dh_auto_build: dh_auto_build # Old sphinx-builds (lenny) are picky mkdir -p docs/html docs/_static sphinx-build -N -bhtml docs/ build/docs override_dh_auto_install: dh_auto_install rm -rf $(PKGDIR)/usr/lib/python*/*-packages/ibid/test rm -rf $(PKGDIR)/usr/lib/python*/*-packages/*.egg-info/requires.txt override_dh_auto_clean: dh_auto_clean rm -rf build rm -rf *.egg-info rm -rf _trial_temp find . -name dropin.cache -delete override_dh_installdocs: dh_installdocs cd $(PKGDIR)/usr/share/doc/ibid && mv docs html override_dh_installexamples: dh_installexamples cd $(PKGDIR)/usr/share/doc/ibid/examples/factpacks && rm -f *.py *.sh override_dh_compress: dh_compress -X.inv -X.txt override_dh_python2: dh_python2 --no-guessing-deps REV=$(shell dpkg-parsechangelog | sed -rne 's,^Version: .*bzr([0-9]+).*,\1,p') VER=$(shell dpkg-parsechangelog | sed -rne 's,^Version: (.+)\+dfsg.*,\1,p') BZR_REPO?=lp:ibid BZR_DOCS_REPO?=lp:~ibid-dev/ibid/docs get-orig-source: ifeq ($(REV),) uscan --noconf --force-download --rename --download-version=$(VER) --destdir=. tar -xf ibid_$(VER).orig.tar.gz mv Ibid-$(VER) ibid-$(VER) rm -f ibid_$(VER).orig.tar.gz else bzr export -r $(REV) ibid-$(VER) $(BZR_REPO) rm -rf ibid-$(VER)/docs bzr export ibid-$(VER)/docs $(BZR_DOCS_REPO)/docs endif cd ibid-$(VER)/factpacks/ && rm -f handey.json overlord.json wrestling.json zippy.json rm -rf ibid-$(VER)/docs/html GZIP=--best tar -cz --owner root --group root --mode a+rX \ -f ibid_$(VER)+dfsg.orig.tar.gz ibid-$(VER) rm -rf ibid-$(VER) debian/README.Debian0000644000000000000000000000064611523215670011237 0ustar Ibid for Debian --------------- To install an Ibid on Debian follow the "Package Managed Installation" section of docs/install.rst or docs/html/install.html. You can obviously skip the bits about adding alternate APT repositories. This package doesn't (yet) support automatic running of bots at system start-up. You'll need to do that yourself. -- Stefano Rivera Sat, 23 Jan 2010 11:17:24 +0200 debian/watch0000644000000000000000000000016211345540130010212 0ustar version=3 opts=dversionmangle=s/\+dfsg// \ https://launchpad.net/ibid/+download \ https?://.*/Ibid-(.*)\.tar\.gz debian/doc-base0000644000000000000000000000040511510440320010553 0ustar Document: ibid Title: Ibid Bot Documentation Author: The Ibid Developers Abstract: Ibid is a multi-protocol chat bot, wrtitten in Python Section: Programming/Python Format: HTML Index: /usr/share/doc/ibid/html/index.html Files: /usr/share/doc/ibid/html/*.html debian/install0000644000000000000000000000033011510427312010547 0ustar ibid/config.ini /usr/share/ibid ibid/configspec.ini /usr/share/ibid ibid/data /usr/share/ibid ibid/logging.ini /usr/share/ibid ibid/static /usr/share/ibid ibid/templates /usr/share/ibid debian/compat0000644000000000000000000000000211325420467010370 0ustar 7 debian/source/0000755000000000000000000000000011754612562010477 5ustar debian/source/format0000644000000000000000000000001411325420467011700 0ustar 3.0 (quilt) debian/copyright0000644000000000000000000001526411754612462011141 0ustar Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: Ibid Upstream-Contact: The Ibid Developers Source: https://launchpad.net/ibid/+download License: GPL-3+ Comment: Some of the factpacks included in the upstream tarball contain quotes that aren't licensed for redistribution. The following factpacks have been removed from the Debian version of this package: handey.json: Jack Handey quotes overlord.json: Overlord list wrestling.json: Wrestling move list zippy.json: Zippy the Pinhead quotes The built HTML docmentation has also been removed. Files: * Copyright: 2008-2011, Jonathan Hitchcock, Michael Gorven, Stefano Rivera and other contributors. License: Expat or GPL-3+ Files: debian/* Copyright: 2008-2011, Michael Gorven, Stefano Rivera License: Expat Files: ibid/factpacks/divine.json Copyright: 1996-2000, Sarah Burcham, Kevin Lenzo 2003-2010, Jonathan Hitchcock 2008-2010, Stefano Rivera License: Perl Derived from knab. Derived from infobot. Covered by the same terms as Perl itself (the Artistic License), which can be found in /usr/share/common-licenses/Artistic. This software is meant to be freely available under those terms in perpetuity. Files: ibid/factpacks/rubaiyat.json ibid/factpacks/tao.json Copyright: 2003-2010, Jonathan Hitchcock Comment: Derived from knab. Derived from works in the Public Domain (expired copyright). License: Expat Files: ibid/factpacks/zen.json Copyright: 2008-2010, Michael Gorven Comment: Generated from a document placed in the public domain. License: Expat Files: ibid/lib/nickometer.py Copyright: 2004, William Robinson. Derived from work Copyright 1998, Adam Spiers. License: 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. Files: ibid/plugins/urlinfo.py Copyright: 2009-2010, Michael Gorven, Stefano Rivera Derived from work Copyright 2006-2008, Ricardo Garcia Gonzalez Comment: The youtube Processor uses code from youtube-dl, released into the public domain, as stated by the author: It is released to the public domain, which means you can modify it, redistribute it or use it however you like. License: Expat Files: docs/_extensions/extlinks.py Copyright: 2009-2011, Georg Brandl License: 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. * The names of the contributors may not be used to endorse or promote products derived from this software without specific prior written permission. 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. License: Expat Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: . The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. . THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. License: GPL-3+ This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. . On Debian systems, the complete text of the GNU General Public License version 3 can be found in the /usr/share/common-licenses/GPL-3 file. debian/control0000644000000000000000000000440711754612424010604 0ustar Source: ibid Section: net Priority: optional Maintainer: Python Applications Packaging Team Uploaders: Stefano Rivera Build-Depends: debhelper (>= 7.0.50~), python-all (>= 2.6.5-13~), python-beautifulsoup, python-configobj (>= 4.7), python-dateutil, python-html5lib, python-jinja2, python-pkg-resources, python-setuptools, python-simplejson, python-soappy, python-sphinx (>= 1.0.7+dfsg), python-sqlalchemy (>= 0.5), python-twisted-core, python-twisted-web Standards-Version: 3.9.3 Homepage: http://ibid.omnia.za.net/ Vcs-Svn: svn://svn.debian.org/python-apps/packages/ibid/trunk/ Vcs-Browser: http://svn.debian.org/viewsvn/python-apps/packages/ibid/trunk/ X-Python-Version: >= 2.5 Package: ibid Architecture: all Depends: python (>= 2.6) | python-simplejson, python-beautifulsoup, python-chardet, python-configobj (>= 4.7), python-dateutil, python-html5lib, python-jinja2, python-pkg-resources, python-soappy, python-sqlalchemy (>= 0.5), python-twisted-core (>= 10.0.0-3~), python-twisted-web, python-twisted-words, python-zope.interface | python-zopeinterface, ${misc:Depends}, ${python:Depends}, ${sphinxdoc:Depends} Recommends: fortune, ipcalc, iputils-ping, iputils-tracepath, man-db, python-dictclient, python-dnspython, python-feedparser, python-html2text, python-imdbpy, python-twisted-mail, python-wokkel (>= 0.6.3), units Suggests: apt-file, aptitude, bc, bzr, caca-utils, dictd, nmap, python-aalib, python-dbus, python-imaging, python-matplotlib, python-mysqldb | python-psycopg2, python-numpy, python-objgraph, python-pyfiglet (>= 0.6), python-svn Description: easily extensible Python IM bot for IRC, Jabber, SILC, campfire, etc. Ibid is a multi-protocol, general purpose, instant messaging chat bot written in Python. It aims for a naturalistic interface rather than strict-syntax commands. . Ibid understands many protocols, including IRC, Jabber/XMPP/Google Talk, Campfire, NMDC and SILC. It also interacts over SMTP, HTTP and various RPC protocols. . Ibid aims to make plugins as easy as possible to write. It ships with a large collection of plugins for looking up information, performing conversions, storing factoids, delivering messages, and much more. debian/manpages0000644000000000000000000000000611331044062010672 0ustar man/* debian/triggers0000644000000000000000000000003711510441322010730 0ustar activate twisted-plugins-cache debian/patches/0000755000000000000000000000000011754612562010626 5ustar debian/patches/tac-not-needed.diff0000644000000000000000000000057111523215670014243 0ustar Description: tac file isn't needed, as we install a twisted plugin. Author: Stefano Rivera Forwarded: not-needed Last-Update: 2011-02-05 --- a/setup.py +++ b/setup.py @@ -67,7 +67,6 @@ 'scripts/ibid-pb-client', 'scripts/ibid-plugin', 'scripts/ibid-setup', - 'scripts/ibid.tac', ], include_package_data=True, debian/patches/series0000644000000000000000000000016511622002071012023 0ustar sqlalchemy-0.7.diff jinja2.diff pyfiglet-0.6.diff tac-not-needed.diff docs.diff separate-data.diff fortune-path.diff debian/patches/sqlalchemy-0.7.diff0000644000000000000000000006605211623434114014123 0ustar Description: SQLAlchemy 0.7 support (beta) Ibid 0.1.x only supports SQLAlchemy 0.4 an 0.5, but Debian now ships 0.7. This is a backport of the in-progress upstream patch, bumping supported versions to 0.6 and 0.7 Origin: https://code.launchpad.net/~stefanor/ibid/sqlalchemy-0.6-trunk Bug-Debian: http://bugs.debian.org/634913 Last-Update: 2011-08-19 --- a/docs/install.rst +++ b/docs/install.rst @@ -50,7 +50,7 @@ * `Twisted framework `_ (core sources) * Twisted Words (IRC, XMPP) * `Wokkel `_. (XMPP) -* `SQLAlchemy `_ 0.5 preferred, 0.4 compatible. +* `SQLAlchemy `_ 0.6 or later. * `ConfigObj `_ >= 4.7.0 * `python-dateutil `_ * `SOAPpy `_ [#soappy-install]_ --- a/ibid/core.py +++ b/ibid/core.py @@ -12,7 +12,7 @@ from twisted.python.modules import getModule from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker, scoped_session -from sqlalchemy.exceptions import IntegrityError +from sqlalchemy.exc import IntegrityError import ibid from ibid.event import Event @@ -332,28 +332,35 @@ else: if uri.startswith(u'mysql://'): if u'?' not in uri: - uri += u'?charset=utf8' - else: - params = parse_qs(uri.split(u'?', 1)[1]) - if u'charset' not in params: - uri += u'&charset=utf8' + uri += u'?' + params = parse_qs(uri.split(u'?', 1)[1]) + if u'charset' not in params: + uri += u'&charset=utf8' + if u'sql_mode' not in params: + uri += u'&sql_mode=ANSI_QUOTES' + # As recommended by SQLAlchemy due to a memory leak: + # http://www.sqlalchemy.org/trac/wiki/DatabaseNotes + if u'use_unicode' not in params: + uri += u'&use_unicode=0' engine = create_engine(uri, encoding='utf-8', - convert_unicode=True, assert_unicode=True, echo=echo) + convert_unicode=True, assert_unicode=True, echo=echo, + # For PostgreSQL to ensure decoded unicode values are returned: + use_native_unicode=False, + # For MySQL which closes 8hr old connections: + pool_recycle=3600) if uri.startswith('mysql://'): class MySQLModeListener(object): def connect(self, dbapi_con, con_record): - dbapi_con.set_sql_mode("ANSI") mysql_engine = ibid.config.get('mysql_engine', 'InnoDB') c = dbapi_con.cursor() - c.execute("SET storage_engine=%s;" % mysql_engine) - c.execute("SET time_zone='+0:00';") + c.execute("SET SESSION storage_engine=%s;" + % mysql_engine) + c.execute("SET SESSION time_zone='+0:00';") c.close() engine.pool.add_listener(MySQLModeListener()) - engine.dialect.use_ansiquotes = True - elif uri.startswith('postgres://'): class PGSQLModeListener(object): def connect(self, dbapi_con, con_record): --- a/ibid/db/__init__.py +++ b/ibid/db/__init__.py @@ -2,7 +2,7 @@ # Released under terms of the MIT/X/Expat Licence. See COPYING for details. import warnings as _warnings -from ibid.db.types import TypeDecorator, Integer, DateTime, Boolean, \ +from ibid.db.types import Integer, DateTime, Boolean, \ IbidUnicode, IbidUnicodeText from sqlalchemy import Table, Column, ForeignKey, Index, UniqueConstraint, \ @@ -11,7 +11,7 @@ from sqlalchemy.sql import func from sqlalchemy.ext.declarative import declarative_base as _declarative_base -from sqlalchemy.exceptions import IntegrityError, SADeprecationWarning +from sqlalchemy.exc import IntegrityError, SADeprecationWarning metadata = _MetaData() Base = _declarative_base(metadata=metadata) @@ -19,9 +19,6 @@ from ibid.db.versioned_schema import VersionedSchema, SchemaVersionException, \ schema_version_check, upgrade_schemas -# We use SQLAlchemy 0.4 compatible .save_or_update() functions -_warnings.filterwarnings('ignore', 'Use session.add\(\)', SADeprecationWarning) - def get_regexp_op(session): "Return a regexp operator" if session.bind.engine.name in ('postgres', 'postgresql'): --- a/ibid/db/types.py +++ b/ibid/db/types.py @@ -1,65 +1,77 @@ -# Copyright (c) 2009-2010, Stefano Rivera +# Copyright (c) 2009-2011, Stefano Rivera # Released under terms of the MIT/X/Expat Licence. See COPYING for details. -from sqlalchemy.types import TypeDecorator, Integer, DateTime, Boolean, \ +from sqlalchemy.types import Integer, DateTime, Boolean, \ Unicode as _Unicode, UnicodeText as _UnicodeText -class _CIDecorator(TypeDecorator): - "Abstract class for collation aware columns" - def __init__(self, length=None, case_insensitive=False): - self.case_insensitive = case_insensitive - super(_CIDecorator, self).__init__(length=length) +def monkey_patch(): + import sqlalchemy.dialects.postgresql + sqlalchemy.dialects.postgresql.dialect.ischema_names['citext'] = IbidUnicodeText + def postgres_visit_IBID_VARCHAR(self, type_): + if type_.case_insensitive: + return 'CITEXT' + else: + return self.visit_VARCHAR(type_) + sqlalchemy.dialects.postgresql.dialect.type_compiler.visit_IBID_VARCHAR = postgres_visit_IBID_VARCHAR + def postgres_visit_IBID_TEXT(self, type_): + if type_.case_insensitive: + return 'CITEXT' + else: + return self.visit_TEXT(type_) + sqlalchemy.dialects.postgresql.dialect.type_compiler.visit_IBID_TEXT = postgres_visit_IBID_TEXT - def load_dialect_impl(self, dialect): - if hasattr(dialect, 'name'): - self.dialect = dialect.name - # SQLAlchemy 0.4: - else: - self.dialect = { - 'SQLiteDialect': 'sqlite', - 'PGDialect': 'postgres', - 'MySQLDialect': 'mysql', - }[dialect.__class__.__name__] - - return dialect.type_descriptor(self.impl) - - def get_col_spec(self): - colspec = self.impl.get_col_spec() - if hasattr(self, 'case_insensitive'): - collation = None - if self.dialect == 'mysql': - if self.case_insensitive: - collation = 'utf8_general_ci' - else: - collation = 'utf8_bin' - elif self.dialect == 'sqlite': - if self.case_insensitive: - collation = 'NOCASE' - else: - collation = 'BINARY' - elif self.dialect == 'postgres' and self.case_insensitive: - return 'CITEXT' - - if collation is not None: - return colspec + ' COLLATE ' + collation - return colspec + import sqlalchemy.dialects.sqlite + def sqlite_visit_IBID_VARCHAR(self, type_): + if type_.case_insensitive: + collation = 'NOCASE' + else: + collation = 'BINARY' + return self.visit_VARCHAR(type_) + ' COLLATE ' + collation + sqlalchemy.dialects.sqlite.dialect.type_compiler.visit_IBID_VARCHAR = sqlite_visit_IBID_VARCHAR + def sqlite_visit_IBID_TEXT(self, type_): + if type_.case_insensitive: + collation = 'NOCASE' + else: + collation = 'BINARY' + return self.visit_TEXT(type_) + ' COLLATE ' + collation + sqlalchemy.dialects.sqlite.dialect.type_compiler.visit_IBID_TEXT = sqlite_visit_IBID_TEXT + + import sqlalchemy.dialects.mysql + def mysql_visit_IBID_VARCHAR(self, type_): + if type_.case_insensitive: + collation = 'utf8_general_ci' + else: + collation = 'utf8_bin' + return self.visit_VARCHAR(type_) + ' COLLATE ' + collation + sqlalchemy.dialects.mysql.dialect.type_compiler.visit_IBID_VARCHAR = sqlite_visit_IBID_VARCHAR + def mysql_visit_IBID_TEXT(self, type_): + if type_.case_insensitive: + collation = 'utf8_general_ci' + else: + collation = 'utf8_bin' + return self.visit_TEXT(type_) + ' COLLATE ' + collation + sqlalchemy.dialects.mysql.dialect.type_compiler.visit_IBID_TEXT = sqlite_visit_IBID_TEXT -class IbidUnicode(_CIDecorator): +class IbidUnicode(_Unicode): "Collaiton aware Unicode" - impl = _Unicode + __visit_name__ = 'IBID_VARCHAR' - def __init__(self, length, **kwargs): + def __init__(self, length, case_insensitive=False, **kwargs): + self.case_insensitive = case_insensitive super(IbidUnicode, self).__init__(length, **kwargs) -class IbidUnicodeText(_CIDecorator): +class IbidUnicodeText(_UnicodeText): "Collation aware UnicodeText" - impl = _UnicodeText + __visit_name__ = 'IBID_TEXT' - def __init__(self, index_length=8, **kwargs): + def __init__(self, index_length=8, case_insensitive=False, **kwargs): + self.case_insensitive = case_insensitive self.index_length = index_length - super(IbidUnicodeText, self).__init__(length=None, **kwargs) + super(IbidUnicodeText, self).__init__(**kwargs) + +monkey_patch() # vi: set et sta sw=4 ts=4: --- a/ibid/db/versioned_schema.py +++ b/ibid/db/versioned_schema.py @@ -4,14 +4,11 @@ import logging import re -from sqlalchemy import Column, Index, UniqueConstraint, MetaData, \ - __version__ as _sqlalchemy_version -from sqlalchemy.exceptions import InvalidRequestError, OperationalError, \ +from sqlalchemy import Column, Index, CheckConstraint, UniqueConstraint, \ + MetaData, __version__ as _sqlalchemy_version +from sqlalchemy.exc import InvalidRequestError, OperationalError, \ ProgrammingError, InternalError -if _sqlalchemy_version < '0.5': - NoResultFound = InvalidRequestError -else: - from sqlalchemy.orm.exc import NoResultFound +from sqlalchemy.orm.exc import NoResultFound from ibid.db.types import Integer, IbidUnicodeText, IbidUnicode @@ -19,6 +16,11 @@ log = logging.getLogger('ibid.db.versioned_schema') +if _sqlalchemy_version < '0.6': + pg_engine = 'postgres' +else: + pg_engine = 'postgresql' + class VersionedSchema(object): """For an initial table schema, set table.versioned_schema = VersionedSchema(__table__, 1) @@ -78,7 +80,7 @@ self._create_table() schema = Schema(unicode(self.table.name), self.version) - session.save_or_update(schema) + session.add(schema) return Schema.__table__ = self._get_reflected_model() @@ -92,7 +94,7 @@ self._create_table() schema = Schema(unicode(self.table.name), self.version) - session.save_or_update(schema) + session.add(schema) elif self.version > schema.version: for version in range(schema.version + 1, self.version + 1): @@ -104,7 +106,7 @@ getattr(self, 'upgrade_%i_to_%i' % (version - 1, version))() schema.version = version - session.save_or_update(schema) + session.add(schema) self.upgrade_reflected_model = \ MetaData(session.bind, reflect=True) @@ -127,7 +129,7 @@ if session.bind.engine.name == 'sqlite': return 'ix_%s_%s' % (self.table.name, col.name) - elif session.bind.engine.name == 'postgres': + elif session.bind.engine.name == pg_engine: return '%s_%s_key' % (self.table.name, col.name) elif session.bind.engine.name == 'mysql': return col.name @@ -176,6 +178,8 @@ ('constraints', old_constraints), ('indexes', old_indexes)): for constraint in old_list: + if isinstance(constraint, CheckConstraint): + continue if any(True for column in constraint.columns if isinstance(column.type, IbidUnicodeText)): indices.append(( @@ -247,7 +251,7 @@ query = 'ALTER TABLE "%s" ADD %s INDEX "%s" ("%s"(%i));' % ( self.table.name, col.unique and 'UNIQUE' or '', self._index_name(col), col.name, col.type.index_length) - elif engine == 'postgres': + elif engine == pg_engine: # SQLAlchemy hangs if it tries to do this, because it forgets the ; query = 'CREATE %s INDEX "%s" ON "%s" ("%s")' % ( col.unique and 'UNIQUE' or '',self._index_name(col), @@ -270,7 +274,7 @@ return raise except ProgrammingError, e: - if engine == 'postgres' and u'already exists' in unicode(e): + if engine == pg_engine and u'already exists' in unicode(e): return raise @@ -295,21 +299,13 @@ raise except ProgrammingError, e: - if engine == 'postgres' and u'does not exist' in unicode(e): + if engine == pg_engine and u'does not exist' in unicode(e): return - # In SQLAlchemy 0.4, the InternalError below is a ProgrammingError - # and can't be executed in the upgrade transaction: - if engine == 'postgres' and u'requires' in unicode(e): - self.upgrade_session.bind.execute( - 'ALTER TABLE "%s" DROP CONSTRAINT "%s"' % ( - self.table.name, self._index_name(col))) - return - raise # Postgres constraints can be attached to tables and can't be dropped # at DB level. except InternalError, e: - if engine == 'postgres': + if engine == pg_engine: self.upgrade_session.execute( 'ALTER TABLE "%s" DROP CONSTRAINT "%s"' % ( self.table.name, self._index_name(col))) --- a/ibid/plugins/codecontest.py +++ b/ibid/plugins/codecontest.py @@ -239,7 +239,7 @@ usaco_account[0].value = usaco_user else: account.attributes.append(Attribute('usaco_account', usaco_user)) - event.session.save_or_update(account) + event.session.add(account) event.session.commit() event.addresponse(u'Done') --- a/ibid/plugins/factoid.py +++ b/ibid/plugins/factoid.py @@ -82,7 +82,7 @@ .filter(FactoidName.name.like('%#_#%%', escape='#')) \ .all(): row.wild = True - self.upgrade_session.save_or_update(row) + self.upgrade_session.add(row) def upgrade_7_to_8(self): self.drop_index(self.table.c._name) self.alter_column(Column('name', @@ -394,7 +394,7 @@ name = FactoidName(unicode(target), event.identity) factoid.names.append(name) - event.session.save_or_update(factoid) + event.session.add(factoid) event.session.commit() event.addresponse(True) log.info(u"Added name '%s' to factoid %s (%s) by %s/%s (%s)", @@ -590,7 +590,7 @@ factoid = Factoid() fname = FactoidName(unicode(name), event.identity) factoid.names.append(fname) - event.session.save_or_update(factoid) + event.session.add(factoid) event.session.flush() log.info(u"Creating factoid %s with name '%s' by %s", factoid.id, fname.name, event.identity) @@ -598,7 +598,7 @@ value = '%s %s' % (verb, value) fvalue = FactoidValue(unicode(value), event.identity) factoid.values.append(fvalue) - event.session.save_or_update(factoid) + event.session.add(factoid) event.session.commit() self.last_set_factoid=factoid.names[0].name log.info(u"Added value '%s' to factoid %s (%s) by %s/%s (%s)", @@ -659,7 +659,7 @@ oldvalue = factoid[2].value factoid[2].value += suffix - event.session.save_or_update(factoid[2]) + event.session.add(factoid[2]) event.session.commit() log.info(u"Appended '%s' to value %s of factoid %s (%s) by %s/%s (%s)", @@ -752,7 +752,7 @@ event.addresponse(u"That operation makes no sense. Try something like y/abcdef/ABCDEF/") return - event.session.save_or_update(factoid[2]) + event.session.add(factoid[2]) event.session.commit() log.info(u"Applying '%s' to value %s of factoid %s (%s) by %s/%s (%s)", --- a/ibid/plugins/feeds.py +++ b/ibid/plugins/feeds.py @@ -143,7 +143,7 @@ return feed = Feed(unicode(name), unicode(url), event.identity) - event.session.save(feed) + event.session.add(feed) event.session.commit() event.addresponse(True) log.info(u"Added feed '%s' by %s/%s (%s): %s (Found %s entries)", --- a/ibid/plugins/identity.py +++ b/ibid/plugins/identity.py @@ -54,7 +54,7 @@ return account = Account(username) - event.session.save_or_update(account) + event.session.add(account) event.session.commit() log.info(u"Created account %s (%s) by %s/%s (%s)", account.id, account.username, event.account, event.identity, event.sender['connection']) @@ -64,14 +64,14 @@ .filter_by(identity=username, source=event.source).first() if identity: identity.account_id = account.id - event.session.save_or_update(identity) + event.session.add(identity) event.session.commit() log.info(u"Attached identity %s (%s on %s) to account %s (%s)", identity.id, identity.identity, identity.source, account.id, account.username) else: identity = event.session.query(Identity).get(event.identity) identity.account_id = account.id - event.session.save_or_update(identity) + event.session.add(identity) event.session.commit() log.info(u"Attached identity %s (%s on %s) to account %s (%s)", identity.id, identity.identity, identity.source, account.id, account.username) @@ -132,7 +132,7 @@ oldname = account.username account.username = newname - event.session.save_or_update(account) + event.session.add(account) event.session.commit() identify_cache.clear() @@ -183,12 +183,12 @@ return account = Account(username) - event.session.save_or_update(account) + event.session.add(account) currentidentity = event.session.query(Identity) \ .get(event.identity) currentidentity.account_id = account.id - event.session.save_or_update(currentidentity) + event.session.add(currentidentity) identify_cache.clear() @@ -250,7 +250,7 @@ if not ident: ident = Identity(source, identity) ident.account_id = account.id - event.session.save_or_update(ident) + event.session.add(ident) event.session.commit() identify_cache.clear() @@ -276,7 +276,7 @@ if not identity: identity = Identity(source, user) identity.account_id = account_id - event.session.save_or_update(identity) + event.session.add(identity) identify_cache.clear() del self.tokens[token] @@ -308,7 +308,7 @@ event.addresponse(u"I don't know about that identity") else: identity.account_id = None - event.session.save_or_update(identity) + event.session.add(identity) event.session.commit() identify_cache.clear() @@ -344,7 +344,7 @@ return account.attributes.append(Attribute(name, value)) - event.session.save_or_update(account) + event.session.add(account) event.session.commit() event.addresponse(True) @@ -467,7 +467,7 @@ .first() if not identity: identity = Identity(event.source, event.sender['id']) - event.session.save_or_update(identity) + event.session.add(identity) try: event.session.commit() log.info(u'Created identity %s for %s on %s', identity.id, identity.identity, identity.source) @@ -546,7 +546,7 @@ credential = password credential = Credential(method, credential, source, account.id) - event.session.save_or_update(credential) + event.session.add(credential) event.session.commit() log.info(u"Added %s credential %s for account %s (%s) on %s by account %s", method, credential.credential, account.id, account.username, source, event.account) @@ -601,7 +601,7 @@ return permission.value = value - event.session.save_or_update(permission) + event.session.add(permission) event.session.commit() ibid.auth.drop_caches() --- a/ibid/plugins/karma.py +++ b/ibid/plugins/karma.py @@ -112,7 +112,7 @@ event.session.delete(karma) else: - event.session.save_or_update(karma) + event.session.add(karma) event.session.commit() log.info(u"%s karma for '%s' by %s/%s (%s) because: %s", @@ -143,11 +143,18 @@ @match(r'^(reverse\s+)?karmaladder$') def ladder(self, event, reverse): - karmas = event.session.query(Karma) \ - .order_by(reverse and Karma.value.asc() or Karma.value.desc()) \ - .limit(30).all() + karmas = event.session.query(Karma) + if reverse: + karmas = karmas.order_by(Karma.value.asc()) + else: + karmas = karmas.order_by(Karma.value.desc()) + karmas = karmas.limit(30).all() + if karmas: - event.addresponse(', '.join(['%s: %s (%s)' % (karmas.index(karma), karma.subject, karma.value) for karma in karmas])) + event.addresponse(u', '.join( + u'%s: %s (%s)' + % (karmas.index(karma), karma.subject, karma.value) + for karma in karmas)) else: event.addresponse(u"I don't really care about anything") --- a/ibid/plugins/memo.py +++ b/ibid/plugins/memo.py @@ -118,7 +118,7 @@ event.addresponse(u'I am not connected to %s', source) return to = Identity(source, who) - event.session.save(to) + event.session.add(to) event.session.commit() log.info(u"Created identity %s for %s on %s", to.id, to.identity, @@ -133,7 +133,7 @@ memo = Memo(event.identity, to.id, memo, how.lower() in (u'pm', u'privmsg', u'msg')) - event.session.save_or_update(memo) + event.session.add(memo) event.session.commit() log.info(u"Stored memo %s for %s (%s) from %s (%s): %s", @@ -290,7 +290,7 @@ }) memo.delivered = True - event.session.save_or_update(memo) + event.session.add(memo) event.session.commit() log.info(u"Delivered memo %s to %s (%s)", memo.id, event.identity, event.sender['connection']) --- a/ibid/plugins/seen.py +++ b/ibid/plugins/seen.py @@ -86,7 +86,7 @@ sighting.time = event.time sighting.count = sighting.count + 1 - event.session.save_or_update(sighting) + event.session.add(sighting) try: event.session.commit() except IntegrityError: --- a/ibid/plugins/urlgrab.py +++ b/ibid/plugins/urlgrab.py @@ -76,7 +76,7 @@ url = 'http://%s' % url u = URL(url, event.channel, event.identity) - event.session.save_or_update(u) + event.session.add(u) if self.service and self.username: self._post_url(event, url) --- a/scripts/ibid-factpack +++ b/scripts/ibid-factpack @@ -85,7 +85,7 @@ exit(5) factpack = Factpack(name) -session.save(factpack) +session.add(factpack) session.flush() existing = [] @@ -102,7 +102,7 @@ fvalue = FactoidValue(unicode(value), None, factpack=factpack.id) factoid.values.append(fvalue) if len(factoid.names) > 0: - session.save(factoid) + session.add(factoid) if existing and not options.skip: print >> stderr, u'The following factoids already exist in the database. ' \ --- a/scripts/ibid-knab-import +++ b/scripts/ibid-knab-import @@ -130,7 +130,7 @@ if not identity: identity = Identity(source, user) identity.created = created - session.save(identity) + session.add(identity) session.flush() elif identity.created > created: identity.created = created @@ -187,7 +187,7 @@ fvalue.time = kfactoid.utc_time factoid.values.append(fvalue) - ibid.save_or_update(factoid) + ibid.add(factoid) ibid.commit() @@ -297,7 +297,7 @@ config.merge(FileConfig('local.ini')) ibidengine = create_engine(config.databases['ibid'], encoding='utf-8') - IbidSession = sessionmaker(bind=ibidengine, transactional=False) + IbidSession = sessionmaker(bind=ibidengine, autocommit=True) ibid = IbidSession() import_factoids(knab, ibid, source) --- a/scripts/ibid-plugin +++ b/scripts/ibid-plugin @@ -16,7 +16,7 @@ except ImportError: pass -from sqlalchemy.exceptions import IntegrityError +from sqlalchemy.exc import IntegrityError sys.path.insert(0, '.') @@ -98,7 +98,7 @@ identity = session.query(Identity).filter_by(identity=username, source=u'test_source').first() if not identity: identity = Identity(u'test_source',username) - session.save(identity) + session.add(identity) session.commit() identity = session.query(Identity).filter_by(identity=username).first() identity_id = identity.id --- a/scripts/ibid-setup +++ b/scripts/ibid-setup @@ -160,8 +160,8 @@ credential = Credential(u'password', hash(unicode(pass1))) account.credentials.append(credential) -session.save_or_update(account) -session.save_or_update(identity) +session.add(account) +session.add(identity) session.commit() session.close() --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ 'PyStemmer', 'python-dateutil', 'SOAPpy', - 'SQLAlchemy>=0.5,<0.6a', # Works with >=0.4.6 except on OS X + 'SQLAlchemy>=0.6', 'Twisted', 'wokkel>=0.6.3', ] debian/patches/jinja2.diff0000644000000000000000000000336411622002071012621 0ustar Description: Use Jinja2 instead of Jinja Author: Keegan Carruthers-Smith Origin: https://code.launchpad.net/~keegan-csmith/ibid/jinja2-517784/+merge/71326 Bug-Debian: http://bugs.debian.org/634910 Last-Updated: 2011-08-12 --- a/INSTALL +++ b/INSTALL @@ -25,7 +25,7 @@ # aptitude install python-beautifulsoup \ python-dateutil python-dnspython python-feedparser \ python-html2text python-html5lib python-imdbpy \ - python-jinja python-silc python-setuptools \ + python-jinja2 python-silc python-setuptools \ python-simplejson python-soappy python-sqlalchemy \ python-twisted python-wokkel --- a/docs/install.rst +++ b/docs/install.rst @@ -65,7 +65,7 @@ Web source and web services: -* `Jinja `_ +* `Jinja2 `_ Other sources: @@ -264,7 +264,7 @@ user@box $ sudo aptitude install bzr python-configobj python-sqlalchemy \ python-twisted python-beautifulsoup python-celementtree \ python-html5lib python-setuptools python-simplejson \ - python-soappy python-jinja python-dateutil python-virtualenv + python-soappy python-jinja2 python-dateutil python-virtualenv Create a user to run your bot as:: --- a/ibid/source/http.py +++ b/ibid/source/http.py @@ -6,7 +6,7 @@ from twisted.web import server, resource, static, xmlrpc, soap from twisted.application import internet from twisted.internet import reactor -from jinja import Environment, FileSystemLoader +from jinja2 import Environment, FileSystemLoader import ibid from ibid.source import IbidSourceFactory --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ 'feedparser', 'html2text', 'html5lib', - 'jinja', + 'jinja2', 'pyopenssl', 'PyStemmer', 'python-dateutil', debian/patches/docs.diff0000644000000000000000000000077011343434423012404 0ustar Description: contrib/ and factpacks/ will be installed as docs. Author: Michael Gorven Forwarded: not-needed Last-Update: 2010-01-25 --- a/setup.py +++ b/setup.py @@ -53,7 +53,7 @@ 'http://ibid.omnia.za.net/eggs/', 'http://wokkel.ik.nu/downloads', ], - packages=['ibid', 'tracibid', 'twisted', 'contrib', 'factpacks'], + packages=['ibid', 'tracibid', 'twisted'], entry_points={ 'trac.plugins': ['tracibid = tracibid.notifier'], }, debian/patches/fortune-path.diff0000644000000000000000000000125211533430567014072 0ustar Description: Provide explicit fortune executable location. fortune is in /usr/games on Debian, which won't necessarily be in the user's path. Change the default location to an absolute path. Author: Stefano Rivera Forwarded: not-needed Last-Update: 2011-03-02 --- a/ibid/plugins/quotes.py +++ b/ibid/plugins/quotes.py @@ -29,7 +29,8 @@ usage = u'fortune' feature = ('fortune',) - fortune = Option('fortune', 'Path of the fortune executable', 'fortune') + fortune = Option('fortune', 'Path of the fortune executable', + '/usr/games/fortune') def __init__(self, name): super(Fortune, self).__init__(name) debian/patches/separate-data.diff0000644000000000000000000000412411533430567014172 0ustar Description: Move data to /usr/share/ibid Don't try to install it from setup.py. Update Ibid's locate_resource helper to look in /usr/share and provide emulation functions for ibid-setup which doesn't use locate_resource. Author: Stefano Rivera Forwarded: not-needed Last-Update: 2011-03-02 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,15 +1,11 @@ recursive-include ibid *.py -recursive-include ibid/templates * recursive-include tracibid *.py recursive-include contrib * recursive-include ibid/lib *.py -recursive-include ibid/data * -recursive-include ibid/static * recursive-include docs * recursive-include man * include factpacks/*.json include factpacks/README -include ibid/*.ini include twisted/plugins/ibid_plugin.py include README include INSTALL --- a/ibid/utils/__init__.py +++ b/ibid/utils/__init__.py @@ -21,7 +21,6 @@ import dateutil.parser from dateutil.tz import tzlocal, tzutc -from pkg_resources import resource_exists, resource_filename import ibid from ibid.compat import defaultdict, json @@ -283,9 +282,11 @@ )) if os.path.exists(fspath): return fspath - if not resource_exists(path, filename): + + debianpath = os.path.join(*(['/usr/share'] + path.split('.') + [filename])) + if not os.path.exists(debianpath): return None - return resource_filename(path, filename) + return debianpath def get_process_output(command, input=None): process = Popen(command, stdin=PIPE, stdout=PIPE, stderr=PIPE) --- a/scripts/ibid-setup +++ b/scripts/ibid-setup @@ -8,10 +8,16 @@ from sys import exit, stderr from getpass import getpass from os import getenv -from os.path import exists +from os.path import exists, join from shutil import copyfileobj -from pkg_resources import resource_filename, resource_stream +# Debian replacements for pkg_resources +def resource_filename(package, resource): + return join('/usr/share', package, resource) + +def resource_stream(package, resource): + return file(resource_filename(package, resource), 'rb') + from twisted.python.modules import getModule sys.path.insert(0, '.') debian/patches/pyfiglet-0.6.diff0000644000000000000000000000652311622002071013570 0ustar Description: Support pyfiglet >= 0.6 (only) Author: Stefano Rivera Origin: https://code.launchpad.net/~stefanor/ibid/pyfiglet-0.6/+merge/65127 Last-Update: 2011-08-14 --- a/ibid/plugins/ascii.py +++ b/ibid/plugins/ascii.py @@ -3,19 +3,17 @@ from BaseHTTPServer import BaseHTTPRequestHandler from cStringIO import StringIO -import fnmatch import Image -from os import listdir, remove +from os import remove import os.path from random import choice import subprocess from tempfile import mkstemp from urllib2 import HTTPError, URLError, urlopen from urlparse import urlparse -from zipfile import ZipFile from aalib import AsciiScreen -from pyfiglet import Figlet, FontNotFound +from pyfiglet import Figlet from ibid.config import Option, IntOption, ListOption from ibid.plugins import Processor, match @@ -158,8 +156,6 @@ feature = ('figlet',) max_width = IntOption('max_width', 'Maximum width for ascii output', 60) - fonts_ = Option('fonts', 'Directory or Zip file containing figlet fonts', - '/usr/share/figlet') preferred_fonts = ListOption('preferred_fonts', 'List of default figlet fonts', ('slant', 'letter')) @@ -168,29 +164,8 @@ self.fonts = None def _find_fonts(self): - if self.fonts is not None: - return - - if os.path.isdir(self.fonts_): - self.fontstore = 'dir' - fonts = listdir(self.fonts_) - else: - self.fontstore = 'zip' - zip = ZipFile(self.fonts_) - fonts = zip.namelist() - fonts = fnmatch.filter(fonts, '*.[tf]lf') - - self.fonts = {} - for font in fonts: - font = os.path.splitext(font)[0] - # Not all fonts are compatible with pyfiglet - # (e.g. TLFs with colour): - try: - self._render('test', font) - except FontNotFound: - continue - name = os.path.split(font)[-1] - self.fonts[name] = font + if self.fonts is None: + self.fonts = Figlet().getFonts() @match(r'^list\s+figlet\s+fonts(?:\s+from\s+(\d+))?$') def list_fonts(self, event, index): @@ -201,7 +176,7 @@ if index >= len(self.fonts): event.addresponse(u'I wish I had that many fonts installed') return - event.addresponse(unicode(', '.join(self.fonts.keys()[int(index):]))) + event.addresponse(unicode(', '.join(self.fonts[int(index):]))) @match(r'^figlet\s+(.+?)(\s+in\s+(\S+))?$', 'deaddressed') def write(self, event, text, font_phrase, font): @@ -215,17 +190,14 @@ if font in self.fonts: break else: - font = choice(self.fonts.keys()) + font = choice(self.fonts) else: event.addresponse(u"I'm afraid I have no fonts available") return self._write(event, text, font) def _render(self, text, font): - if self.fontstore == 'dir': - figlet = Figlet(font=font, dir=self.fonts_) - else: - figlet = Figlet(font=font, zipfile=self.fonts_) + figlet = Figlet(font=font) return figlet.renderText(text) def _write(self, event, text, font): debian/examples0000644000000000000000000000002211332371357010726 0ustar contrib factpacks debian/docs0000644000000000000000000000001311510440320010021 0ustar build/docs debian/links0000644000000000000000000000007711621157460010240 0ustar /usr/share/doc/ibid/html/_sources /usr/share/doc/ibid/rst