§
    cÌc‡%  ã                   ó¬   — d Z ddlZddlZddlmZ  e e¦   «         d¦  «         ddlmZ dd„Zd„ Zd	„ Z	d
„ Z
d„ Zd„ Zd„ Zd„ Zd„ Zd„ Zdd„Zd„ Zd„ ZdS )zBFunctions for deriving user configuration from system environment.é    Né   )Úlazy_importzD
from breezy import (
    osutils,
    trace,
    win32utils,
    )
)Úerrorsc                 ó  — | €t          ¦   «         } t          j                             | ¦  «        sÒt          j                             | ¦  «        }t          j                             |¦  «        sIt
                               d|¦  «         t          j        |¦  «         t           	                    |¦  «         t
                               d| ¦  «         t          j        | ¦  «         t           	                    | ¦  «         dS dS )zéMake sure a configuration directory exists.

    This makes sure that the directory exists.
    On windows, since configuration directories are 2 levels deep,
    it makes sure both the directory and the parent directory exists.
    Nz$creating config parent directory: %rzcreating config directory: %r)
Ú
config_dirÚosÚpathÚisdirÚdirnameÚtraceÚmutterÚmkdirÚosutilsÚcopy_ownership_from_path)r	   Ú
parent_dirs     ú0/usr/lib/python3/dist-packages/breezy/bedding.pyÚensure_config_dir_existsr   $   sÙ   € ð €|Ý‰|Œ|ˆÝŒ7�=Š=˜ÑÔð 	/Ý”W—_’_ TÑ*Ô*ˆ
ÝŒw�}Š}˜ZÑ(Ô(ð 	9Ý�LŠLØ6¸
ñDô Dð DåŒH�ZÑ Ô Ð Ý×,Ò,¨ZÑ8Ô8Ð8Ý�ŠÐ4°dÑ;Ô;Ð;Ý
Œ�‰ŒˆÝ×(Ò(¨Ñ.Ô.Ð.Ð.Ð.ð	/ð 	/ó    c                  ó¾  — t           j                             d¦  «        } t          j        dk    rR| €t
                               ¦   «         } | €t
                               ¦   «         } t           	                    | dd¦  «        S | €Àt           j                             d¦  «        }|€2t           	                    t           
                    ¦   «         d¦  «        }t           	                    |d¦  «        }t                               |¦  «        rt                               d|z  ¦  «         |S t           
                    ¦   «         } t           	                    | d	¦  «        S )
a;  Return per-user configuration directory as unicode string

    By default this is %APPDATA%/bazaar/2.0 on Windows, ~/.bazaar on Mac OS X
    and Linux.  On Mac OS X and Linux, if there is a $XDG_CONFIG_HOME/bazaar
    directory, that will be used instead

    TODO: Global option --config-dir to override this.
    ÚBZR_HOMEÚwin32NÚbazaarz2.0ÚXDG_CONFIG_HOMEú.configz(Using configuration in XDG directory %s.z.bazaar)r   ÚenvironÚgetÚsysÚplatformÚ
win32utilsÚget_appdata_locationÚget_home_locationr   ÚpathjoinÚ_get_home_dirr
   r   r   )ÚbaseÚxdg_dirs     r   Úbazaar_config_dirr&   9   s  € õ Œ:�>Š>˜*Ñ%Ô%€DÝ
„|�wÒÐØˆ<Ý×2Ò2Ñ4Ô4ˆDØˆ<Ý×/Ò/Ñ1Ô1ˆDÝ×Ò  h°Ñ6Ô6Ð6Ø€|Ý”*—.’.Ð!2Ñ3Ô3ˆØˆ?Ý×&Ò&¥w×'<Ò'<Ñ'>Ô'>À	ÑJÔJˆGÝ×"Ò" 7¨HÑ5Ô5ˆÝ�=Š=˜Ñ!Ô!ð 	Ý�LŠLØ:¸WÑDñFô Fð FàˆNÝ×$Ò$Ñ&Ô&ˆÝ×Ò˜D )Ñ,Ô,Ð,r   c                  ój  — t           j                             d¦  «        } t          j        dk    r,| €t
                               ¦   «         } | €t          d¦  «        ‚| €St           j                             d¦  «        } | €2t           	                    t           
                    ¦   «         d¦  «        } t           	                    | d¦  «        }t                               |¦  «        r|dfS t          ¦   «         }t                               |¦  «        rt                               d|¦  «         |d	fS |dfS )
á  Return per-user configuration directory as unicode string

    By default this is %APPDATA%/breezy on Windows, $XDG_CONFIG_HOME/breezy on
    Mac OS X and Linux. If the breezy config directory doesn't exist but
    the bazaar one (see bazaar_config_dir()) does, use that instead.
    ÚBRZ_HOMEr   Nz$Unable to determine AppData locationr   r   Úbreezyz)Using Bazaar configuration directory (%s)r   )r   r   r   r   r   r   r    ÚRuntimeErrorr   r"   r#   r
   r&   r   r   )r$   Ú
