
    kd(                         d Z dZdZddlZddlZddlZddlZddlZddlZddl	m
Z
 ej                  dk\  rdZndZd	 Zej                  d
        Z G d de      Zd Zy)z|Module with little helper functions and classes:

deprecated - decorator to emit a warning if a depreacted function is used
z%Sebastian Heinlein <devel@glatzor.de>)
deprecatedIsoCodes    N)ElementTree3gettextugettextc                 B     t        j                          fd       }|S )zThis is a decorator which can be used to mark functions
    as deprecated. It will result in a warning being emitted
    when the function is used.

    Taken from http://wiki.python.org/moin/PythonDecoratorLibrary
    #GeneratingDeprecationWarnings
    c                      t        j                  ddj                  iz  t        j                  j
                  j                  j                  dz           | i |S )Nz)Call to deprecated function %(funcname)s.funcname   )categoryfilenamelineno)warningswarn_explicit__name__DeprecationWarning__code__co_filenameco_firstlineno)argskwargsfuncs     1/usr/lib/python3/dist-packages/aptdaemon/utils.pynew_funczdeprecated.<locals>.new_func1   s]    7DMM;  (]]..==//!3	
 T$V$$    )	functoolswraps)r   r   s   ` r   r   r   )   s'     __T	% 	% Or   c              #     K   t        j                         dk7  rt        j                         dk7  rd  y t        j                  |       t        j                         }t        j
                  |g       t        j                  |        	 d  t        j                  t        j                                t        j                  t        j                                t        j
                  |       y # t        j                  t        j                                t        j                  t        j                                t        j
                  |       w xY ww)Nr   )osgetuidgetgidsetegid	getgroups	setgroupsseteuid)uidgid
old_groupss      r   set_euid_egidr*   ?   s      
yy{aBIIK1,JJsOJLL#JJsO!


299;


299;
Z  	

299;


299;
Z s    BEC3 A$E3A%EEc                   $    e Zd ZdZddZd Zd Zy)r   zPProvides access to the iso-codes language, script and country
    database.
    Nc                     d|z  }t        j                   |      }i | _        || _        t        |j	                               D ]I  }|j                  |      }|s|r|j                  |      }|s,|j                  d      | j                  |<   K y )Nz/usr/share/xml/iso-codes/%s.xml)filename)r   _dictnormlistiterget)selfr0   tagfallback_tagr   etelementiso_codes           r   __init__zIsoCodes.__init__X   s~    4t;$$(3
	BGGI 	;G{{3'H";;|4'.{{6':

8$	;r   c                     	 | j                   |   }t        j                  | j                  d|g      } t        |t              |      S # t        $ r Y y w xY w)NT)domainfallback	languages)r/   KeyErrorr   translationr0   getattr_gettext_method)r4   valuelocaler.   transs        r   get_localised_namezIsoCodes.get_localised_named   s\    	::e$D ##499t/5h8.wuo.t44	  		s   A
 
	AAc                 @    	 | j                   |   S # t        $ r Y y w xY wN)r/   r?   )r4   rC   s     r   get_namezIsoCodes.get_namem   s(    	::e$$ 		s    	rH   )r   
__module____qualname____doc__r:   rF   rI    r   r   r   r   R   s    
;5r   r   c                     d| v r| j                  dd      \  }}d}n"d| v r| j                  dd      \  }}d}n| }dx}}|||fS )zQReturn the name, the version number and the release of the
    specified package.=r   N/)split)packager.   versionreleases       r   split_package_idrU   t   s`     g~c1-g	c1-g  ''!!r   )rL   
__author____all__r    sys
contextlibr   r   r   	xml.etreer   rS   rB   r   contextmanagerr*   objectr   rU   rM   r   r   <module>r]      sr   , 5

$ 	 
     !;;#O O, ! !$v D"r   