
    _Og                     j    S r SSKJrJrJrJr  SSKJr  SSKJ	r	  SSK
JrJrJrJrJr   " S S\5      rg)	z^
This module provides the Character class, used to store information about
a given character.
    )absolute_importdivisionprint_functionunicode_literals)deepcopy)IMDbParserError)
_Containeranalyze_name
build_name	cmpPeopleflattenc                       \ rS rSrSrSrSSSSSSSSSSSSS.rS	r\r	S
 r
S rS rS rS rS rS rS rS r\rS rS rS rS rSrg)	Character   a2  A Character.

Every information about a character can be accessed as::

    characterObject['information']

to get a list of the kind of information stored in a
Character object, use the keys() method; some useful aliases
are defined (as "also known as" for the "akas" key);
see the keys_alias dictionary.
)mainfilmography	biographyr   akasquoteskeywords)zmini biographybiozcharacter biographyzcharacter biographiesbiographieszcharacter bioakazalso known aszalternate nameszpersonal quoteskeyskeyword)r   r   c                     UR                  S5      nU(       a!  SU R                  ;  a  U R                  U5        UR                  SS5      U l        UR                  SS5      U l        g)a  Initialize a Character object.

*characterID* -- the unique identifier for the character.
*name* -- the name of the Character, if not in the data dictionary.
*myName* -- the nickname you use for this character.
*myID* -- your personal id for this character.
*data* -- a dictionary used to initialize the object.
*notes* -- notes about the given character.
*accessSystem* -- a string representing the data access system used.
*titlesRefs* -- a dictionary with references to movies.
*namesRefs* -- a dictionary with references to persons.
*charactersRefs* -- a dictionary with references to characters.
*modFunct* -- function called returning text fields.
namecharacterIDNmyName )getdataset_namer   r   )selfkwdsr   s      S/Users/admin/workspace/ai/Jarvis/env/lib/python3.13/site-packages/imdb/Character.py_initCharacter._initA   sQ     xxF$))+MM$88M48hhx,    c                      SU l         SU l        g)zReset the Character object.Nr    r   r   r$   s    r&   _resetCharacter._resetV   s    r)   c                 r     [        U5      nU R                  R                  U5        g! [         a     gf = f)zSet the name of the character.N)r
   r"   updater   )r$   r   ds      r&   r#   Character.set_name[   s5    	T"AIIQ 		s   &) 
66c                 b    / nSU R                   ;   a  US/-  nSU R                   ;   a  US/-  nU$ )z-Valid keys to append to the data.keys() list.r   long imdb nameheadshotzfull-size headshot)r"   )r$   addkeyss     r&   _additional_keysCharacter._additional_keysc   s@    TYY())G",--Gr)   c                 Z    SU R                   ;   a  US:X  a  [        U R                   5      $ g)zHandle special keys.r   r4   N)r"   r   )r$   keys     r&   _getitemCharacter._getiteml   s+     TYY&&!$)),,r)   c                     U R                   $ )zReturn the characterID.)r   r,   s    r&   getIDCharacter.getIDt   s    r)   c                 J    [        U R                  R                  S5      5      $ )zBThe Character is "false" if the self.data does not contain a name.r   )boolr"   r!   r,   s    r&   __bool__Character.__bool__x   s     DIIMM&)**r)   c                    SSK J n  SSKJn  [        X5      (       a?  [        U R                  SUS9 H%  nUR                  UR                  5      (       d  M%    g   g[        X5      (       a5  [        U R                  SUS9 H  nUR                  U5      (       d  M    g   g[        U[        5      (       a  XR                  ;   $ g)zjReturn true if this Character was portrayed in the given Movie
or it was impersonated by the given Person.   )Movie)PersonT)yieldDictKeysscalarF)rF   rG   
isinstancer   r"   isSamecurrentRolestr)r$   itemrF   rG   ms        r&   __contains__Character.__contains__}   s     	!"d##TYYd5I;;q}}-- J  $$TYYd5I;;q>> J
  c""99$$r)   c                 T   [        XR                  5      (       d  gSU R                  ;   a;  SUR                  ;   a+  [        U R                  SS9[        UR                  SS9:X  a  gU R                  UR                  :X  a(  U R
                  b  U R
                  UR
                  :X  a  gg)zCReturn true if two character have the same name
and/or characterID.Fr   )	canonicalT)rJ   	__class__r"   r   accessSystemr   )r$   others     r&   
isSameNameCharacter.isSameName   s     %00TYY6UZZ#74996*UZZ[`:aa 2 22  ,  E$5$55r)   c                    [        SU R                  U R                  U R                  [	        U R
                  U5      U R                  U R                  [	        U R                  U5      [	        U R                  U5      [	        U R                  U5      S9
n[        U R                  5      Ul        UR                  U R                  5        U$ )z+Return a deep copy of a Character instance.r    )
r   r   r   myIDr"   notesrU   
titlesRefs	namesRefscharactersRefs)r   r   r   rZ   r   r"   r[   rU   r\   r]   r^   listcurrent_infoset_mod_functmodFunct)r$   memocs      r&   __deepcopy__Character.__deepcopy__   s    24+;+;![[tyy#DIIt4 JJT5F5F!)$//4!@ ( >%-d.A.A4%HJ d//0	&r)   c                 f    SU R                   < SU R                  < SU R                  S5      < S3$ )z,String representation of a Character object.z<Character id:[z] name:_r   z_>)r   rU   r!   r,   s    r&   __repr__Character.__repr__   s*     d//&1A
 	
r)   c                 &    U R                  SS5      $ )zSimply print the short name.r   r    )r!   r,   s    r&   __str__Character.__str__   s    xx##r)   c                 6   U (       d  gSU R                  SS5      -  nU R                  S5      nU(       a  USUS   -  -  nU R                  S5      nU(       a;  USS	  Vs/ s H  oDR                  S
S5      PM     nnUSSR                  U5      -  -  nU$ s  snf )z@Return a string with a pretty-printed summary for the character.r    zCharacter
=====
Name: %s
r   r   zBiography: %s
r   r   N   zlong imdb canonical titlez%Last movies with this character: %s.
z; )r!   join)r$   sr   filmoxa_lists         r&   summaryCharacter.summary   s    *TXXfb-AAhh{#"SV++A'FKBQiPiee7<iFP9DIIf<MMMA Qs    Br+   N)__name__
__module____qualname____firstlineno____doc__default_info
keys_aliaskeys_tomodify_listr   cmpFunctr'   r-   r#   r7   r;   r>   rB   rP   rW   isSameCharacterre   ri   rl   ru   __static_attributes__ r)   r&   r   r      s    
 8L &*!,"$!#J 1H-*
 +
" !O
$r)   r   N)r{   
__future__r   r   r   r   copyr   imdb._exceptionsr   
imdb.utilsr	   r
   r   r   r   r   r   r)   r&   <module>r      s-   "
 S R  , O Ob
 br)   