ó
[³XMc           @   s?   d  Z  d g Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d S(   sM   
L{twisted.python.fakepwd} provides a fake implementation of the L{pwd} API.
t   UserDatabaset   _UserRecordc           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s¯   
    L{_UserRecord} holds the user data for a single user in L{UserDatabase}.
    It corresponds to L{pwd.struct_passwd}.  See that class for attribute
    documentation.
    c         C   sC   | |  _  | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ d  S(   N(   t   pw_namet	   pw_passwdt   pw_uidt   pw_gidt   pw_gecost   pw_dirt   pw_shell(   t   selft   namet   passwordt   uidt   gidt   gecost   homet   shell(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyt   __init__   s    						c         C   s   d S(   Ni   (    (   R	   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyt   __len__   s    c         C   s2   |  j  |  j |  j |  j |  j |  j |  j f | S(   N(   R   R   R   R   R   R   R   (   R	   t   index(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyt   __getitem__!   s    (   t   __name__t
   __module__t   __doc__R   R   R   (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyR      s   	
	c           B   s;   e  Z d  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   sí   
    L{UserDatabase} holds a traditional POSIX user data in memory and makes it
    available via the same API as L{pwd}.

    @ivar _users: A C{list} of L{_UserRecord} instances holding all user data
        added to this database.
    c         C   s   g  |  _  d  S(   N(   t   _users(   R	   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyR   0   s    c      	   C   s,   |  j  j t | | | | | | | ƒ ƒ d S(   s§  
        Add a new user record to this database.

        @param username: The value for the C{pw_name} field of the user
            record to add.
        @type username: C{str}

        @param password: The value for the C{pw_passwd} field of the user
            record to add.
        @type password: C{str}

        @param uid: The value for the C{pw_uid} field of the user record to
            add.
        @type uid: C{int}

        @param gid: The value for the C{pw_gid} field of the user record to
            add.
        @type gid: C{int}

        @param gecos: The value for the C{pw_gecos} field of the user record
            to add.
        @type gecos: C{str}

        @param home: The value for the C{pw_dir} field of the user record to
            add.
        @type home: C{str}

        @param shell: The value for the C{pw_shell} field of the user record to
            add.
        @type shell: C{str}
        N(   R   t   appendR   (   R	   t   usernameR   R   R   R   R   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyt   addUser4   s     c         C   s4   x$ |  j  D] } | j | k r
 | Sq
 Wt ƒ  ‚ d S(   sH   
        Return the user record corresponding to the given uid.
        N(   R   R   t   KeyError(   R	   R   t   entry(    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyt   getpwuidX   s    c         C   s4   x$ |  j  D] } | j | k r
 | Sq
 Wt ƒ  ‚ d S(   sM   
        Return the user record corresponding to the given username.
        N(   R   R   R   (   R	   R
   R   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyt   getpwnamb   s    c         C   s   |  j  S(   s4   
        Return a list of all user records.
        (   R   (   R	   (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyt   getpwalll   s    (   R   R   R   R   R   R   R   R    (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyR    (   s   		$	
	
N(   R   t   __all__t   objectR   R    (    (    (    s:   /usr/lib/python2.7/dist-packages/twisted/python/fakepwd.pyt   <module>   s   	