
    |`*                     f    d Z ddlmZmZmZmZ ddlmZ ddlm	Z	m
Z
mZmZmZmZmZ  G d de	      Zy)zX
This module provides the Person class, used to store information about
a given person.
    )absolute_importdivisionprint_functionunicode_literals)deepcopy)
_Containeranalyze_name
build_name	cmpPeopleflattennormalizeNamecanonicalNamec                   ^   e Zd ZdZdZi ddddddddd	d
dd
dd
dd
ddddddddddddddddddi ddddddd dd!d"d#d$d%d&d'd(d)d(d*d+d,d-d.d/d0d1d1d1d2d1d3d1d4d5d6d6d7d7d8d/d9Zd:Zd;ZeZ	d< Z
d= Zd> Zd? Zd@ ZdA ZdB ZdC ZdD ZdE ZeZdF ZdG ZdH ZdI ZyJ)KPersonaH  A Person.

    Every information about a person can be accessed as::

        personObject['information']

    to get a list of the kind of information stored in a
    Person object, use the keys() method; some useful aliases
    are defined (as "biography" for the "mini biography" key);
    see the keys_alias dictionary.
    )mainfilmography	biographyr   mini biographybioakaakaszalso known asz	nick namez
nick namesnicksnickname	nicknamesmiscellaneouscrewzmiscellaneous crewcrewmembersmiscguestznotable tv guest appearancesguestsztv guestzguest appearancesspousesspousesalarysalary historysalaries
otherworksother workszmaltin's biography2biography from leonard maltin's movie encyclopediazleonard maltin's biographyz	real namez
birth namezwhere are they now	where nowzpersonal quotesquoteszmini-biography authorzimdb mini-biography byzbiography authorgenregenres	portrayedportrayed inkeyskeywords
trademarks
trade markztrade marks	trademark
pictorials	pictorialzmagazine cover photoepisodesarticle)zmagazine coverszmagazine-coversztv series episodesztv-series episodesarticleskeyword)r   r!   r)   r&   r#   triviar1   newsbookszbiographical moviesr-   r(   
interviewsr6   r'   headshotc                     |j                  d      }|rd| j                  vr| j                  |       |j                  dd      | _        |j                  dd      | _        |j                  dd      | _        y)a  Initialize a Person object.

        *personID* -- the unique identifier for the person.
        *name* -- the name of the Person, if not in the data dictionary.
        *myName* -- the nickname you use for this person.
        *myID* -- your personal id for this person.
        *data* -- a dictionary used to initialize the object.
        *currentRole* -- a Character instance representing the current role
                         or duty of a person in this movie, or a Person
                         object representing the actor/actress who played
                         a given character in a Movie.  If a string is
                         passed, an object is automatically build.
        *roleID* -- if available, the characterID/personID of the currentRole
                    object.
        *roleIsPerson* -- when False (default) the currentRole is assumed
                          to be a Character object, otherwise a Person.
        *notes* -- notes about the given person for a specific movie
                    or role (e.g.: the alias used in the movie credits).
        *accessSystem* -- a string representing the data access system used.
        *titlesRefs* -- a dictionary with references to movies.
        *namesRefs* -- a dictionary with references to persons.
        *modFunct* -- function called returning text fields.
        *billingPos* -- position of this person in the credits list.
        namepersonIDNmyName 
billingPos)getdataset_namer@   rA   rC   )selfkwdsr?   s      -/usr/lib/python3/dist-packages/imdb/Person.py_initzPerson._inite   sb    2 xxF$))+MM$T2hhx,((<6    c                 .    d| _         d| _        d| _        y)zReset the Person object.NrB   )r@   rA   rC   rG   s    rI   _resetzPerson._reset   s    rK   c                     d| _         y)zReset the dictionary.N)rC   rM   s    rI   _clearzPerson._clear   s	    rK   c                 T    t        |d      }| j                  j                  |       y)zSet the name of the person.F	canonicalN)r	   rE   update)rG   r?   ds      rI   rF   zPerson.set_name   s     /		rK   c                 \    g }d| j                   v r|g dz  }d| j                   v r|dgz  }|S )z-Valid keys to append to the data.keys() list.r?   )canonical namelong imdb namelong imdb canonical namer=   full-size headshotrE   )rG   addkeyss     rI   _additional_keyszPerson._additional_keys   sA    TYY 4 4G",--GrK   c                    d| j                   v rr|dk(  rt        | j                   d         S |dk(  rt        | j                   d         S |dk(  rt        | j                   d      S |dk(  rt        | j                   d      S |dk(  r| j	                         S || j                   vr0|| j                   j                  d	i       v r| j                   d	   |   S y
)zHandle special keys.r?   rW   rX   FrR   rY   TrZ   r   N)rE   r   r   r
   get_fullsizeURLrD   )rG   keys     rI   _getitemzPerson._getitem   s    TYYf}$TYYv%677(($TYYv%677((!$))u==22!$))t<<&&''))		!cTYY]]="-M&M99]+C00rK   c                     | j                   S )zReturn the personID.)r@   rM   s    rI   getIDzPerson.getID   s    }}rK   c                     d| j                   v S )z?The Person is "false" if the self.data does not contain a name.r?   r[   rM   s    rI   __bool__zPerson.__bool__   s     ""rK   c                 `   ddl m } ddlm} t        ||      r1t        | j                  d|      D ]  }|j                  |      s y yt        ||      r;t        | j                  d|      D ]  }|j                  |j                        s y yt        |t              r|| j                  v S y)zvReturn true if this Person has worked in the given Movie,
        or if the fiven Character was played by this Person.   )Movie)	CharacterT)yieldDictKeysscalarF)rh   ri   