breezy_dirÚ
bazaar_dirs      r   Ú_config_dirr.   V   s  € õ Œ:�>Š>˜*Ñ%Ô%€DÝ
„|�wÒÐØˆ<Ý×2Ò2Ñ4Ô4ˆDØˆ<õ ÐEÑFÔFÐFà€|ÝŒz�~Š~Ð/Ñ0Ô0ˆØˆ<Ý×#Ò#¥G×$9Ò$9Ñ$;Ô$;¸YÑGÔGˆDÝ×!Ò! $¨Ñ1Ô1€JÝ‡}‚}�ZÑ Ô ð &Ø˜HÐ%Ð%å"Ñ$Ô$€JÝ‡}‚}�ZÑ Ô ð &Ý�ŠØ7¸ñ	Eô 	Eð 	Eà˜HÐ%Ð%Ø˜Ð!Ð!r   c                  ó*   — t          ¦   «         d         S )r(   r   )r.   © r   r   r   r   z   s   € õ ‰=Œ=˜ÔÐr   c                  óœ   — t          ¦   «         \  } }|dk    rt                               | d¦  «        S t                               | d¦  «        S )ú0Return per-user configuration ini file filename.r   zbazaar.confzbreezy.conf)r.   r   r"   )r	   Úkinds     r   Úconfig_pathr4   „   sF   € å‘”�J€Dˆ$ØˆxÒÐÝ×Ò  mÑ4Ô4Ð4å×Ò  mÑ4Ô4Ð4r   c                  óP   — t                                t          ¦   «         d¦  «        S )r2   zlocations.conf©r   r"   r   r0   r   r   Úlocations_config_pathr7   �   s   € å×Ò�J™LœLÐ*:Ñ;Ô;Ð;r   c                  óP   — t                                t          ¦   «         d¦  «        S )ú1Return per-user authentication ini file filename.zauthentication.confr6   r0   r   r   Úauthentication_config_pathr:   ’   s   € å×Ò�J™LœLÐ*?Ñ@Ô@Ð@r   c                  óP   — t                                t          ¦   «         d¦  «        S )r9   Úignorer6   r0   r   r   Úuser_ignore_config_pathr=   —   s   € å×Ò�J™LœL¨(Ñ3Ô3Ð3r   c                  ó°   — t           j        dk    r't                               t	          ¦   «         d¦  «        S t
          j                             dd¦  «        S )zúReturn the directory name to store crash files.

    This doesn't implicitly create it.

    On Windows it's in the config directory; elsewhere it's /var/crash
    which may be monitored by apport.  It can be overridden by
    $APPORT_CRASH_DIR.
    r   ÚCrashÚAPPORT_CRASH_DIRz
/var/crash)r   r   r   r"   r   r   r   r   r0   r   r   Ú	crash_dirrA   œ   sD   € õ „|�wÒÐÝ×Ò¥
¡¤¨gÑ6Ô6Ð6õ Œz�~Š~Ð0°,Ñ?Ô?Ð?r   c                  ó  — t           j                             d¦  «        } t          j        dv r7| €t
                               ¦   «         } | €t
                               ¦   «         } nSt           j                             d¦  «        } | €2t           	                    t           
                    ¦   «         d¦  «        } t           	                    | d¦  «        }t           j                             |¦  «        st          j        |¦  «         |S )z"Return the cache directory to use.r)   r   NÚXDG_CACHE_HOMEz.cacher*   )r   r   r   r   r   r   Úget_local_appdata_locationr!   r   r"   r#   r	   ÚexistsÚmakedirs)r$   Ú	cache_dirs     r   rG   rG   ­   sÌ   € åŒ:�>Š>˜*Ñ%Ô%€DÝ
„|�wÐÐØˆ<Ý×8Ò8Ñ:Ô:ˆDØˆ<Ý×/Ò/Ñ1Ô1ˆDøåŒz�~Š~Ð.Ñ/Ô/ˆØˆ<Ý×#Ò#¥G×$9Ò$9Ñ$;Ô$;¸XÑFÔFˆDå× Ò   xÑ0Ô0€Iõ Œ7�>Š>˜)Ñ$Ô$ð Ý
Œ�IÑÔÐàÐr   ú/etc/mailnamec                 ó  — t           j        dk    rdS 	 t          | ¦  «        }n# t          $ r Y dS w xY w	 |                     ¦   «                              ¦   «         }||                     ¦   «          S # |                     ¦   «          w xY w)zfIf possible, return the assumed default email domain.

    :returns: string mail domain, or None.
    r   N)r   r   ÚopenÚOSErrorÚreadlineÚstripÚclose)Úmailname_fileÚfÚdomains      r   Ú_get_default_mail_domainrR   Ã   sŽ   € õ
 „|�wÒÐàˆtðÝ�ÑÔˆˆøÝð ð ð ØˆtˆtðøøøðØ—’‘”×#Ò#Ñ%Ô%ˆØà	�Š‰	Œ	ˆ	ˆ	øˆ�Š‰	Œ	ˆ	ˆ	øøøs   ”$ ¤
