1 """Card class.
2
3 __author__ = "gemalto http://www.gemalto.com"
4
5 Copyright 2001-2011 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 from smartcard.Exceptions import CardConnectionException, NoCardException
25 from smartcard.reader.Reader import Reader
26 from smartcard.System import readers
27 from smartcard.util import toHexString
28
29
31 """Card class."""
32
34 """Card constructor.
35 reader: reader in which the card is inserted
36 atr: ATR of the card"""
37 self.reader = reader
38 self.atr = atr
39
41 """Return a string representing the Card (atr and reader
42 concatenation)."""
43 return toHexString(self.atr) + ' / ' + str(self.reader)
44
46 """Return True if self==other (same reader and same atr).
47 Return False otherwise."""
48 if isinstance(other, Card):
49 return (self.atr == other.atr and `self.reader` == `other.reader`)
50 else:
51 return False
52
54 """Return True if self!=other (same reader and same atr).Returns
55 False otherwise."""
56 return not self.__eq__(other)
57
59 """Returns a hash value for this object (str(self) is unique)."""
60 return hash(str(self))
61
77