code: def unlock(self):
          '''Unlock card with SCardEndTransaction.'''
          component = self.component
          while True:
              if isinstance(
                      component,
                      smartcard.pcsc.PCSCCardConnection.PCSCCardConnection):
                  hresult = SCardEndTransaction(component.hcard,
                                                SCARD_LEAVE_CARD)
                  if 0 != hresult:
                      raise CardConnectionException(
                          'Failed to unlock with SCardEndTransaction: ' +
                          SCardGetErrorMessage(hresult))
                  else:
                      # print('unlocked')
                      pass
                  break
              if hasattr(component, 'component'):
                  component = component.component
              else:
                  breaf unlock(self):
          '''Unlock card with SCardEndTransaction.'''
          component = self.component
          while True:
              if isinstance(
                      component,
                      smartcard.pcsc.PCSCCardConnection.PCSCCardConnection):
                  hresult = SCardEndTransaction(component.hcard,
                                                SCARD_LEAVE_CARD)
                  if 0 != hresult:
                      raise CardConnectionException(
                          'Failed to unlock with SCardEndTransaction: ' +
                          SCardGetErrorMessage(hresult))
                  else:
                      # print('unlocked')
                      pass
                  break
              if hasattr(component, 'component'):
                  component = component.component
              else:
                  break
docs: Unlock card with SCardEndTransaction.