2±2¶'A2 Á2Bc                  ó  — t           j                             d¦  «        } | r| S t           j                             d¦  «        } | r| S t          ¦   «         \  }}|r|rd                     ||¦  «        S |r|S t          j        ¦   «         ‚)NÚ	BRZ_EMAILÚEMAILz{} <{}>)r   r   r   Ú_auto_user_idÚformatr   ÚNoWhoami)ÚvÚnameÚemails      r   Údefault_emailr\   Ö   s�   € Ý
Œ
�Š�{Ñ#Ô#€AØð ØˆÝ
Œ
�Š�wÑÔ€AØð ØˆÝ‘/”/�K€Dˆ%Øð �ð Ø×Ò  eÑ,Ô,Ð,Ø	ð ØˆÝ
Œ/Ñ
Ô
Ðr   c                  óp  — t           j        dk    rdS t          ¦   «         } | sdS ddl}t	          j        ¦   «         }	 |                     |¦  «        }n.# t          $ r! t           	                    d|z  ¦  «         Y dS w xY w|j
        }t          |t          ¦  «        rˆ	 |                     d¦  «        }d}no# t          $ rb 	 t                               ¦   «         }|                     |¦  «        }n/# t          $ r" t           	                    d|z  ¦  «         Y Y dS w xY wY nw xY w|j        }t          |t          ¦  «        rE	 |                     |¦  «        }n.# t          $ r! t           	                    d|z  ¦  «         Y dS w xY w|                     d¦  «        }|d	k    r|}n
|d|…         }||d
z   | z   fS )a  Calculate automatic user identification.

    :returns: (realname, email), either of which may be None if they can't be
    determined.

    Only used when none is set in the environment or the id file.

    This only returns an email address if we can be fairly sure the
    address is reasonable, ie if /etc/mailname is set on unix.

    This doesn't use the FQDN as the default domain because that may be
    slow, and it doesn't use the hostname alone because that's not normally
    a reasonable address.
    r   )NNr   Nzno passwd entry for uid %d?zutf-8zcannot decode passwd entry %sú,éÿÿÿÿú@)r   r   rR   Úpwdr   ÚgetuidÚgetpwuidÚKeyErrorr   r   Úpw_gecosÚ
isinstanceÚbytesÚdecodeÚUnicodeErrorr   Úget_user_encodingÚpw_nameÚfind)	Údefault_mail_domainra   ÚuidÚwÚgecosÚencodingÚusernameÚcommaÚrealnames	            r   rV   rV   å   s  € õ „|�wÒÐð ˆzå2Ñ4Ô4ÐØð Øˆzà€J€J€JÝ
Œ)‰+Œ+€CðØ�LŠL˜ÑÔˆˆøÝð ð ð Ý�ŠÐ2°SÑ8Ñ9Ô9Ð9Øˆzˆzðøøøð ŒJ€EÝ�%�ÑÔð 
"ð		"Ø—L’L Ñ)Ô)ˆEØˆHˆHøÝð 	"ð 	"ð 	"ð"Ý"×4Ò4Ñ6Ô6�ØŸš XÑ.Ô.��øÝð "ð "ð "Ý—’Ð<¸qÑ@ÑAÔAÐAØ!�z�z�zð"øøøð �ð	"øøøð Œy€HÝ�(�EÑ"Ô"ð ð	Ø—’ xÑ0Ô0ˆHˆHøÝð 	ð 	ð 	Ý�LŠLÐ8¸1Ñ<Ñ=Ô=Ð=Ø�:�:ð	øøøð �JŠJ�s‰OŒO€EØ�‚{€{Øˆˆà˜˜%˜”=ˆà�h ‘nÐ':Ñ:Ð;Ð;sY   ½A Á'A>Á=A>ÂB6 Â6
D"Ã.C0Ã/D"Ã0'DÄD"ÄDÄD"Ä!D"ÅE Å'FÆF)N)rH   )Ú__doc__r   r   r   ÚglobalsÚ r   r   r&   r.   r   r4   r7   r:   r=   rA   rG   rR   r\   rV   r0   r   r   ú<module>rx      sO  ðð$ IÐ Hà 	€	€	€	Ø 
€
€
€
à $Ð $Ð $Ð $Ð $Ð $Ø €ˆGˆG‰IŒIð ñ ô ð ðð ð ð ð ð ð
/ð /ð /ð /ð*-ð -ð -ð:!"ð !"ð !"ðHð ð ð5ð 5ð 5ð<ð <ð <ð
Að Að Að
4ð 4ð 4ð
@ð @ð @ð"ð ð ð,ð ð ð ð&ð ð ð?<ð ?<ð ?<ð ?<ð ?<r   