Rev 1: A simple LogFormatter that allows you to 'bzr log --rss' in http://bzr.arbash-meinel.com/plugins/log_rss
John Arbash Meinel
john at arbash-meinel.com
Fri Nov 30 19:50:25 GMT 2007
At http://bzr.arbash-meinel.com/plugins/log_rss
------------------------------------------------------------
revno: 1
revision-id:john at arbash-meinel.com-20071130195023-bbpeudonbtght8wp
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: log_rss
timestamp: Fri 2007-11-30 13:50:23 -0600
message:
A simple LogFormatter that allows you to 'bzr log --rss'
added:
__init__.py __init__.py-20071130195009-36quy5abpgjs8gwj-1
rss_log.py rss_log.py-20071130195009-36quy5abpgjs8gwj-2
-------------- next part --------------
=== added file '__init__.py'
--- a/__init__.py 1970-01-01 00:00:00 +0000
+++ b/__init__.py 2007-11-30 19:50:23 +0000
@@ -0,0 +1,25 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# 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 2 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""Add a log formatter that generates an RSS feed."""
+
+version_info = (0, 1, 0, 'dev', 0)
+
+from bzrlib import log
+
+log.log_formatter_registry.register_lazy('rss',
+ __name__ + '.rss_log', 'RSSLogFormatter',
+ 'Log formatter for RSS feeds.')
=== added file 'rss_log.py'
--- a/rss_log.py 1970-01-01 00:00:00 +0000
+++ b/rss_log.py 2007-11-30 19:50:23 +0000
@@ -0,0 +1,56 @@
+# Copyright (C) 2007 Canonical Ltd
+#
+# 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 2 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.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+"""A log formatter that generates an RSS feed."""
+
+import cgi
+
+from bzrlib import log
+
+
+class RSSLogFormatter(log.LogFormatter):
+ """A log formatter that generates an RSS feed.
+ """
+
+ def log_revision(self, revision):
+ from bzrlib.osutils import format_date
+
+ rev = revision.rev
+ date_str = format_date(rev.timestamp,
+ rev.timezone or 0,
+ timezone='original',
+ date_fmt='%a, %d %b %Y %H:%M:%S')
+ first_line = rev.message.split('\n', 1)[0].strip()
+
+ escaped_message = cgi.escape(rev.message.strip(), True)
+ escaped_message = escaped_message.replace('\n', '<br />\n')
+ escaped_author = ''.join('&#%d;' % ord(c) for c in rev.committer)
+
+ info_dict = dict(first_line=first_line,
+ escaped_message=escaped_message,
+ author=escaped_author,
+ date=date_str,
+ revision_id=rev.revision_id)
+
+ to_file = self.to_file
+ to_file.write('''<item>
+ <title>%(first_line)s</title>
+ <link>rev/%(revision_id)s<link>
+ <description><![CDATA[%(escaped_message)s]]></description>
+ <author>%(author)s</author>
+ <pubDate>%(date)s</pubDate>
+</item>
+''' % info_dict)
More information about the bazaar-commits
mailing list