Package smartcard :: Package sw :: Module ErrorChecker
[hide private]
[frames] | no frames]

Source Code for Module smartcard.sw.ErrorChecker

 1  """Base class for status word error checkers. 
 2   
 3  __author__ = "http://www.gemalto.com" 
 4   
 5  Copyright 2001-2012 gemalto 
 6  Author: Jean-Daniel Aussel, mailto:jean-daniel.aussel@gemalto.com 
 7   
 8  This file is part of pyscard. 
 9   
10  pyscard is free software; you can redistribute it and/or modify 
11  it under the terms of the GNU Lesser General Public License as published by 
12  the Free Software Foundation; either version 2.1 of the License, or 
13  (at your option) any later version. 
14   
15  pyscard is distributed in the hope that it will be useful, 
16  but WITHOUT ANY WARRANTY; without even the implied warranty of 
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
18  GNU Lesser General Public License for more details. 
19   
20  You should have received a copy of the GNU Lesser General Public License 
21  along with pyscard; if not, write to the Free Software 
22  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA 
23  """ 
24   
25   
26 -class ErrorChecker(object):
27 """Base class for status word error checking strategies. 28 29 Error checking strategies are chained into an L{ErrorCheckingChain} to 30 implement a Chain of Responsibility. Each strategy in the chain is 31 called until an error is detected. The strategy raises a 32 L{smartcard.sw.SWException} exception when an error is detected. 33 34 Implementation derived from Bruce Eckel, Thinking in Python. The 35 L{ErrorCheckingChain} implements the Chain Of Responsibility design 36 pattern. 37 """ 38
39 - def __call__(data, sw1, sw2):
40 """Called to test data, sw1 and sw2 for error. 41 42 @param data: apdu response data 43 @param sw1, sw2: apdu data status words 44 45 Derived classes must raise a L{smartcard.sw.SWException} upon error.""" 46 pass
47