rev 3603 - in debbugs-illa: . bzlink
Pierre Habouzit
madcoder at costa.debian.org
Tue Apr 18 23:00:03 UTC 2006
Author: madcoder
Date: 2006-04-18 23:00:00 +0000 (Tue, 18 Apr 2006)
New Revision: 3603
Added:
debbugs-illa/bzlink/sender.py
Modified:
debbugs-illa/TODO
debbugs-illa/bzlink.cfg
debbugs-illa/bzlink/__init__.py
Log:
now bz* tools use the same mechanism as reportbut to guess From in the
mail.
(REPORTBUGEMAIL, DEBEMAIL, EMAIL, and stuff like that)
code drectly taken from reporbug.py
drop from = settings in bzlink.cfg
Modified: debbugs-illa/TODO
===================================================================
--- debbugs-illa/TODO 2006-04-18 22:46:12 UTC (rev 3602)
+++ debbugs-illa/TODO 2006-04-18 23:00:00 UTC (rev 3603)
@@ -7,8 +7,6 @@
* bzlink is not well named:
+ bzlink should be bznotifparse (or anything meaningful)
- * Use DEBEMAIL to forge current Config.From (have to look at reportbug)
-
Medium Term:
* make bzlink figure how to jump from merged closings into other merged
Modified: debbugs-illa/bzlink/__init__.py
===================================================================
--- debbugs-illa/bzlink/__init__.py 2006-04-18 22:46:12 UTC (rev 3602)
+++ debbugs-illa/bzlink/__init__.py 2006-04-18 23:00:00 UTC (rev 3603)
@@ -29,6 +29,7 @@
###############################################################################
import os
+import sender
from ConfigParser import RawConfigParser
class NoSuchSection(Exception):
@@ -61,8 +62,12 @@
def debug(self): return self._get('debug')
def ldap(self): return self._get('ldap')
def user(self): return self._get('user')
- def sender(self): return self._get('from')
+ def sender(self):
+ tmp = self._get('from')
+ if tmp is None: return sender.get_email()[1]
+ return tmp
+
def bugzilla(self):
url = self._get('bugzilla')
if url is not None:
Added: debbugs-illa/bzlink/sender.py
===================================================================
--- debbugs-illa/bzlink/sender.py 2006-04-18 22:46:12 UTC (rev 3602)
+++ debbugs-illa/bzlink/sender.py 2006-04-18 23:00:00 UTC (rev 3603)
@@ -0,0 +1,72 @@
+# vim:set encoding=utf-8:
+###############################################################################
+#
+# This code has been taken from the reportbug module
+#
+###############################################################################
+#
+# Reportbug module - common functions for reportbug and greportbug
+# Written by Chris Lawrence <lawrencc at debian.org>
+# Copyright (C) 1999-2005 Chris Lawrence
+#
+# This program is freely distributable per the following license:
+#
+## Permission to use, copy, modify, and distribute this software and its
+## documentation for any purpose and without fee is hereby granted,
+## provided that the above copyright notice appears in all copies and that
+## both that copyright notice and this permission notice appear in
+## supporting documentation.
+##
+## I DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
+## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL I
+## BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
+## DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+## WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+## SOFTWARE.
+
+import pwd, re, os, rfc822
+
+def get_email_addr(addr):
+ addr = rfc822.AddressList(addr)
+ return addr.addresslist[0]
+
+def get_email(email='', realname=''):
+ return get_email_addr(get_user_id(email, realname))
+
+def get_user_id(email='', realname=''):
+ uid = os.getuid()
+ info = pwd.getpwuid(uid)
+ email = (os.environ.get('REPORTBUGEMAIL', email) or
+ os.environ.get('DEBEMAIL') or os.environ.get('EMAIL'))
+
+ email = email or find_rewritten(info[0]) or info[0]
+
+ if '@' not in email:
+ if os.path.exists('/etc/mailname'):
+ domainname = file('/etc/mailname').readline().strip()
+ else:
+ domainname = socket.getfqdn()
+
+ email = email+'@'+domainname
+
+ # Handle EMAIL if it's formatted as 'Bob <bob at host>'.
+ if '<' in email or '(' in email:
+ realname, email = get_email_addr(email)
+
+ if not realname:
+ realname = (os.environ.get('DEBFULLNAME') or os.environ.get('DEBNAME')
+ or os.environ.get('NAME'))
+ if not realname:
+ realname = info[4].split(',', 1)[0]
+ # Convert & in gecos field 4 to capitalized logname: #224231
+ realname = realname.replace('&', info[0].upper())
+
+ if not realname:
+ return email
+
+ if re.match(r'[\w\s]+$', realname):
+ return '%s <%s>' % (realname, email)
+
+ return rfc822.dump_address_pair( (realname, email) )
+
Modified: debbugs-illa/bzlink.cfg
===================================================================
--- debbugs-illa/bzlink.cfg 2006-04-18 22:46:12 UTC (rev 3602)
+++ debbugs-illa/bzlink.cfg 2006-04-18 23:00:00 UTC (rev 3603)
@@ -2,13 +2,17 @@
debug = false
ldap = 'ldap://bts2ldap.debian.net:10101'
+[debug]
+debug = true
+bugzilla = 'http://bugs.kde.org'
+user = 'debian-qt-kde at lists.debian.org'
+from = a at b.com
+
[kde]
bugzilla = 'http://bugs.kde.org'
user = 'debian-qt-kde at lists.debian.org'
-from = 'debian-qt-kde at lists.debian.org'
[gnome]
bugzilla = 'http://bugs.gnome.org'
user = 'pkg-gnome-maintainers at lists.alioth.debian.org'
-from = 'pkg-gnome-maintainers at lists.alioth.debian.org'
More information about the pkg-kde-commits
mailing list