isinstancer   rE   isSamecurrentRolestr)rG   itemrh   ri   ms        rI   __contains__zPerson.__contains__   s     	!(dE"TYYd5I  ;;q>   i(TYYd5I  ;;q}}- 
  c"499$$rK   c                 H   t        || j                        syd| j                  v r>d|j                  v r0t        | j                  d      t        |j                  d      k(  ry| j                  |j                  k(  r&| j
                  r| j
                  |j
                  k(  ryy)z]Return true if two persons have the same name and imdbIndex
        and/or personID.
        Fr?   TrR   )rl   	__class__rE   r
   accessSystemr@   )rG   others     rI   
isSameNamezPerson.isSameName   s     %0TYY%**$49955::67 2 22$--5>>"ArK   c                     t        d| j                  | j                  | j                  t	        | j
                  |      t	        | j                  |      | j                  | j                  | j                  t	        | j                  |      t	        | j                  |      t	        | j                  |            }t        | j                        |_        |j                  | j                          | j"                  |_        |S )z(Return a deep copy of a Person instance.rB   )r?   r@   rA   myIDrE   rn   roleIsPersonnotesru   
titlesRefs	namesRefscharactersRefs)r   r@   rA   ry   r   rE   rn   _roleIsPersonr{   ru   r|   r}   r~   listcurrent_infoset_mod_functmodFunctrC   )rG   memops      rI   __deepcopy__zPerson.__deepcopy__   s    T]]4;;		D(A'(8(8$? $ 2 2$2C2C&t=%dnnd;"*4+>+>"EG d//0	&rK   c                 `    d| j                   d| j                  d| j                  d      dS )z)String representation of a Person object.z<Person id:[z] name:_rX   z_>)r@   ru   rD   rM   s    rI   __repr__zPerson.__repr__   s)     MM4,,dhh7G.H
 	
rK   c                 &    | j                  dd      S )zSimply print the short name.r?   rB   )rD   rM   s    rI   __str__zPerson.__str__   s    xx##rK   c                    | syd| j                  dd      z  }| j                  d      }|r(|d|z  z  }| j                  d      }|r|d|z  z  }|dz  }| j                  d	      }|r(|d
|z  z  }| j                  d      }|r|d|z  z  }|dz  }| j                  d      }|r|d|d   z  z  }| j                  d      }|r9|dd D cg c]  }|j                  dd       }	}|ddj                  |	      z  z  }| j                  d      xs | j                  d      }
|
r9|
dd D cg c]  }|j                  dd       }}|ddj                  |      z  z  }|S c c}w c c}w )z=Return a string with a pretty-printed summary for the person.rB   zPerson
=====
Name: %s
rY   z
birth datezBirth date: %szbirth notesz (%s)z.
z
death datezDeath date: %szdeath notesr   zBiography: %s
r   directorN   zlong imdb canonical titlezLast movies directed: %s.
z; actoractress   zLast movies acted: %s.
)rD   join)rG   sbdatebnotesddatednotesr   r   xd_listacta_lists               rI   summaryzPerson.summary   s   '$((3Mr*RR&!E))AXXm,FWv%%JA&!E))AXXm,FWv%%JAhh'("SV++A88J'FNrPQlSaee7<SFS.61BBBAhhw6488I#6FI"1gNaee7<NFN+dii.???A T Os   E&EN)__name__
__module____qualname____doc__default_info
keys_aliaskeys_tomodify_list
_image_keyr   cmpFunctrJ   rN   rP   rF   r]   ra   rc   re   rr   rw   isSamePersonr   r   r   r    rK   rI   r   r      s<   
 8L)%)) 	v) 		)
 	\) 	) 	L) 	\) 	1) 	+) 	$) 	/) 	0) 	2) 	;)  	8!)" 	"#)$ 	$%)& 	m')( 	R))* 	%&Z+), 	\-). 	k/)0 	81)2 	 !93)4 	45)6 	7)8 	^9): 	
;)< 	l=)> 	l?)@ 	|A)B 	\C)D 	kE)F 21((Q)JX JH7@
"#
"  L
$rK   r   N)r   
__future__r   r   r   r   copyr   
imdb.utilsr   r	   r
   r   r   r   r   r   r   rK   rI   <module>r      s-   "
 S R  m m mvZ vrK   