+
     h  c                   sZ    R t ^ RIHtHt ^ RIHt ^ RIHt  ! R R4      t]	R8X  d    R# R# )ai  
Smartcard Session.

__author__ = "https://www.gemalto.com/"

Copyright 2001-2012 gemalto
Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com

This file is part of pyscard.

pyscard is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

pyscard is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License
along with pyscard; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
)InvalidReaderExceptionNoReadersException)PassThruCardService)readersc                   sF   a  ] tR t^t o RtR	R ltR tR tR tR t	Rt
V tR# )
Sessiona  The Session object enables programmers to transmit APDU to smartcards.

This is an example of use of the Session object:

>>> import smartcard
>>> reader=smartcard.listReaders()
>>> s = smartcard.Session(reader[0])
>>> SELECT = [0xA0, 0xA4, 0x00, 0x00, 0x02]
>>> DF_TELECOM = [0x7F, 0x10]
>>> data, sw1, sw2 = s.sendCommandAPDU(SELECT+DF_TELECOM)
>>> print(data, sw1, sw2)
>>> s.close()
>>> print(`s`)
Nc                sD   VfT   \        \        4       4      ^ 8  d2   \        4       ^ ,          V n        \        V P                  4      V n        MS\        4       hWn        \        4        F5  pV\        V4      8X  g   K  W0n        \        V P                  4      V n        K7  	   V P                   T P                  P                  4       p\        T4      T n        T P                  P                  P                  4        R#   \         d    \        T P                  4      hi ; i)zSession constructor. Initializes a smart card session and
connect to the card.

@param readerName: reader to connect to; default is first PCSC reader
@param cardServiceClass: card service to bind the session to; default
                    is None
N)lenr   readerZrepr
readerNamer   ZstrZAttributeErrorr    ZcreateConnectionr   cs
connectionZconnect)selfr   ZcardServiceClassr   Zccs   &&&  8/usr/lib64/python3.14/site-packages/smartcard/Session.py__init__ZSession.__init__/   s     79~!%il"&t{{"3(** )O!)V,"(K&*4;;&7DO $
	:KK
 [[))+%b)""$  	:(99	:s   "C> >!Dc                sN    V P                   P                  P                  4        R# )zNClose the smartcard session.

Closing a session will disconnect from the card.N)r   r	   Z
disconnectr
      &r   closeZSession.closeR   s     	%%'    c                s    V P                   P                  P                  V4      w  r#p\        V4      ^8  d#   VP	                  V4       VP	                  V4       W#V3# )zSend an APDU command to the connected smartcard.

@param command: list of APDU bytes, e.g. [0xA0, 0xA4, 0x00, 0x00, 0x02]

@return: a tuple (response, sw1, sw2) where
        response is the APDU response
        sw1, sw2 are the two status words
)r   r	   Ztransmitr   Zappend)r
   ZcommandZresponseZsw1Zsw2s   &&   r   sendCommandAPDUZSession.sendCommandAPDUX   sR     "WW//88Asx=1OOC OOC c!!r   c                sJ    V P                   P                  P                  4       # )z&Returns the ATR of the connected card.)r   r	   getATRr   r   r   r   ZSession.getATRi   s    ww!!((**r   c                s(    RV P                   ,          # )z/Returns a string representation of the session.z!<Session instance: readerName=%s>)r   r   r   r   __repr__ZSession.__repr__m   s    2T__DDr   )r   r   r   )NN)__name__Z
__module__Z__qualname__Z__firstlineno____doc__r   r   r   r   r   Z__static_attributes__Z__classdictcell__)Z__classdict__s   @r   r   r      s+     !%F(""+E Er   r   Z__main__N)
r   Zsmartcard.Exceptionsr    r   Zsmartcard.PassThruCardServicer   Zsmartcard.Systemr   r   r   ) r   r   <module>r      s:   2 L = $PE PEf z: r   