1 """Card class.
2
3 __author__ = "gemalto 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 from smartcard.reader.Reader import Reader
25 from smartcard.System import readers
26 from smartcard.util import toHexString
27
28
30 """Card class."""
31
33 """Card constructor.
34 reader: reader in which the card is inserted
35 atr: ATR of the card"""
36 self.reader = reader
37 self.atr = atr
38
40 """Return a string representing the Card (atr and reader
41 concatenation)."""
42 return toHexString(self.atr) + ' / ' + str(self.reader)
43
45 """Return True if self==other (same reader and same atr).
46 Return False otherwise."""
47 if isinstance(other, Card):
48 return (self.atr == other.atr and
49 repr(self.reader) == repr(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
78