mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-03-14 00:21:08 +00:00
Tone down ubu_email magic
This commit is contained in:
parent
b038e247d5
commit
2a1a48ae56
@ -95,33 +95,21 @@ def ubu_email(name=None, email=None, export=True):
|
||||
"""Find the developer's Ubuntu e-mail address, and export it in
|
||||
DEBFULLNAME, DEBEMAIL if necessary (and export isn't False).
|
||||
|
||||
e-mail Priority: arguments, UBUMAIL, DEBEMAIL, DEBFULLNAME, user@mailname
|
||||
e-mail Priority: arguments, UBUMAIL, DEBEMAIL, user@mailname
|
||||
name Priority: arguments, UBUMAIL, DEBFULLNAME, DEBEMAIL, NAME, /etc/passwd
|
||||
|
||||
Name and email are only exported if provided as arguments or found in
|
||||
UBUMAIL. Otherwise, wrapped devscripts scripts can be expected to determine
|
||||
the values themselves.
|
||||
|
||||
Return email, name.
|
||||
Return name, email.
|
||||
"""
|
||||
name_email_re = re.compile(r'^\s*(.+?)\s*<(.+@.+)>\s*$')
|
||||
|
||||
# First priority is to sanity-check command-line supplied values:
|
||||
if name:
|
||||
name = name.strip()
|
||||
if email:
|
||||
email = email.strip()
|
||||
if name:
|
||||
m = name_email_re.match(name)
|
||||
if m:
|
||||
name = m.group(1)
|
||||
if not email:
|
||||
email = m.group(2)
|
||||
if email:
|
||||
m = name_email_re.match(email)
|
||||
if m:
|
||||
if not name:
|
||||
name = m.group(1)
|
||||
if m and not name:
|
||||
name = m.group(1)
|
||||
email = m.group(2)
|
||||
|
||||
if export and not name and not email and 'UBUMAIL' not in os.environ:
|
||||
@ -130,23 +118,23 @@ def ubu_email(name=None, email=None, export=True):
|
||||
for var, target in (
|
||||
('UBUMAIL', 'name'),
|
||||
('UBUMAIL', 'email'),
|
||||
('DEBEMAIL', 'email'),
|
||||
('DEBFULLNAME', 'name'),
|
||||
('DEBEMAIL', 'name'),
|
||||
('DEBFULLNAME', 'email'),
|
||||
('DEBEMAIL', 'email'),
|
||||
('NAME', 'name'),
|
||||
):
|
||||
if name and email:
|
||||
break
|
||||
if var in os.environ and not locals()[target]:
|
||||
m = name_email_re.match(os.environ[var])
|
||||
if m:
|
||||
if target == 'name':
|
||||
name = m.group(1)
|
||||
if var.endswith('MAIL'):
|
||||
m = name_email_re.match(os.environ[var])
|
||||
if m:
|
||||
if target == 'name':
|
||||
name = m.group(1)
|
||||
elif target == 'email':
|
||||
email = m.group(2)
|
||||
elif target == 'email':
|
||||
email = m.group(2)
|
||||
elif var.endswith('MAIL') and target == 'email':
|
||||
email = os.environ[var].strip()
|
||||
email = os.environ[var].strip()
|
||||
elif var.endswith('NAME') and target == 'name':
|
||||
name = os.environ[var].strip()
|
||||
|
||||
|
@ -179,13 +179,6 @@ class UbuEmailTestCase(unittest.TestCase):
|
||||
self.assertEqual(os.environ['DEBFULLNAME'], name)
|
||||
self.assertEqual(os.environ['DEBEMAIL'], email)
|
||||
|
||||
def test_debfullname_with_email(self):
|
||||
name = 'Joe Developer'
|
||||
email = 'joe@example.net'
|
||||
os.environ['DEBFULLNAME'] = orig = '%s <%s>' % (name, email)
|
||||
self.assertEqual(ubu_email(), (name, email))
|
||||
self.assertEqual(os.environ['DEBFULLNAME'], orig)
|
||||
|
||||
def test_debemail_with_name(self):
|
||||
name = 'Joe Developer'
|
||||
email = 'joe@example.net'
|
||||
|
Loading…
x
Reference in New Issue
Block a user