Y
  @   	ˆl–Ü4ý( ©”u( 	•íÀà™S�ÿŽþFð–nQðÈ0„¤óÉƒ�ƒÈ_ŠI|¥�+Wé3ž¯ÇÆ 
‚    	# Copyright (C) 2009 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, see <http://www.gnu.org/licenses/>.

from email.utils import parseaddr


class UserMapper:

    def __init__(self, lines):
        """Create a user-mapper from a list of lines.

        Blank lines and comment lines (starting with #) are ignored.
        Otherwise lines are of the form:

          old-id = new-id

        Each id may be in the following forms:

          name <email>
          name

        If old-id has the value '@', then new-id is the domain to use
        when generating an email from a user-id.
        """
        self._parse(lines)

    def _parse(self, lines):
        self._user_map = {}
        self._default_domain = None
        for line in lines:
            line = line.strip()
            if len(line) == 0 or line.startswith(b'#'):
                continue
            old, new = line.split(b'=', 1)
            old = old.strip()
            new = new.strip()
            if old == b'@':
                self._default_domain = new
                continue
            # Parse each id into a name and email address
            old_name, old_email = self._parse_id(old)
            new_name, new_email = self._parse_id(new)
            # print "found user map: %s => %s" % ((old_name, old_email), (new_name, new_email))
            self._user_map[(old_name, old_email)] = (new_name, new_email)

    def _parse_id(self, id):
        if id.find(b'<') == -1:
            return id, b""
        else:
            return parseaddr(id)

    def map_name_and_email(self, name, email):
        """Map a name and an email to the preferred name and email.

        :param name: the current name
        :param email: the current email
        :result: the preferred name and email
        """
        try:
            new_name, new_email = self._user_map[(name, email)]
        except KeyError:
            new_name = name
            if self._default_domain and not email:
                new_email = b"%s@%s" % (name, self._default_domain)
            else:
                new_email = email
        return new_name, new_email
     ˆÃÂÉ613ÁÇÆ e    ‹      Õ–QoÚ0Çßû)<?ì.iK·¶ÁSG�†F)j™¦iš*b5±#Û�ÑO?Ó6�Ê–i-ÚàÎäßýÌùìèU|Ñ›|÷Ñ‡Éù�?½z· >ô âIì¶ƒ ?Â§Ö' eY¶Ëƒ¶Òs˜\BjóìŒÕ"±mf&{QõÙCQÊ)sEVØŒ“�dü;R3ja�`Ü½·2ÀøR$ÜT¾å9$Å¢ú ãä<WzõöøÑ0ƒü¤.lâDSÅVUøð¹C¹×tºŽX¹šD6EKš‰¹ìb«
L"‘Ï‘ÑIƒH”40Í¨¼iÏÅ#šÙ.þ:è]|s:°iõ6‰(J5Ÿuñ»^wtzÑ�1ÑœG@ŸÖœ;Í&Cj,Ê3ÁÙVñ•_‰ÛíÆ^s“hQX¡äƒb5Q™)¨cí8‚T×U^Â~·4y´ã³Ëþh.ý’°jŠ‡ìþâ�ÃdL5—ÅBóÄºG*âµœšâônˆ69k1O-&µÐ“Ê? �©Œq]GÝy—¯·õ,Jk?Ø?j…a+<Fá›“à¡Ì!o¤*eÀÕÁ“ JfBrL¼m °¢àè$èlpýæãŠte®}uaR4F	ÿ)Q5¾ÉÚoâ¾_¤ù¦(TÉµÛÞ>Gþ;ÞÚµ£euT`rï6¯§í{{Çõd,µam¦ßùUkÚm™ÅtsX8„{ÿ?l±¾tg&Þ>ÀŽë¨šˆ]ß*É&µÁËw¦†·ØÜë"X_ #ð÷×4a¨"    $   ˆÃÂÉ605Áa–Ü4ý( ©¤ýÔâ€nàƒp©‹FÿÇ ]    ‹      Õ–ßoÚ0ÇßûWx~Ø¡Œ®4xêH¥¡RŠZ¦iš¦ÊÄ†XMìÈ60ú×ÏÁi›NE£­ØwG¾¹»�ã_á»è²7þ>:C_Æ4úúyÐï!\øvØˆÆ‘Ðª7€³!F8±6ï ,—Ëúò°®ôÆW�Ø,m�±ZÄ¶Î,Ãä ,þ#(L8eÎ¢Ð
›rÒ—ŒÿBjŠ@Í­Œ»÷V_ˆ˜›Â·<ƒŒgJ¯J4Û ã�2n=	�Cð¹]5(Ë…ÅVEÁ+Ut‰×Pt².\¸š„6AšŠ™ìb«rLB‘Í�Ñqƒˆ•40I©¼­ÏÄ#šÚ.þÑï]þt:°Iñ6	)J4Ÿvñ§^wxrÙ�0ÒŒ‡@Ÿ×\8Í)&j,ÊSÁÙFñµ_‹»Í	#¯‰¸‰µÈ­PòQ
±Š«ÔäÔ±~p‰®ª¼„ým4hüd0F§WgÃqÔ¿òCÂŠ�Ýíàûa2¢šK‹"¡ylÝ£’Î—z/'&?¹QÙ»³Äb‚P=«|ðT¥Œë*ò&Øû~½­vùG[ÍF³]‚ZpŒ‚£N£�Ð+ö?—·R-eÀÍ‡g”L…ä˜x»@3@�v§ÑÚàv¡ó7È“•¹ñ³“J°5ŠûÝ'Qìƒ%ÉÚß�íE®–\»Eáí.úãE¡Ýv´(ŽLÜ}ù/À0–Z‡°6ûÒþö³ÈÌ'å¡áüÿp‹�ó…;Ë0ñv o<�ŠDìæNIn0©ÛŸÿeË[”÷»Ö÷Éü­ö7EK8    7   ˆl–Ü4ý( ©¤